Maven version dependency - java

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.

Related

maven-surefire-plugin:2.18.1:test failed

I'm studying "Cloud-Native Applications in Java" and I'm doing the exercise in this book. This is my pom.xml:
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
</parent>
<groupId>com.mycompany.petstore</groupId>
<artifactId>product</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I set up the settings of Maven on a specific path: C:\Users\Sam.m2\settings.xml
The only information that I set up on my settings.xml is the following:
...
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>localhost:8080</host>
<nonProxyHosts>localhost,127.0.0.1</nonProxyHosts>
<port>8080</port>
</proxy>
</proxies>
When I try to run this program (a simple program with three java classes), in my console there is:
--- maven-surefire-plugin:2.18.1:test (default-test) # product ---
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/maven-surefire-common/2.18.1/maven-surefire-common-2.18.1.pom
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-api/2.18.1/surefire-api-2.18.1.pom
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-toolchain/2.2.1/maven-toolchain-2.2.1.pom
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-annotations/3.3/maven-plugin-annotations-3.3.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.873 s
[INFO] Finished at: 2019-07-21T15:32:13+02:00
[INFO] Final Memory: 18M/224M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project product: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.18.1 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-surefire-plugin:jar:2.18.1 -> org.apache.maven.surefire:maven-surefire-common:jar:2.18.1: Failed to read artifact descriptor for org.apache.maven.surefire:maven-surefire-common:jar:2.18.1: Could not transfer artifact org.apache.maven.surefire:maven-surefire-common:pom:2.18.1 from/to central (https://repo.maven.apache.org/maven2): localhost:8080 -> [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/PluginResolutionException
How can I solve the problem?

Maven Dependency Plugin go-offline not downloading some plugins

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>

Heroku not resolves local Maven dependencies

I am using custom dependencies in my project, hosted on Heroku, and when I push my changes via Git, the server throws this log (Maven tries to download from public repositories):
... Remote repositories download ...
[INFO] Downloading: https://repo.maven.apache.org/maven2/javax/inject/javax.inject/1/javax.inject-1.jar //Example of correct file
[INFO] Downloading: file:/tmp/build_2b1a7b0432368beb5dc5ba232fac767a/repo/com/example/functions/17.0/functions-17.0.jar
[INFO] Downloading: file:/tmp/build_2b1a7b0432368beb5dc5ba232fac767a/repo/com/example/routines/17.0/routines-17.0.jar
... More downloads ...
[INFO] Downloading: https://repo.maven.apache.org/maven2/com/example/routines/17.0/routines-17.0.jar
[INFO] Downloading: https://repo.maven.apache.org/maven2/com/example/functions/17.0/functions-17.0.jar
... More downloads ...
[INFO] Downloaded: https://repo.maven.apache.org/maven2/javax/inject/javax.inject/1/javax.inject-1.jar (3 KB at 7.6 KB/sec) //Correct file downloaded
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.755 s
[INFO] Finished at: 2015-12-04T09:19:40+00:00
[INFO] Final Memory: 14M/241M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project example-project: Could not resolve dependencies for project example-project:example-project:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.example:functions:jar:17.0, com.example:routines:jar:17.0: in project.local (file:/tmp/build_2b1a7b0432368beb5dc5ba232fac767a/repo) -> [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
I followed this guide and I don't use settings.xml file. My pom.xml is this:
<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>example-project</groupId>
<artifactId>example-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>My example project</name>
<description>Example of Maven Project</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>project.local</id>
<name>project</name>
<url>file:${project.basedir}/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>functions</artifactId>
<version>17.0</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>routines</artifactId>
<version>17.0</version>
</dependency>
... More dependencies ...
</dependencies>
... Plugins ...
</project>
How can I upload my custom JARs to Heroku?
I solved it adding Maven plugin for Heroku and uploading the project with the Maven command.

Maven Illegal Argument Exception

I am new to Maven and would love some help with an issue I've been having. I am not able to compile one of my projects due to an Illegal Argument Exception for one of the dependency URLs. Here is my pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="https://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>
<name>MDM-Map-Reduce</name>
<groupId>com.cardinalhealth</groupId>
<artifactId>MDM-Map-Reduce</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<repositories>
<repository>
<id>hortonworks</id>
<url>
http://repo.hortonworks.com/content/repositories/releases/
</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.hcatalog</groupId>
<artifactId>hcatalog-core</artifactId>
<version>0.5.0.21</version>
</dependency>
</dependencies>
</project>
And here is the last few lines of the output from mvn clean install:
Downloading: http://repo.hortonworks.com/content/repositories/releases/org/apache/hcatalog/hcatalog-core/0.5.0.21/hcatalog-core-0.5.0.21.pom
4/4 KB
Downloaded: http://repo.hortonworks.com/content/repositories/releases/org/apache/hcatalog/hcatalog-core/0.5.0.21/hcatalog-core-0.5.0.21.pom (4 KB at 28.4 KB/sec)
Downloading: http://repo.hortonworks.com/content/repositories/releases/org/apache/hcatalog/hcatalog/${hcatalog.version}/hcatalog-${hcatalog.version}.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/hcatalog/hcatalog/${hcatalog.version}/hcatalog-${hcatalog.version}.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.895 s
[INFO] Finished at: 2014-05-13T17:52:15-05:00
[INFO] Final Memory: 5M/12M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project MDM-Map-Reduce: Could not resolve dependencies for project com.cardinalhealth:MDM-Map-Reduce:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.apache.hcatalog:hcatalog-core:jar:0.5.0.21: Failed to read artifact descriptor for org.apache.hcatalog:hcatalog-core:jar:0.5.0.21: Could not transfer artifact org.apache.hcatalog:hcatalog:pom:${hcatalog.version} from/to hortonworks (http://repo.hortonworks.com/content/repositories/releases/): IllegalArgumentException: Illegal character in path at index 88: http://repo.hortonworks.com/content/repositories/releases/org/apache/hcatalog/hcatalog/${hcatalog.version}/hcatalog-${hcatalog.version}.pom -> [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
(I had to break the urls after http:// with a space for SO to allow me to post)
If you notice it seems like it is trying to pull the same dependency twice, I have no clue why it would do that, or why it would fail to resolve parameters correctly.
I have attached relevant files here, I am a complete Maven novice so I have included the directory layout (in list), the pom and the output of mvn clean install, both standard and extended (i.e. with -e for stack trace).
https://drive.google.com/folderview?id=0B_G2bKn27T9raFVoMkl0LUQyT28&usp=sharing
use pluginrepo instead repository
e.g.
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<url>http://repository.apache.org/snapshots/</url>
</pluginRepository>
</pluginRepositories>

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