Wrong version of maven-archetype-plugin running "mvn archetype:generate" - maven

I created an archetype with maven, which includes archetype-post-generate.groovy, but it is not executed.
This is a fragment of the pom:
<properties>
<maven.archetype.version>3.2.0</maven.archetype.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>${maven.archetype.version}</version>
</plugin>
</plugins>
</pluginManagement>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>${maven.archetype.version}</version>
</extension>
</extensions>
</build>
However, the version of the plugin does not match the one defined in the pom:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) > generate-sources # standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) < generate-sources # standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:2.4:generate (default-cli) # standalone-pom ---
[INFO] Generating project in Interactive mode
Could that be the reason why it doesn't run the groovy script? Why does the version not match?
EDIT:
Complete POM with suggested changes:
<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>
<artifactId>bp-archetype-bcore</artifactId>
<groupId>global.base</groupId>
<version>1.0.0</version>
<packaging>maven-archetype</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>${maven.archetype.version}</version>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>${maven.archetype.version}</version>
</extension>
</extensions>
</build>
</project>

Declaring a plugin just in <pluginManagement> adds nothing to the build. This is just kind of a template which configuration should be used if the plugin is declared in this or a child POM's <build><plugins> section.
See POM Reference, Plugin Management:
pluginManagement: [...] However, this only configures plugins that are actually referenced within the plugins element in the children or in the current POM. [...]

Related

maven-dependency-plugin usage to download dependency jars

Hoping someone can explain how to set the plugin options correctly.
I am looking to have a pom file that someone could execute an mvn command on to download all the jars of the dependencies (transitive included) defined in the pom (including their sources and javadoc jars) from Maven Central and copy them to a specified directory.
My question appears quite similar to maven-dependency-plugin ignores outputDirectory configuration but dwells on a slightly different aspect. Tried the approach advised in the accepted answer there but that didn't work.
pom file:
<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>gq.jetstream</groupId>
<artifactId>maven-download-sources-javadocs</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<org.springframework.version>5.2.22.RELEASE</org.springframework.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
</dependencies>
<build>
<!-- <sourceDirectory>src</sourceDirectory> -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<classifier>sources</classifier>
<classifier>javadoc</classifier>
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
<includeClassifiers>sources,javadoc</includeClassifiers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Executing mvn package against this pom doesn't do anything. The output for the goal execution was empty.
Alt 1: Tried the following command. This copied the javadoc jars only and not the binary jars and sources jars of the dependencies.
mvn dependency:copy-dependencies#copy-dependencies
[INFO] Scanning for projects...
[INFO]
[INFO] ------------< gq.jetstream:maven-download-sources-javadocs >------------
[INFO] Building maven-download-sources-javadocs 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.3.0:copy-dependencies (copy-dependencies) # maven-download-sources-javadocs ---
[INFO] Copying spring-core-5.2.22.RELEASE-javadoc.jar to C:\projects\code\maven-download-sources-javadocs\target\dependency-jars\spring-core-5.2.22.RELEASE-javadoc.jar
[INFO] Copying spring-jcl-5.2.22.RELEASE-javadoc.jar to C:\projects\code\maven-download-sources-javadocs\target\dependency-jars\spring-jcl-5.2.22.RELEASE-javadoc.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.846 s
[INFO] Finished at: 2022-06-22T02:09:55+01:00
[INFO] ------------------------------------------------------------------------

Maven flatten plugin not working does not substitute my version property

