Mvn install or Mvn package

后端 未结 8 1239
清歌不尽
清歌不尽 2020-12-07 13:41

I am new to Maven, I have a Java based web project with maven configured in my MyEclipse.
Now if I modified any java files then do I need to do Run as -> Mvn in

相关标签:
8条回答
  • 2020-12-07 13:55

    From the Lifecycle reference, install will run the project's integration tests, package won't.

    If you really need to not install the generated artifacts, use at least verify.

    0 讨论(0)
  • 2020-12-07 13:56

    It depends on what you're trying to achieve after changing the Java file. Until you want to test the maven process, you never need to do anything. Eclipse/MyEclipse will build what is necessary and put the output in the appropriate place within your project. You can also run or deploy it (if it's a web project, for example), without your needing to explicitly do anything with maven. In the end, to install your project in the maven repository, you will need to do a maven install. You may also have other maven goals that you wish to execute, which MyEclipse won't do automatically.

    As I say, it depends on what you want to do.

    0 讨论(0)
  • 2020-12-07 14:06

    If you're not using a remote repository (like artifactory), use plain old: mvn clean install

    Pretty old topic but AFAIK, if you run your own repository (eg: with artifactory) to share jar among your team(s), you might want to use

    mvn clean deploy

    instead.

    This way, your continuous integration server can be sure that all dependencies are correctly pushed into your remote repository. If you missed one, mvn will not be able to find it into your CI local m2 repository.

    0 讨论(0)
  • 2020-12-07 14:06

    The proper way is mvn package if you did things correctly for the core part of your build then there should be no need to install your packages in the local repository.

    In addition if you use Travis you can "cache" your dependencies because it will not touch your $HOME.m2/repository if you use package for your own project.

    In practicality if you even attempt to do a mvn site you usually need to do a mvn install before. There's just too many bugs with either site or it's numerous poorly maintained plugins.

    0 讨论(0)
  • 2020-12-07 14:12

    Also you should note that if your project is consist of several modules which are dependent on each other, you should use "install" instead of "package", otherwise your build will fail, cause when you use install command, module A will be packaged and deployed to local repository and then if module B needs module A as a dependency, it can access it from local repository.

    0 讨论(0)
  • 2020-12-07 14:14

    from http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

    package: take the compiled code and package it in its distributable format, such as a JAR.

    install: install the package into the local repository, for use as a dependency in other projects locally

    So the answer to your question is, it depends on whether you want it in installed into your local repo. Install will also run package because it's higher up in the goal phase stack.

    0 讨论(0)
提交回复
热议问题