Maven Dependency Plugin go-offline not downloading some plugins - java

I am trying to download all transitive dependencies and plugins for a pom file into a local folder and then using it to run sonarqube offline. I am fairly new to Maven, so I might be doing something wrong here, but I think maven maven-dependency-plugin:3.1.1:go-offline is not downloading all plugins needed to run sonarqube, which is causing an error.
This is what I have tried.
Download all dependcies to a new folder
mvn -D"maven.repo.local"="c:\test\test" org.apache.maven.plugins:maven-dependency-plugin:3.1.1:go-offline
run sonar
mvn -o -D"maven.repo.local"="c:\test\test" sonar:sonar
This however gives me the following error
[INFO] Scanning for projects...
[WARNING] The POM for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-antrun-plugin:jar:1.3 has not been downloaded from it before.
[WARNING] The POM for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5 has not been downloaded from it before.
[WARNING] The POM for org.apache.maven.plugins:maven-dependency-plugin:jar:2.8 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-dependency-plugin:2.8: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-dependency-plugin:jar:2.8 has not been downloaded from it before.
[WARNING] The POM for org.apache.maven.plugins:maven-release-plugin:jar:2.5.3 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-release-plugin:2.5.3: Plugin org.apache.maven.plugins:maven-release-plugin:2.5.3 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-release-plugin:jar:2.5.3 has not been downloaded from it before.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.133 s
[INFO] Finished at: 2019-04-30T14:35:43+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'sonar' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (c:\test\test), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions,
please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
The POM file is as below
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>HelloWorld</groupId>
<artifactId>HelloWorld_Test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
</dependency>
</dependencies>
</project>
Since it is complaining about various plugins not being available, I gather there is a problem with the maven-dependency-plugin not downloading all necessary plugins needed to run sonarqube ? Any ideas how to get around this?

sonar-maven-plugin should be declared as a plugin and not as a dependency.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
</plugin>
</plugins>
</pluginManagement>
</build>

Related

maven - skip dependency during build