For some reason when i do mvn install and check my local repo and look at the pom there, i don't see that the version variable was substituted with the value.
I am using a parent pom with a version in the properties
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
<revision>19.3.29</revision>
</properties>
It also contains the flatten plugin entry:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
The child pom uses the ${revision} as the value for the version & ${project.version} for dependencies as recommended by maven:
<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>
<artifactId>analysisModule</artifactId>
<version>${revision}</version>
<parent>
<groupId>com.mycompany.analysis</groupId>
<version>1.0.0</version>
<artifactId>autoav</artifactId>
<relativePath>../autoAV</relativePath>
</parent>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>com.mycompany.analysis</groupId>
<artifactId>analysisCore</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Looking at the local repo pom xml after I 'mvn install' :
<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>
<artifactId>analysisJdbc</artifactId>
<version>${revision}</version>
<description>analysis of jdbc sources</description>
<parent>
<groupId>com.mycompany.analysis</groupId>
<version>1.0.0</version>
<artifactId>autoav</artifactId>
<relativePath>../autoAV</relativePath>
</parent>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>com.mycompany.analysis</groupId>
<artifactId>analysisCore</artifactId>
<version>${project.version}</version>
</dependency>
...
</project>
Shouldn't the ${revision} & ${project.version} been replaced with the actual numbers ?
Isn't that the whole thing about using flatten plugin ?
I followed this
https://www.mojohaus.org/flatten-maven-plugin/examples/example-central-version.html
Adding my output of mvn install (skipping tests) (maven version 3.3.9):
02:12:03 :/code/thedrs/gitrepos/analysis/analysis/analysisJdbc (main) $ mvn install -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building analysisJdbc 19.3.30
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # analysisJdbc ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # analysisJdbc ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # analysisJdbc ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # analysisJdbc ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # analysisJdbc ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # analysisJdbc ---
[INFO] Building jar: /code/thedrs/gitrepos/analysis/analysis/analysisJdbc/target/analysisJdbc-19.3.30.jar
[INFO] META-INF/maven/com.mycompany.analysis/analysisJdbc/pom.xml already added, skipping
[INFO] META-INF/maven/com.mycompany.analysis/analysisJdbc/pom.properties already added, skipping
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # analysisJdbc ---
[INFO] Installing /code/thedrs/gitrepos/analysis/analysis/analysisJdbc/target/analysisJdbc-19.3.30.jar to /code/thedrs/.m2/com/mycompany/analysis/analysisJdbc/19.3.30/analysisJdbc-19.3.30.jar
[INFO] Installing /code/thedrs/gitrepos/analysis/analysis/analysisJdbc/pom.xml to /code/thedrs/.m2/com/mycompany/analysis/analysisJdbc/19.3.30/analysisJdbc-19.3.30.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.147 s
[INFO] Finished at: 2020-05-06T02:12:40-07:00
[INFO] Final Memory: 14M/356M
[INFO] ------------------------------------------------------------------------
You need to move the plugin from <pluginManagement><plugins> to <plugins>. Alternatively, you can leave it there and just add a short plugin definition (including groupId and artifactId) to the <plugins> section.
<pluginManagement> is just to preconfigure version numbers and configuration. Plugins in <pluginManagement> are not run during the build unless they reappear in <plugins>.
I've been able to achieve that by creating another property for the dependencies. This property will have the same value as ${revision} and will be replaced in the generated pom file.
<properties>
<revision>19.3.29</revision>
<my-lib.version>${revision}</my-lib.version>
</properties>
Then instead of using ${project.version} in your dependencies, use your property:
<dependency>
<groupId>com.mycompany.analysis</groupId>
<artifactId>analysisCore</artifactId>
<version>${my-lib.version}</version>
</dependency>

Maven ignoring plugin version from pluginManagement in profile of submodule

