I'm new to maven and i'm trying to use the following command :
mvn clean install -DskipTests=true
but i get the following error :
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:3.0.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:3.0.0: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:3.0.0 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty -> [Help 1]
I have absolutly no idea of what i'm missing. Here 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.sf.okapi</groupId>
<artifactId>build-okapi-superpom</artifactId>
<version>0.30-SNAPSHOT</version>
<relativePath>superpom/pom.xml</relativePath>
</parent>
<artifactId>build-okapi-root</artifactId>
<packaging>pom</packaging>
<name>Okapi Build Root</name>
<url>https://bitbucket.org/okapiframework/okapi</url>
<modules>
<module>superpom</module>
<module>okapi</module>
<module>okapi-ui/swt</module>
<module>applications</module>
</modules>
</project>
My maven version :
mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /root/apache-maven-3.3.9
Java version: 1.7.0_101, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "3.14.32-xxxx-grs-ipv6-64", arch: "amd64", family: "unix"
Related
Github Actions workflow for a private repository:
Within IntelliJ project OrionDAO is a facet of project Orion and so has to be run first.
Part of OrionDAO Pom follows:
<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>uk.co.xxxx.orionDAO</groupId>
<artifactId>orionDAO</artifactId>
<packaging>jar</packaging>
<name>Orion Model</name>
<description>Orion </description>
<version>25.1.3</version>
……….
<distributionManagement>
<repository>
<id>github</id>
<name>Apache Maven Packages</name>
<url>https://maven.pkg.github.com/xxxx/Orion_CICD</url>
</repository>
</distributionManagement>
</project>
Part of Orion Pom follows:
4.0.0
<groupId>uk.co.xxxx.orion</groupId>
<artifactId>orion</artifactId>
<version>25.1.3</version>
<packaging>war</packaging>
<name>Orion</name>
<description>Orion </description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>15</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<hapi-fhir-version>4.2.0</hapi-fhir-version>
</properties>
<dependencies>
<dependency>
<groupId>uk.co.xxxx.orionDAO</groupId>
<artifactId>orionDAO</artifactId>
<version>25.1.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
<finalName>orion</finalName>
</build>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub ReedInPartnership Apache Maven Packages</name>
<url>https://maven.pkg.github.com/xxxx/Orion_CICD</url>
</repository>
</distributionManagement>
This all works fine until the deploy step.
Then it just sits there.
I added permissions: step but still hangs.
# This workflow will trigger when a PR is closed and will put out a message
# dependant upon Orion being built and deployed to the Master branch
name: Master Workflow - PR message output and build and deploy
on:
pull_request:
types: closed
branches:
- master
permissions:
contents: read
packages: write
jobs:
merge_job:
# this job will only run if the PR has been merged
if: github.event.pull_request.merged == true
runs-on: windows-latest
steps:
- run: |
echo PR #${{ github.event.number }} has been merged
close_job:
# this job will only run if the PR has been closed without being merged
if: github.event.pull_request.merged == false
runs-on: windows-latest
steps:
- run: |
echo PR #${{ github.event.number }} has been closed without being merged
deploy_job:
# this job will only run if the PR has been merged i.e merge-job completed successfully
needs: merge_job
runs-on: windows-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 16 for now
uses: actions/setup-java#v2
with:
java-version: '16'
distribution: 'adopt'
- name: Set up Maven
uses: stCarolas/setup-maven#v4
with:
maven-version: 3.6.3
- name: Cache Maven packages
uses: actions/cache#v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: 'Create settings.xml'
uses: whelk-io/maven-settings-xml-action#v4
with:
repositories: '[{ "id": "github", "url": "https://maven.pkg.github.com/ReedInPartnership/Orion_CICD" }]'
servers: '[{"id": "github", "username": "${{ secrets.GITHUB_USERNAME }}", "password": "${{ secrets.GITHUB_PASSWORD }}"}]'
- name: Install Jespa
run: mvn install:install-file "-Dfile=Orion\jespa-1.2.6.jar" "-DgroupId=jespa" "-DartifactId=jespa" "-Dversion=1.2.6" "-Dpackaging=jar" "-DgeneratePom=true"
- name: Build with Maven (Orion DAO)
run: mvn -B install --file Orion_DAO/pom.xml
- name: Build with Maven (Orion)
run: mvn -B install --file Orion/pom.xml
- name: Publish to GitHub Packages Orion
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn --batch-mode --file Orion/pom.xml deploy
Output: Just hangs when uploading jar and pom to github
***** UPDATE *****
***** UPDATE *****
***** UPDATE *****
This was done with myself as the creator of the merge request and also as the the person merging it and I thought maybe this is why it is hanging. So I got someone else (the reviewer) to do the merge and now it is not hanging but I am getting the following error instead
Error: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project orion: Failed to deploy artifacts: Could not transfer artifact uk.co.reed.orion:orion:war:25.1.3 from/to github (https://maven.pkg.github.com/xxxx/Orion_CICD): Transfer failed for https://maven.pkg.github.com/xxxx/Orion_CICD/uk/co/reed/orion/orion/25.1.3/orion-25.1.3.war 401 Unauthorized -> [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/MojoExecutionException
Error: Process completed with exit code 1.
***** UPDATE2 *****
***** UPDATE2 *****
***** UPDATE2 *****
I have now gotten another reviewer with admin access to merge this and we are back to the workflow just hanging in the maven deploy step!!
In the end I created a release workflow and then it created the packages. It seems that packages are only created on a release event type although I couldn't find this mentioned in all the documentation I read.
# This workflow will build and publish to Github Packages on release
name: Master Workflow - Build and Publish to GitHub Packages
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout#v2
- uses: actions/setup-java#v2
with:
java-version: '16'
distribution: 'adopt'
- name: Install Jespa
run: mvn install:install-file "-Dfile=Orion\jespa-1.2.6.jar" "-DgroupId=jespa" "-DartifactId=jespa" "-Dversion=1.2.6" "-Dpackaging=jar" "-DgeneratePom=true"
- name: Build with Maven (Orion DAO)
run: mvn -B install --file Orion_DAO/pom.xml
- name: Build with Maven (Orion)
run: mvn -B install --file Orion/pom.xml
- name: Publish package
run: mvn --batch-mode --file Orion/pom.xml deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
You can add settings.xml to the project root folder same location as pom.xml
Then you can add steps like this:
- name: Build with Maven
env:
USENAME: ${{github.actor}}
PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B clean package --settings settings.xml
Content of the settings.xml :
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<servers>
<server>
<id>github</id>
<username>${env.USERNAME}</username>
<password>${env.PASSWORD}</password>
</server>
</servers>
</settings>
I have a Nexus 3 which I deploy some artifacts from Jenkins with "mvn deploy". I have A LOT of modules 500+. The build looks kind of like this:
mvn clean package -DskipTests -DskipITs -T C1
mvn install -DskipTests -DskipITs -T C1
mvn deploy --quiet -DskipTests -DskipITs -Dmaven.validate.skip=true -Dmaven.compile.skip=true -Dmaven.test.skip=true -Dmaven.package.skip=true -Dmaven.integration-test.skip=true -Dmaven.verify.skip=true -T C1
The problem is that from time to time my artifacts have a timestamp while the metadata has a different timestamp. 1 second difference usually.
This is what I see in nexus at https://mynexus.com/repository/snapshots/com/company/my-artifact/1.0.0-SNAPSHOT/maven-metadata.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
<groupId>com.company</groupId>
<artifactId>my-artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<versioning>
<snapshot>
<timestamp>20170613.140447</timestamp>
<buildNumber>1</buildNumber>
</snapshot>
<lastUpdated>20170613140447</lastUpdated>
<snapshotVersions>
<snapshotVersion>
<extension>war</extension>
<value>1.0.0-20170613.140447-1</value>
<updated>20170613140447</updated>
</snapshotVersion>
<snapshotVersion>
<extension>pom</extension>
<value>1.0.0-20170613.140447-1</value>
<updated>20170613140447</updated>
</snapshotVersion>
</snapshotVersions>
</versioning>
</metadata>
Judging the maven-metadata.xml, the artifact URL should be this:
https://mynexus.com/repository/snapshots/com/company/my-artifact/1.0.0-SNAPSHOT/my-artifact/1.0.0-20170613.140447-1.war
But it is not. Instead, the artifact is at this location:
https://mynexus.com/repository/snapshots/com/company/my-artifact/1.0.0-SNAPSHOT/my-artifact/1.0.0-20170613.140446-1.war
mvn --version
OpenJDK 64-Bit Server VM
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06+02:00)
Maven home: /usr/local/apache-maven
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-64-generic", arch: "amd64", family: "unix"
The version of maven-deploy-plugin is 2.8.2
What am I doing wrong? How can I fix this?
Thank you!
This is a bug in Maven 3.5.0 and and will be resolved whenever 3.5.1 is released.
The original bug-report targed the deploy-plugin (https://issues.apache.org/jira/browse/MDEPLOY-221) however it's an issue with maven core: https://issues.apache.org/jira/browse/MNG-6240.
We hit the same issue at my work and after some digging and searching on mavens issue tracker I found the above links. I would suggest downgrading while waiting for 3.5.1 to come out.
I am unable to build the project using Apache-maven 3.2.2 and As i am new to the maven i am not able to find the issue. Please provide some solutions to resolve it.
And the error as follows:
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR] Unresolveable build extension: Plugin
org.apache.maven.wagon:wagon-ftp:1.0-beta-2 or one of its dependencies could
not be resolved: Failed to read artifact descriptor for
org.apache.maven.wagon:wagon-ftp:jar:1.0-beta-2: Could not transfer artifact
org.apache.maven.wagon:wagon-ftp:pom:1.0-beta-2 from/to central
(http://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host
repo.maven.apache.org -> [Help 2]
and my maven version as follows:
C:\Users\xyz>mvn -version
Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T19:21:42+05:30)
Maven home: D:\software\Maven\apache-maven-3.2.2-bin\apache-maven-3.2.2
Java version: 1.7.0_01, vendor: Oracle Corporation
Java home: C:\Program Files (x86)\Java\jdk1.7.0_01\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows nt (unknown)", version: "6.2", arch: "x86", family: "windows"
The problem is with your maven path , you have to give bin as your maven path
In your pom.xml, try to find this dependency.
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-beta-2</version>
</dependency>
and you can change it with the following artifact;
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>2.10</version>
</dependency>
if it does not work, the problem is with your internet settings, as Tunaki said.
I create a simple maven project in eclipse(indigo), it reports an error:
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3
I found maven-resources-plugin:2.5 in local repo.
I don't understand why my project needs 2.4.3 but not 2.5?
mvn -v:
Apache Maven 3.0.4 (r1232337; 2012-01-17 16:44:56+0800)
Maven home: D:\Program Files\maven-3.0
Java version: 1.6.0_31, vendor: Sun Microsystems Inc.
Java home: D:\Program Files\Java\jdk1.6.0_31\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows xp", version: "5.1", arch: "x86", family: "windows"
I solved it,
just create src/main/java, src/main/resources, src/test/java, src/test/resources
The maven-resources-plugin will disappear.
I am getting a compilation error when try to execute mvn clean install.
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:
javac: invalid flag: -s
Usage: javac <options> <source files>
Java version is
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)
Maven version
Apache Maven 3.0.3 (r1075438; 2011-02-28 11:31:09-0600)
Maven home: C:\Sajith\apache-maven-3.0.3\apache-maven-3.0.3
Java version: 1.5.0_16, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.5.0_16\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows xp", version: "5.1", arch: "x86", family: "windows"
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.test.sample</groupId>
<artifactId>TestApp</artifactId>
<description>TestApp Release 1.0 Build</description>
<version>2.0</version>
<packaging>pom</packaging>
<name>TestApp API</name>
<url>http://maven.apache.org</url>
Any help would be appreciated.
The problem is that your maven is using java 5 (as your comment says). You have to change your JAVA_HOME variable to point to jdk 6 or higher. Look at :
Error when using javac: "javac: invalid flag: -s"
In my case i dont have the apropiate environment variable because the project is inherited, and I had not created the variable JDK_WAS85_JDK8 = C:\Program Files\Java\jdk1.8.0_221.
Usually is JAVA_HOME the variable that is set.