I am using maven-release-plugin on a multi-module project with the following layout:
ROOT/
+ parent
+ module1
+ module2
In the parent's pom, the child modules configured using modules element. Each one of the projects are configured to use the plugin with basic configuration and a tag base for each. I have the following problems:
When I run mvn release:prepare on parent, after the line that says Checking for snapshot dependencies ..., I receive no prompt to enter the versions. If I press Enter for the number of questions it requires answer, it continues. Why do not I receive prompts on the screen? (The same thing happens if run with -DdryRun=true)
After running mvn release:prepare (with or without -DdryRun=true), the release:prepare is SKIPPED for the child modules.
I am using the basic configuration on the plugin's guide. I'd be thankful for any ideas or clues of what's wrong.
Regarding the lack of prompts, are you running mvn through a pipe? This happened to me when I was using a script to do colour highlighting of Maven's log output, because Maven doesn't output a newline after the prompt.
By the way, you may be able to use mvn's -B option to run in batch mode; maven-release-plugin will use the default values instead of prompting.
Related
I have a maven multi-module project . In the parent module there is a certain dependency which is mentioned in dependencyManagement-> dependencies section say x.
Now in one of the child modules , few classes belonging to artifact x are being used.
So, ideally mvn clean install should not pass as we also need to mention the same dependency in the pom of child module.
But surprisingly mvn clean install passes from the command line but Intellij Idea asks to add dependency to the child pom. What might be the reason behind this behaviour
I am learning about Jenkins and I have to explore some existing build jobs that others wrote (in the company that I'm working).
So I am trying to understand a job which uses mvn command.
So under the build part (inside the job), I see these details:
Maven version: 3.0.5
Root POM: pom:xml
Goals and options: clean install -U -Pnotest,docs
I'm trying to understand what this mvn command means?
I tried to google it: "clean install -U"
But I didn't find what the parameter U means.
And I don't know what is "-Pnotest,docs".
can you guide me regarding how I can find what's it? (maybe "-Pnotest,docs" is from a xml file or it's from the artifactory etc..)
Thanks a lot!!!!
-U Forces a check for miss releases and updated snapshots on remote repositories
If Maven is regularly used in your company, and you will have to work with it on a day-to-day basis, I would advise you to find a mentor (any colleague that knows the tool well and is ready to share its knowledge with you) and work with them. Maven, when you first look at it, can be quite of a mouthful and you'll learn it more efficiently with their help.
For the problem at hand, Elarbi Mohamed Aymen's answer already tells you what the -U flag corresponds to. As for -P, it is used to activate profiles (in your case notest and docs). These profiles are usually defined in the pom.xml of the project being build.
See Running Apache Maven for the basic commands, and as advised on that page run mvn -h to have the complete list of flags the command can use.
Maven is one of the mechanism how to handle the build process and check project dependencies, especially for Java.
One of the option can be to have physically included dependencies (artifacts / libs) in the project, but its not so useful- in case of new version, you have to replace the file, sometimes you are using same lib in more apps, ten you have to handle it manually in all projects.
Except this, there is the maven- it has a global repository with shared artifacts / libs , which are common used- ref. https://repo1.maven.org/maven2/.
Except this, you can make your own libs/ artifacts in this case, its a modules / applications which are reusable, then you are storing it in private repository- this is the artifactory.
When you want to build your project, in case of maven project you have pom.xml , which is like manual for maven what to do / how to build.
clean and install are common goals, clean will wipe your local maven repository, install will download them again, with parameter -U it force to download them.
You can define your own goals in pom file, eg. to "tree build"- build some dependent modules, then build parent project.
Eg. with -D you pass parameters to the maven eg.
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app
- that will generate new project, based on given archetype- "template", with the given groupID and artifactID- groupID can be eg. company name, artifactID is then the name of specific app / component.
-P,--activate-profiles <arg> Comma-delimited list of profiles
to activate
-D,--define <arg> Define a system property
This is probably a question on Maven internals, and I haven't had much luck searching and finding the answer. Concisely, I'm interested in seeing what commands Maven actually execute for each phase or goal. For example, mvn package creates the jar file, so I'd think it must call the jar -cf command at some point.
Maven is opinionated so by design, this command doesn't show up in the .pom file. But which commands does Maven actually run for a specific phase and goal? Is there a way to see them?
The call creating a jar file is done in the maven-jar-plugin which is bound to the life cycle. You can do a mvn -X clean package to what happens behind the scenes. But you won't see many commands (except for javac compiling)... What do you mean by: Maven is opinionated so by design, this command doesn't show up in the .pom file?
The life cycles shows what kind of phases run bindings shows which plugins runs in which phase.
If you want to take a look into the sources of plugins all plugins can be found here: https://maven.apache.org/plugins/
On the right side you can see links to the appropriate version control system with links to it.
Each plugin has a link to the source code for example maven-jar-plugin: https://maven.apache.org/plugins/maven-jar-plugin/source-repository.html
Run mvn with the -X parameter, then look for lines starting with "[DEBUG] Executing command line:".
All the plugins are written in Java (or JVM-based languages), so if you can read it - you can find out what it does. Here are for example sources of the maven-jar-plugin: link1, link2.
But to get there you need to figure out which plugins and goals are executed when you run a phase. There are multiple ways:
In the output Maven says which goals it executes, example:
maven-resources-plugin:2.6:resources (default-resources) # module-name
If you generate an Effective POM, you'll be able to see all the plugins and which phases they are bound to: mvn help:effective-pom. Some plugins have default phases so people don't have to specify them explicitly - for these you'd have to look into the plugin meta information or into the sources.
Default plugins and goals are defined by the packaging. For the default packagings you could look into default-bindings.xml (role-hint is the packaging name).
After you know which plugins and goals are executed you can check out the sources of each plugin (the sources are usually open) and see its Mojos for the actual source code.
If you decide to learn the code it would be useful to be able to debug it when you run a mvn command. For that you can use mvnDebug instead of mvn.
More info: click1, click2.
I want maven-javadoc-plugin to be skipped by default, during the
mvn clean install command, so I have added <skip>true<skip> in the pom.xml
But I want it to be executed whenever needed, so I am trying something like
mvn clean install -Dmaven.javadoc.skip=false But it seems that it is overriding this setting with that in pom.xml and not executing the javadoc plugin.
What can I do to resolve this problem?
You could create a profile for the plugin execution (move it from the normal build generation). Within the profile, simply state that the plugin should run when you want it. The idea is that when you do a run without the profile included in arguments, it won't run; if you include the profile argument, it'll be kicked off:
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
Run arguments would look something like:
mvn groupId:artifactId:goal -P profile-1
I’m confused as to how the version number in a pom file and the system properties like -DdevelopmentVersion=2.0-SNAPSHOT and -DreleaseVersion=1.2 work when maven is run in non-interactive mode.
When I run mvn –B release:prepare –Dtag=1.2 -DdevelopmentVersion=2.0-SNAPSHOT -DreleaseVersion=1.2 for a pom.xml with <version>1.0-SNAPSHOT</version> and <packaging>jar</packaging> the resulting jar file uses the pom version number not the command line version, i.e xxx-1.0-SNAPSHOT.jar .
Is this the expected behaviour and if so what is the point of specifying the versions on the command line ?
You should be aware that the release:prepare is the first part of the release process. Afterwards you need to give release:perform which will checkout the created tag from version control and start the build for the artfiact whcih will be really released.
So I found my mistake:
Before running the example release:prepare in my question I had carried out a dryRun i.e. using the option-DdryRun=true .
This had created a release.properties file which was be used by subsequent release:prepare commands until it was cleaned up using release:clean