I'm defining plugin versions in the <pluginManagement> section of a parent POM and want to use them in the <plugins> section of submodules.
This is working, unless the plugin is being used inside a profile of a submodule. In this case, the version from the parent POM's <pluginManagement> section is ignored.
Output of mvn -v:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_102, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
./pom.xml:
<?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>
<prerequisites>
<maven>3.1.0</maven>
</prerequisites>
<modules>
<module>project1</module>
</modules>
<groupId>org.example.test</groupId>
<artifactId>test-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
./project1/pom.xml:
<?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>
<prerequisites>
<maven>3.1.0</maven>
</prerequisites>
<parent>
<groupId>org.example.test</groupId>
<artifactId>test-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>project1</artifactId>
<profiles>
<profile>
<id>p1</id>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Output of mvn versions:display-plugin-updates:
$ mvn versions:display-plugin-updates
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] test-parent
[INFO] project1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test-parent 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.2:display-plugin-updates (default-cli) # test-parent ---
[INFO]
[INFO] All plugins with a version specified are using the latest versions.
[INFO]
[INFO] Project defines minimum Maven version as: 3.1.0
[INFO] Plugins require minimum Maven version of: 3.1.0
[INFO] Note: the super-pom from Maven 3.3.9 defines some of the plugin
[INFO] versions and may be influencing the plugins required minimum Maven
[INFO] version.
[INFO]
[INFO] No plugins require a newer version of Maven than specified by the pom.
[INFO]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building project1 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.2:display-plugin-updates (default-cli) # project1 ---
[INFO]
[INFO] All plugins with a version specified are using the latest versions.
[INFO]
[WARNING] The following plugins do not have their version specified:
[WARNING] com.github.eirslett:frontend-maven-plugin ................. 0.0.26
[INFO]
[INFO] Project defines minimum Maven version as: 3.1.0
[INFO] Plugins require minimum Maven version of: 3.1.0
[INFO] Note: the super-pom from Maven 3.3.9 defines some of the plugin
[INFO] versions and may be influencing the plugins required minimum Maven
[INFO] version.
[INFO]
[INFO] No plugins require a newer version of Maven than specified by the pom.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] test-parent ........................................ SUCCESS [ 0.851 s]
[INFO] project1 ........................................... SUCCESS [ 0.314 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.649 s
[INFO] Finished at: 2016-09-16T16:03:04+02:00
[INFO] Final Memory: 13M/247M
[INFO] ------------------------------------------------------------------------
I can duplicate the information from the <pluginManagement> section of the parent POM inside the submodules to make it work, but I want to avoid this for obvious reasons.
Maven is not ignoring it, you can check it by executing the following:
mvn -pl project1 help:effective-pom -Doutput=noProfilePom.xml
The effective-pom goal will:
Displays the effective POM as an XML for this build, with the active profiles factored in.
Checking the noProfilePom.xml generated, you will see what effectively Maven will run when building the pom.xml of the project1 module.
There we can see:
<pluginManagement>
<plugins>
...
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
...
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
Hence, the pluginManagement has been merged properly (taken from the parent), while the plugins section doesn't provide it.
But running the following:
mvn -pl project1 -Pp1 help:effective-pom -Doutput=withProfilePom.xml
Note: we are also activating the profile via -Pp1 as part of the goal execution.
As part of the generated withProfilePom.xml will have:
<pluginManagement>
<plugins>
...
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.0</version>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
This time the p1 profile was active and its has properly injected into the plugins section its plugin declaration, taking then its version from the pluginManagement of the parent.
Hence: the pluginManagement section is not ignored by plugins declared in a profile.

Why is PMD OK from command line, but does not work from within Maven?

After many years of successful use of PMD with Ant, I am now trying without success to get PMD to work from within Maven.
To illustrate my problem, I have created a simple Maven system (based upon the Maven tutorial "my-app" hello world program). It differs only in the inclusion of a line of code which should trigger a PMD error using the basic ruleset:
Boolean bar = new Boolean("true");
When I run PMD from the command line, the problem in the code is revealed:
run.sh pmd -d src/main/java -f text -R rulesets/java/basic.xml -language java
maven-pmd-example/src/main/java/com/mycompany/app/App.java:11 Avoid instantiating Boolean objects; reference Boolean.TRUE or Boolean.FALSE or call Boolean.valueOf() instead.
However, when I run pmd from within Maven, the problem in the code is not revealed:
-> mvn pmd:check
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-pmd-plugin:2.7.1:check (default-cli) # my-app >>>
[INFO]
[INFO] --- maven-pmd-plugin:2.7.1:pmd (pmd) # my-app ---
[WARNING] Unable to locate Source XRef to link to - DISABLED
[INFO]
[INFO] <<< maven-pmd-plugin:2.7.1:check (default-cli) # my-app <<<
[INFO]
[INFO] --- maven-pmd-plugin:2.7.1:check (default-cli) # my-app ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.375s
[INFO] Finished at: Sun Feb 03 15:38:02 HST 2013
[INFO] Final Memory: 12M/309M
[INFO] ------------------------------------------------------------------------
Here is the 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.7.1</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<minimumPriority>0</minimumPriority>
<rulesets>
<ruleset>rulesets/basic.xml</ruleset>
</rulesets>
<targetJdk>1.6</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</build>
</project>
I have uploaded this example system to GitHub so you can see the entire example system (and download/play with it if you would like):
https://github.com/philipmjohnson/maven-pmd-example
It's because you have set the minimumPriority to 0, which will effectively prevent PMD from evaluating any rules at all (refer to this SO question for a discussion on priority).
Please refer to this section of the goal documentation for the PMD plugin for more information.
I'd suggest modifying the configuration to set the minimumPriority to 2 so that you can fail the build for BooleanInstantiation.
Hope this helps!

Fail of org.apache.maven.plugins goal execution

I'm trying to generate a war file using maven but i'm getting this error (most of downloading log output is omitted to make log more clear):
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-war-plugin/2.1.1/maven-war-plugin-2.1.1.pom
Downloaded:
...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building tn.talan.selenium Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # tn.talan.selenium ---
...
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # tn.talan.selenium ---
...
[INFO] --- maven-war-plugin:2.1.1:war (default-cli) # tn.talan.selenium ---
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-archiver/2.4.1/maven-archiver-2.4.1.pom
Downloaded:
...
[INFO] BUILD FAILURE
...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-cli) on project tn.talan.selenium: Execution default-cli of goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war failed: Plugin org.apache.maven.plugins:maven-war-plugin:2.1.1 or one of its dependencies could not be resolved: Could not transfer artifact org.codehaus.plexus:plexus-io:jar:1.0.1 from/to central (http://repo.maven.apache.org/maven2): GET request of: org/codehaus/plexus/plexus-io/1.0.1/plexus-io-1.0.1.jar from central failed: Read timed out -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
...
Here's my pom.xml file code:
<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>selenium</groupId>
<artifactId>tn.talan.selenium</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>tn.talan.selenium Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>tn.talan.selenium</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.0-beta-1</version>
</plugin>
</plugins>
</build>
</project>
What's wrong with my pom? Any idea please?
Specify version for maven-war-plugin, e.g.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
For solving this error, you don't need to do anything, just change your jdk version. You can prefer any jdk version but don't prefer latest one.Try to use older version. Recommended : JDK 11.0.11

Resources