I want to skip demo-api (Which is another module) during build. Setting optional true doesn't work. Any suggestions on how to skip it but not delete the dependency from pom.xml?
Failed to execute goal on project [36mdemo-web[m: [1;31mCould not resolve dependencies for project demo-web:demo-web:war:1.0-SNAPSHOT: Failed to collect dependencies at demo-api:demo-api:jar:1.0-SNAPSHOT[m: Failed to read artifact descriptor for demo-api:demo-api:jar:1.0-SNAPSHOT: Could not find artifact demo-spring-boot:demo-spring-boot:pom:1.0-SNAPSHOT
<dependency>
<artifactId>demo-api</artifactId>
<groupId>demo-api</groupId>
<version>1.0-SNAPSHOT</version>
<optional>true</optional>
</dependency>
You can put that dependency in a profile:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.foo</groupId>
<artifactId>foo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>
<name>foo</name>
<profiles>
<profile>
<id>includeBadDependency</id>
<dependencies>
<dependency>
<artifactId>demo-api</artifactId>
<groupId>demo-api</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
</profiles>
<!-- Normal dependencies go here-->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.5.RELEASE</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
When you build this project:
$ mvn verify # this will succeed
$ mvn verify -PincludeBadDependency
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------< org.foo:foo >-----------------------------
[INFO] Building foo 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from maven-atlassian-com: https://packages.atlassian.com/maven/repository/internal/demo-api/demo-api/1.0-SNAPSHOT/maven-metadata.xml
Downloading from maven-atlassian-com: https://packages.atlassian.com/maven/repository/internal/demo-api/demo-api/1.0-SNAPSHOT/demo-api-1.0-SNAPSHOT.pom
[WARNING] The POM for demo-api:demo-api:jar:1.0-SNAPSHOT is missing, no dependency information available
Downloading from maven-atlassian-com: https://packages.atlassian.com/maven/repository/internal/demo-api/demo-api/1.0-SNAPSHOT/demo-api-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.434 s
[INFO] Finished at: 2021-09-21T18:24:24+10:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project foo: Could not resolve dependencies for project org.foo:foo:jar:1.0.0-SNAPSHOT: Could not find artifact demo-api:demo-api:jar:1.0-SNAPSHOT in maven-atlassian-com (https://packages.atlassian.com/maven/repository/internal) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
Maybe this can give you a hint or two.
<scope>runtime</scope>
I think this will do the trick

Maven version dependency

i want to add the spark-connector-cassandra to my java project, using Maven. When i add the dependecies, maven don't recognize the version (mark it of red). Why? I added also spark dependency but with this dependency there is no problem.
This is my pom file.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.spark.test</groupId>
<artifactId>spark-count</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector_2.11</artifactId>
<version>**2.3.0**</version>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
The bold version is the problem. how can i resolve the problem? Thanks ;)
I tired to run mvn dependency:resolve but this is the result
C:\Users\Utente>mvn dependency:resolve
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plugin:2.7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-site-plugin/3.3/maven-site-plugin-3.3.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-site-plugin:3.3: Plugin org.apache.maven.plugins:maven-site-plugin:3.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-site-plugin:jar:3.3
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-antrun-plugin/1.3/maven-antrun-plugin-1.3.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-dependency-plugin:2.8: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-dependency-plugin:jar:2.8
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.3.2/maven-release-plugin-2.3.2.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-release-plugin:2.3.2: Plugin org.apache.maven.plugins:maven-release-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-release-plugin:jar:2.3.2
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (http://repo.maven.apache.org/maven2): Connect to 10.0.3.69:3128 [/10.0.3.69] failed: Connection timed out: connect
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (http://repo.maven.apache.org/maven2): Connect to 10.0.3.69:3128 [/10.0.3.69] failed: Connection timed out: connect
[WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to central (http://repo.maven.apache.org/maven2): Connect to 10.0.3.69:3128 [/10.0.3.69] failed: Connection timed out: connect
[WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (http://repo.maven.apache.org/maven2): Connect to 10.0.3.69:3128 [/10.0.3.69] failed: Connection timed out: connect
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:50 min
[INFO] Finished at: 2018-08-17T11:54:53+01:00
[INFO] Final Memory: 7M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'dependency' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\Utente\.m2\repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
Try running mvn dependency:resolve and see what happens.
When you say
maven don't recognize the version (mark it of red)
I think this is related to an IDE, so maybe you need to reload the project on the IDE (Maven projects > Reimport on IntelliJ). But basically mvn dependency:resolve should download the missing dependency (com.datastax.spark:spark-cassandra-connector_2.11:2.3.0), and it should be now available from the IDE.

Unresolvable build extension: Plugin com.opencloud.maven.plugins:maven-opencloud-jainslee-plugin:1.1

I am getting below error when I run any maven command like mvn clean or mvn clean install or mvn eclipse:eclipse.
But I am able to run any other maven project other than this in my system so I am sure it is not related to path issues or with proxy.
Below is my error
1.[ERROR] The build could not read 1 project -> [Help 1] org.apache.maven.project.ProjectBuildingException: Some problems were
encountered while processing the POMs:
2.[ERROR] Unresolveable build extension: Plugin com.opencloud.maven.plugins:maven-opencloud-jainslee-plugin:1.1 or one
of its dependencies could not be resolved: Failure to find
"com.opencloud.maven.plugins:maven-opencloud-jainslee-plugin:jar:1.1"
in "http://repo.maven.apache.org/maven2" was cached in the local
repository, resolution will not be reattempted until the update
interval of central has elapsed or updates are forced #
3.[ERROR] Unknown packaging:"
I Generated sbb files with maven command,
mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeCatalog=http://developer.opencloud.com/maven2/public it generated successfully.
But when build it with mvn clean install, it has above errors
Below is my POM.xml
<modelVersion>4.0.0</modelVersion>
<groupId>com.bt</groupId>
<artifactId>myapp-sbb</artifactId>
<packaging>jainslee-sbb-jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>myapp SBB</name>
<dependencies>
<dependency>
<groupId>javax.slee</groupId>
<artifactId>jainslee-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.opencloud</groupId>
<artifactId>jainslee-base-classes</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.opencloud.maven.plugins</groupId>
<artifactId>maven-opencloud-jainslee-plugin</artifactId>
<extensions>true</extensions>
<version>1.1</version>
<configuration>
<jainsleeVersion>1.1</jainsleeVersion>
<createLibrary>true</createLibrary>
<createDeploymentUnit>true</createDeploymentUnit>
</configuration>
</plugin>
</plugins>
</build>
I will get below error when I run maven clean in both command line and eclipse
C:\Users\611542579\Documents\NOAS-CSG\Sample\com.bt>mvn clean
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project myApp:com.bt-sbb:1.0-SNAPSHOT
(C:\Users\611542579\Documents\NOAS-CSG\Sample\com.bt\pom.xml) has 2 errors
[ERROR] Unresolveable build extension: Error resolving version for plugin
'com.opencloud.maven.plugins:maven-opencloud-jainslee-plugin'
from the repositories
[local (C:\Users\611542579\.m2\repository),
central (http://repo.maven.apache.org/maven2)]:
Plugin not found in any plugin repository -> [Help 2]
[ERROR] Unknown packaging: jainslee-sbb-jar # line 7, column 16
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginVersionResolutionException
Maybe you need something like this in your pom:
<pluginRepositories>
<pluginRepository>
<id>jainslee</id>
<name>Jainslee repos</name>
<url>http://developer.opencloud.com/maven2/public</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
This
http://developer.opencloud.com/maven2/public
is what you give in command line but is it in your pom also?
It can be also that there is a problem with your local maven repo. Try the following:
find corresponding path in your local maven repo
{home}/.m2/repositories/com/opencloud/maven/plugins/maven-opencloud-jainslee-plugin
and delete that directory. Try again.
UPDATE: take a look this part on the error message
[ERROR] Unresolveable build extension: Error resolving version for plugin
'com.opencloud.maven.plugins:maven-opencloud-jainslee-plugin'
from the repositories
[local (C:\Users\611542579\.m2\repository),
central (http://repo.maven.apache.org/maven2)]:
Plugin not found in any plugin repository -> [Help 2]
You can see that plugin is first searched from your local then from central maven repository. It is not found there. It should be searched from here
http://developer.opencloud.com/maven2/public
and that is why there is a need for that <pluginRepositories> part in your pom.
If you cannot edit the pom in question create dummy project, add this pluginRepository and plugin in that project, run it like mvn install: it should download plugin to your local repo.
Maybe then you are able to run original project in question without errors.

Maven Plugin issue for Wsgen tag

After tried several thing as posted by me on :
Unable to do wsdl generation by maven plugin
I find the below issue after trying with several versions of mojo jaxws plugin which is already discussed in a site:
Get "java.lang.NoClassDefFoundError" though the class is in the classpath
So as per the suggestion I tried to add the tools jar in the plugin section just above org.codehaus.mojo.
I think this what it is suggested and one of the guy find the solution.
<plugin>
<dependencies>
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.7</version>
<scope>system</scope>
<systemPath>${JAVA_HOME}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>${jaxws-maven-plugin.version}</version>
</plugin>
But trying that ended up having the below issue: Please provide any suggestion , if I am going wrong anywhere.
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) jdk.tools:jdk.tools:jar:1.7
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dversion=1.7 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dversion=1.7 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.codehaus.mojo:jaxws-maven-plugin:maven-plugin:1.9
2) jdk.tools:jdk.tools:jar:1.7
----------
1 required artifact is missing.
for artifact:
org.codehaus.mojo:jaxws-maven-plugin:maven-plugin:1.9
from the specified remote repositories:
releases (https://dsnexus.us.hibm.hex:8081/nexus/content/repositories/releases),
dsnexus-snapshots (https://dsnexus.us.hibm.hex:8081/nexus/content/repositories/snapshots),
R2 (http://dsnexus.us.hibm.hex:8081/nexus/content/groups/public),
snapshots (https://dsnexus.us.hibm.hex:8081/nexus/content/repositories/snapshots),
jboss (http://repository.jboss.org/nexus/content/groups/public-jboss),
dsnexus (https://dsnexus.us.hibm.hex:8081/nexus/content/groups/prd)
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Missing:

Maven enforcer plugin and missing dependencies

Here is a minimal project:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>enforcer</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-env</id>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
<configuration>
<rules>
<requireProperty>
<property>custom</property>
<message>You must set custom property.</message>
</requireProperty>
</rules>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>enforcer-dep</artifactId>
<version>1.0.0</version>
<classifier>${custom}</classifier>
</dependency>
</dependencies>
</project>
When running:
mvn -Dcustom=some-value validate
Validation goes OK.
When running:
mvn enforcer:enforce
or any phase from validate to process-resources
mvn validate
mvn initialize
mvn generate-sources
mvn process-sources
mvn generate-resources
mvn process-resources
I get expected fail with message:
[...]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-env) # enforcer ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
You must set custom property.
[...]
But when I run any other (later) phase from compile up to deploy e.g.:
mvn install
I get the error about missing dependency but there is no fail caused by enforcer plugin:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building enforcer 1.0.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.test:enforcer-dep:jar:${custom}:1.0.0 is missing, no dependency information available
Downloading: http://repo.maven.apache.org/maven2/com/test/enforcer-dep/1.0.0/enforcer-dep-1.0.0-${custom}.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.983s
[INFO] Finished at: Fri Nov 22 09:22:24 CET 2013
[INFO] Final Memory: 7M/152M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project enforcer: Could not resolve dependencies for project com.test:enforcer:jar:1.0
.0: Could not transfer artifact com.test:enforcer-dep:jar:${custom}:1.0.0 from/to central (http://repo.maven.apache.org/
maven2): Illegal character in path at index 84: http://repo.maven.apache.org/maven2/com/test/enforcer-dep/1.0.0/enforcer
-dep-1.0.0-${custom}.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
It looks for me like enforcer plugin is not executed at all, or dependencies are checked first before project can be build when running compile and later phases.
But why dependencies are not checked when running up to process-resources?
Obviously you seemed to have changed the settings of the maven installation which went wrong based on the error message:
[WARNING] Some problems were encountered while building the effective settings
[WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ...ever maven must make a connection to a remote s
erver.\n |-->\n <s... #111:5) # C:\programs\Maven\3\bin\..\conf\settings.xml
This means first clean up the conf/settings.xml file. Best is to use the default file which came via the installation. If you need to make modification do this in the users settings.xml $HOME/.m2/settings.xml or on Windows C:/Users/UserName/.m2/settings.xml
Apart from that i don't know what you like to achieve by using something like this:
[WARNING] The POM for com.test:enforcer-dep:jar:${custom}:1.0.0 is missing, no dependency information available
Downloading: http://repo.maven.apache.org/maven2/com/test/enforcer-dep/1.0.0/enforcer-dep-1.0.0-${custom}.jar

Categories

Resources