I am trying to deploy the Maven build JAR to Github Package Registry.
I am getting exception when I execute mvn deploy command.
I am using a simple Maven project which I want to create a component JAR and store in Github Package Registry.
The build is successful I now want to deploy this artifact to registry.
I have added the below in ~./m2/settings.xml.
Added a repository element under repositories in profile.
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/swastikaa-in</url>
</repository>
<servers>
<server>
<id>github</id>
<username>swastikaa</username>
<password>my personal token from github</password>
</server>
</servers>
Also, I have added the below in Maven project's pom.xml:
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/swastikaa-in/math</url>
</repository>
</distributionManagement>
Expected:
Deployment to be successful , build artifact is deployed to Github package registry.
Actual:
Exception as below:
Caused by: org.eclipse.aether.transfer.MetadataTransferException:
Could not transfer metadata com.redjohn.tools:math:0.0.2-SNAPSHOT/maven-metadata.xml
from/to github (https://maven.pkg.github.com/swastikaa-in/math):
Failed to transfer file https://maven.pkg.github.com/swastikaa-in/math/com/redjohn/tools/math/0.0.2-SNAPSHOT/maven-metadata.xml
with status code 400
Caused by: org.apache.maven.wagon.TransferFailedException:
Failed to transfer file https://maven.pkg.github.com/swastikaa-in/math/com/redjohn/tools/math/0.0.2-SNAPSHOT/maven-metadata.xml
with status code 400
Can someone help me in resolving the issue.
I have followed the instructions provided in the below link:
https://help.github.com/en/articles/configuring-apache-maven-for-use-with-github-package-registry
I had the same problem and I found that snapshot versions don't work well. If you deploy a non snapshot version, it should work.
Inside your settings.xml file, <url>https://maven.pkg.github.com/OWNER/REPOSITORY</url> you need to make use that OWNER is replaced with your github username and REPOSITORY is replaced with the name of your project repository in github.
Related
I am trying to start my tests in an environment without an internet connection.
To do this, I need to save my dependencies in the project directory and specify Maven for this repository.
I copy repository folder from .m2 to project, write:
<repositories>
<repository>
<id>project-repository</id>
<url>file:${project.basedir}/repository</url>
<releases>
<checksumPolicy>ignore</checksumPolicy>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
and hoped that the maven would ignore the local m2 repository. But when I remove all the dependencies from m2, the maven still downloads them from the Internet. If i disconnected - the maven ignores the local repository and does not start.
Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: nodename nor servname provided, or not known
How can I tell the maven to work only from the internal repository? Without custom setting.xml, only on *.pom .
Maven is using the values from the settings.xml in {M2_HOME}\conf\settings.xml.
The issues here is that settings.xml allows you to override definitions in pom.xml, not the other way round. So you can override the tag <localRepository> in settings.xml, more on this here. Also This answer in another thread explains why.
The other option is to set the maven local repository on the command line:
mvn clean install -Dmaven.repo.local=repository
I am trying to upload a Maven artifact I haven't built to my Organization's GitHub package registry. I am using the deploy:deploy-file Maven plugin in order to do so. Here is the command I have been using:
mvn deploy:deploy-file
-Dfile=[THE JAR FILE]
-Durl=https://maven.pkg.github.com/[ORG]
-Dregistry=https://maven.pkg.github.com/[ORG]
-DgroupId=[GID]
-DartifactId=[ARTIFACTID]
-Dversion=[VERSION]
-DgeneratePom=false
-Dtoken=[MY GITHUB TOKEN]
As a result I am receiving 401 errors from Github.
I have made sure that:
I have sufficient permissions inside of my Organization (currently Owner).
The token i am using is valid and has the appropriated scopes: I put all of them on to test.
Also, the github package page states:
<!-- Just a single step: Deploy using a GitHub token -->
$ mvn deploy -Dregistry=https://maven.pkg.github.com/[org] -Dtoken=GH_TOKEN
Why can't I find any information in Maven documentation about registry or token parameters?
Can I upload this file to the organization's registry without any kind of XML configuration file, using only the cli?
Thanks in advance.
I had success with this:
mvn deploy:deploy-file -Dfile=./[JAR].jar
-DpomFile=./pom.xml
-DrepositoryId=github
-Durl=https://maven.pkg.github.com/[OWNER]/[REPO]
-Dtoken=GH_TOKEN
And a settings.xml in my maven home directory:
<settings>
<servers>
<server>
<id>github</id>
<username>[GITHUB USERNAME]</username>
<password>[GENERATED ACCESS TOKEN]</password>
</server>
</servers>
</settings>
And inside my POM:
...
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/[OWNER]/[REPO]</url>
</repository>
</distributionManagement>
...
To workaround the repo issue - since I didn't want each package to be published to a different repo, I created a repo named packages and published the packages from all the other repos to it, using the same config as in the other two answers.
Url should have a repository name as well.
In one of my projects I have this in pom.xml
<distributionManagement>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/stirante/lol-client-java-api</url>
</repository>
</distributionManagement>
I tried doing a mvn deploy for oss.jfrog.org for my project. However I am getting this error:
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://oss.jfrog.org/simple/oss-snapshot-local/com/myorg/mylibrary/com/myorg/mylibrary/0.0.1-SNAPSHOT/mylibrary-0.0
.1-20141211.050111-1.pom. Return code is: 409, ReasonPhrase: Conflict.
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:573)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:493)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:474)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:454)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:871)
... 28 more
When I look into the JFrog Repository Browser, I can see that the jar is there withe the correct version, what could be this error, and why is the jar deployed anyway even with this error?
Here's my POM setting:
<distributionManagement>
<repository>
<id>bintray-myorg-maven-mylibrary</id>
<name>artifactory-snapshots</name>
<url>http://oss.jfrog.org/simple/oss-snapshot-local/com/myorg/mylibrary/</url>
</repository>
</distributionManagement>
Could it be because of the bintray-* id?
simple shouldn't be a part of your URL.
Artifactory thinks that simple is the name of the repository and oss-snapshot-local is a part of your groupId. Since pom shows a different groupId, it fails with 409.
I'm having some issues to configure properly my eclipse to work with maven.
I create a new project, this one is correctly build with maven in command line (mvn install), but in Eclipse I got this error:
CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 (): ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-settings:jar:2.2.1: ArtifactResolutionException: Failure to transfer org.apache.maven:maven-settings:pom:2.2.1 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 artifact org.apache.maven:maven-settings:pom:2.2.1 from/to central : NullPointerException pom.xml /test line 9 Maven Project Build Lifecycle Mapping Problem
Here is my settings.xml conf :
<proxy>
<active>true</active>
<protocol>http</protocol>
<username>myuser</username>
<password>$mymdp</password>
<host>myhost</host>
<port>8080</port>
<nonProxyHosts>some.host.com</nonProxyHosts>
</proxy>
....
<repository>
<id>central</id>
<name>central repo m2</name>
<url>http://central.maven.org/maven2</url>
</repository>
I choose the correct maven installation (in Preference -> Maven -> Install)
I also direct my user settings on the correct settings.xml (Preferences -> Maven -> User Settings)
But I still got this error in Eclipse and everything goes well with maven command line. Do you have and idea?
You only need to delete one folder it is throwing error for. Just go to your M2 repo and org/apache/maven/plugins/maven-compiler-plugins and delete the folder 2.3.2
Have you tried to remove the proxy username and password? A similar poster encountered that issue:
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-jar-plugin:2.3.2 or one of its dependencies could not be resolved
Failing that I found the following worked:
Delete project in Eclipse (but do not delete the contents on disk)
Delete all files in your Maven repository
Re-download all Maven dependencies:
mvn dependency:resolve
Start up Eclipse
Ensure that Eclipse is configured to use your external Maven installation (Window->Preferences->Maven->Installations)
Re-import the existing project(s) into Eclipse
Ensure that there are no Maven Eclipse plugin errors on the final screen of the project import
I was getting this problem when using IBM RSA 9.6.1 when building a brand new development machine. The problem for me ended up being because of HTTPS on the Global Maven repository. My solution was to create a Maven settings.xml that forced it to use HTTP.
The key to me was that the central repository was empty when I exploded it under Maven Repositories -- > Global Repositories
Using the following settings file worked for me:
<settings>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>insecurecentral</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>insecurecentral</id>
<!--Override the repository (and pluginRepository) "central" from the Maven Super POM -->
<repositories>
<repository>
<id>central</id>
<url>http://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
I got the idea from this stackoverflow question.
The issue has been resolved while installation of the maven settings is provided as External in Eclipse. The navigation settings are Window --> Preferences --> Installations. Select the External as installation Type, provide the Installation home and name and click on Finish. Finally select this as default installations.
I accidentally turned on offline mode.
To disable it: in the Maven tool window, click The Toggle Offline Mode button.
I also got the same issue and not able to create a jar, and I found that in Windows-->Prefernces-->Java-->installed JREs By default JRE was added to the build path of newly
created java project so just changed it to your prefered JDK.
Find your Maven local repository, navigate to maven-compiler-plugin, delete the 3.8.1 folder, so that the Maven will redownload it again.
For example:
C:\Users\mkyong.m2\repository\org\apache\maven\plugins\maven-compiler-plugin
Problem deploying my jaudiotagger project since java.net moved from CollabNet to Project Kenai
I made the following changes to pom.xml
from
<repository><id>maven2-repository.dev.java.net</id>
to
<repository><id>maven2-repository.java.net</id>
from
<repository>
<uniqueVersion>false</uniqueVersion>
<id>java.net-maven2-repository</id>
<url>java-net:/maven2-repository/trunk/repository/</url>
</repository>
to
<repository>
<uniqueVersion>false</uniqueVersion>
<id>java.net-m2-repository</id>
<url>java-net:/maven2-repository-svn/trunk/repository/</url>
</repository>
and Wagon version from
<version>1.8</version>
to
<version>1.12</version>
When I run mvn deploy it just complains:
Error retrieving previous build number for artifacts 'org:jaudiotagger:jar' repository metadata for: 'snapshot org:jaudiotagger:2.0.4-SNAPSHOT' could not be retrieved from repository: java.net-m2-repository due to an error: Connection failed:Unable to connect to https://svn.java.net/svn/maven2-repository-svn/trunk/repository
What am I doing wrong
thanks Paul
They have discontinued hosting their own repository but failed to mention it to anyone
http://www.java.net/forum/topic/forum-help/project-moved-project-kenjai-unable-deply-maven-repository?force=216