I would like to enforce the requireReleaseDeps rule of the Maven Enforcer Plugin on a Maven project without any POM configuration simply as a command line call.
According to the docs I should be able to just pass in the rules parameter like so
mvn enforcer:enforce -Drules=requireReleaseDeps
or maybe this should work
mvn enforcer:enforce -Drules=org.apache.maven.plugins.enforcer.RequireReleaseDeps
However both of these calls result in
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (default-cli) on project hel
lo-world: The parameters 'rules' for goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce are missing or in
valid -> [Help 1]
Anybody know if this usage scenario actually works somehow or do I have to dive into debugging the plugin at this stage to figure this out?
It works with the 3.0.0-M3 version:
mvn org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce -Drules=requireReleaseDeps
With the version 3.0.0-M3 of the plugin and newer release the enforcer goal now supports the rules parameter and command line execution without config in the pom. See more at https://maven.apache.org/enforcer/maven-enforcer-plugin/enforce-mojo.html#commandLineRules
Unfortunately there is currently no such functionality but there is already a JIRA Issue for that.
It is available from 3.0.0. The Jira issue from accepted answer got resolved: https://issues.apache.org/jira/browse/MENFORCER-142
mvn enforcer:enforce -Drules=alwaysPass,alwaysFail
Worked for me using Atlassian's fork of the plugin:
mvn org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-atlassian-m01:enforce -Drules=...
I had to declare their plugin repository:
<pluginRepositories>
....
<pluginRepository>
<id>atlassian-3rdparty</id>
<url>https://maven.atlassian.com/3rdparty</url>
</pluginRepository>
</pluginRepositories>
Hope this helps.
Related
I am getting this error: [ERROR] Plugin org.apache.maven.plugins:maven-surefire-plugin:2.12.4 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-surefire-plugin:jar:2.12.4 in nexus-xyz-plugin
I tried to run maven with dependecy:tree, but I can't see surefire, and I dont know why it is looking for this specific version 2.12.4 which is not specified in my pom!
Even the surefire plugin is not defined in my pom, but I have the assembly plugin not sure if assembely is dependent on surefire
Note that I only get the error when running mvn package, however when running mvn compile the build succeeds
Version 2.12.4 of the maven-surefire-plugin is always added to the pom by maven version 3.x unless you depend on a specific other version.
Maven has a so called super pom that you get for free, but that doesn't list surefire: https://maven.apache.org/ref/3.8.5/maven-model-builder/super-pom.html
However it is added to the pom, i've checked this with maven 3.3.9. You can verify this by running mvn help:effective-pom.
Reference with the same problem: No surefire plugin in my pom - How does it show surefire output?
These plugin versions are part of the default bindings for lifecycle executions, in this case of the test phase. So these plugins are always included if not specified.
See for reference:
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
https://maven.apache.org/ref/3.8.5/maven-core/default-bindings.html
Maven default life-cycle and plugins section
Normally this plugin should be available in maven central, check if you have a <pluginRepository> in your (effective) pom that references https://repo1.maven.org/maven2/
Some other things you can check:
Open the file .m2\repository\org\apache\maven\plugins\maven-surefire-plugin\2.12.4\maven-surefire-plugin-2.12.4.jar.lastUpdated and check the error message for each repository. Check why it can't reach maven central; is it missing from the list or giving an error? This might be a company firewall/policy issue perhaps? Or is it giving an error on HTTPS/TLS protocol level?
Check if you can add maven central to your repositories list if it's missing somehow (should be included by default). Check if it's HTTP or HTTPS, only secure is supported now.
Run your maven command with -X for debug mode to investigate further
An alternative is to add the latest version of surefire to your project that is available in your plugin-repository, and perhaps disable it if you're not executing unit tests.
See Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.
When I use this command :
mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/public/ -DarchetypeCatalog=remote -DarchetypeVersion=1.3.1-Carbon
Then result is
Error: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: The desired archetype does not exist (org.opendaylight.controller:opendaylight-startup-archetype:1.3.1-Carbon)
The OpenDaylight project doesn't use Maven Central (yet) to publish artifacts, so you need to tell Maven where the ODL repositories are. For that you need your $HOME/.m2/settings.xml file set up as described in the developer documentation here. I recommend you use the latest archetype version (1.6.0), since if you run into issues that's the most likely you will be able to get support with.
Please follow the official documentation on docs.opendaylight.org.
The community on the archetypes-dev mailing list may also be able to help.
I'm trying associate maven artifacts name with build number.
ex: sample.1.0.0-snapshot.ear into sample.1.0.0-snapshot.buildnumber.ear
I have tried maven-buildnumber plugin but still no luck.
could anyone help me to do this.
You can use the Versions Maven plugin by executing following command before any other maven targets after clean.
mvn versions:set -DnewVersion=sample.1.0.0-snapshot.$BUILD_NUMBER
For my build process, I need two custom maven plugins (see here). It works fine when deploying it to my local maven repository with mvn install.
However, I need to make it accessible for other developer's in my team and integration testing.
I noticed that you could setup a light-weight maven repository on github so that's what I did for now: https://github.com/rweng/mvn-repo
This works fine for normal dependencies like ch.yax.yocto.yocto-server, however, it fails for my plugins with the message
[WARNING] The POM for com.arcanio.maven.plugin:velocity:jar:0.1-SNAPSHOT is missing, no dependency information available**
[ERROR] Plugin com.arcanio.maven.plugin:velocity:0.1-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.arcanio.maven.plugin:velocity:jar:0.1-SNAPSHOT: Could not find artifact com.arcanio.maven.plugin:velocity:pom:0.1-SNAPSHOT -> [Help 1]
I tried substituting the github url in my repositories section through file:///, Though I doubt the problem lies here. I also doubt that this is a proxy problems, as many users with the same error reported.
Is is possible that mvn install deploys s.th. different than my deployment command
mvn -DaltDeploymentRepository=snapshot-repo::default::file:/Users/robin/Code/mvn-repo/ clean deploy
Thanks in advance for any hints how to solve this.
EDIT
I just moved the plugin from my local repository to the github repository and notice the following changes.
D com/arcanio/maven/plugin/maven-metadata.xml
D com/arcanio/maven/plugin/maven-metadata.xml.md5
D com/arcanio/maven/plugin/maven-metadata.xml.sha1
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/maven-metadata.xml
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/maven-metadata.xml.md5
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/maven-metadata.xml.sha1
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.jar
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.jar.md5
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.jar.sha1
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.pom
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.pom.md5
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.pom.sha1
D com/arcanio/maven/plugin/velocity/maven-metadata.xml
D com/arcanio/maven/plugin/velocity/maven-metadata.xml.md5
D com/arcanio/maven/plugin/velocity/maven-metadata.xml.sha1
?? com/arcanio/maven/plugin/maven-metadata-local.xml
?? com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/_maven.repositories
?? com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/maven-metadata-local.xml
?? com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-SNAPSHOT.jar
?? com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-SNAPSHOT.pom
?? com/arcanio/maven/plugin/velocity/maven-metadata-local.xml
So mvn install really does generate something different. Does anyone know why? I thought mvn install was basically the same as mvn deploy but to the local repository.
EDIT
Using mvn -DuniqueVersion=false fixes the unique versions. See here.
EDIT
uniqueVersion=false does not work anymore with maven 3. So the problem stays the same, the timestamped versions are not found in the repository. I think I might be missing a artifactid-snapshot pom.
SOLUTION
Solution found here:
The repository must be added as pluginRepository:
<pluginRepositories>
<pluginRepository>
<id>rweng-plugins</id>
<url>https://github.com/rweng/mvn-repo/raw/master</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
The best solution for such things is to install a repository manager in your company.
Can you please explain this command detailedly, please? What is exec? and exec:exec? -Pexperiment? -DconfigFile?
mvn exec:exec -Pexperiment -DconfigFile=src/test/resources/configFile/configFile-demo000.js
Its runnng the exec goal defined by the exec plug-in using the 'experiment' profile. The 'configFile' value is also being defined in the command-line as an system property.
mvn is the Maven Command
exec:exec is a shortcut for the goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (version may differ). This is described here: http://mojo.codehaus.org/exec-maven-plugin/exec-mojo.html.
-Pexperiment is telling maven to use a Build Profile called experiment. Build Profiles are described here: http://maven.apache.org/guides/introduction/introduction-to-profiles.html
-DconfigFile=... is a system property that is being used by maven in the pom file or by a plugin. Maven properties are described here: http://www.sonatype.com/books/mvnref-book/reference/resource-filtering-sect-properties.html. How to configure plugins is described here: http://maven.apache.org/guides/mini/guide-configuring-plugins.html