I had to migrate from a older Nexus server to Nexus OSS v2.0.4 today. I have been facing strange issues from the morning. Firstly I installed nexus and started it, and I was able to browse it from the server machine only once and then no more. But later from all other machines in the network I could access the server (using http://remote.hostname:8081/nexus ).
Then I copied all the contents of the storage directory from the old server machine and pasted them one by one into the new machine. (For every repository, created a repository in the new server and gave the local storage Location as the directory which i copied from the old server). Now I am able to see all the jars which I had, but when I try to use them from maven, I am not able to do so. Meaning, if i try to run a maven project, then it says dependencies not found. I can see that it is looking for jar exactly in the place where it lies in the new server, but fails to download it. Any idea why it is not able to download the jars?
Also I am still not able to access the new nexus server from the server machine's browser, why is it so? Any suggestions will be appreciated. Thanks.
====UPDATE====
When I fiddled around with maven, I found that I am able to access the dependencies from public repository, but not from one specific repository (only one so far I am aware of). Can this be because of some reason? I suspect some wrong matter of migration, is it the proper way of migrating from one server to another?
Also, all the proxy repositories are having the status as In service-Remote automatically blocked and unavailable. Is this related to my problem somehow?
===Settings.xml===
<settings>
<localRepository>${env.TEST_HOME}\maven.repository</localRepository>
<proxies>
<proxy>
<id>Compproxy</id>
<active>true</active>
<protocol>http</protocol>
<username></username>
<password></password>
<host>proxy.abc.com</host>
<port>81</port>
<nonProxyHosts>*.abc.com|rick*</nonProxyHosts>
</proxy>
</proxies>
<servers>
<server>
<id>MyRep</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>central mirror</id>
<url>http://rick1.abc.com:8081/nexus/content/groups/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>opensymphony mirror</id>
<url>http://rick1.abc.com:8081/nexus/content/groups/public</url>
<mirrorOf>opensymphony</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>actProf</id>
<repositories>
<repository>
<id>public</id>
<url>http://rick1:8081/nexus/content/groups/public</url>
</repository>
<repository>
<id>MyRep</id>
<url>http://rick1:8081/nexus/content/repositories/MyRep</url>
</repository>
</repositories>
<properties>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>actProf</activeProfile>
</activeProfiles>
</settings>
===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.abc.test</groupId>
<artifactId>testgui_start</artifactId>
<packaging>pom</packaging>
<version>1</version>
<name>Start POM Test GUI</name>
<url>www.abc.com</url>
<build>
<plugins>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.abc.test</groupId>
<artifactId>testgui</artifactId>
<version>${version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
One thing you will have to do is add all the repositories you create to the public group so they become available to Maven, provided you are using the standard settings.xml that just references the public group.
Further more I would stop and restart the server and have a close look at the log and report back with more info. It might be set up to listen on specific ports and such. Also keep in mind that the startup scripts changed when we moved to 2.0 so you will have to replace the old ones that you put e.g. in /etc/init.d/.
Related
I'm trying to use Github's new Actions CI server to deploy packages to Github's new packages feature. It's not going well.
I think it's all set up correctly, but I get this error:
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
(default-deploy) on project myproject: Failed to deploy artifacts: Could not
find artifact com.mycompany:myproject:pom:1.5 in github
(https://maven.pkg.github.com/mycompany/mycompany_repository) -> [Help 1]
This happens after it appears to upload that same pom successfully:
Uploading to github: https://maven.pkg.github.com/mycompany/mycompany_repository
/com/mycompany/myproject/1.5/myproject-1.5.pom
Progress (1): myproject-1.5.pom (4.1/6.1 kB)
Progress (1): myproject-1.5.pom (6.1 kB)
So, it looks to me like it is successfully uploading the pom, but then it fails to download the same pom a few seconds later.
I'm running the deploy with debug switches on: mvn -X -e deploy, but I can't see the exact http commands that Maven is sending to the server.
How do I debug this? Is there some Maven/Aether transport or something that will log what is going on under the covers?
In case anyone else lands here looking for a solution to OPs issue publishing to github, I had a similar issue and found that the URLs needed in settings.xml and pom.xml are inconsistent. In your settings.xml, the repo URL needs to be of the form https://maven.pkg.github.com/myuser/com/mycompany/mypackage, whereas in your project's pom file, it needs to be of the form https://maven.pkg.github.com/myuser/mypackage. So, for example, your settings.xml file in ~/.m2 would look something like this:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub Apache Maven Packages</name>
<url>https://maven.pkg.github.com/myuser/com/mycompany/mypackage</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>myuser</username>
<password>mypersonalaccesstoken</password>
</server>
</servers>
</settings>
Whereas the pom.xml file in the root of your project would need to look like this:
<project>
...
<groupId>org.mycompany</groupId>
<artifactId>mypackage</artifactId>
<version>1.0.0</version>
...
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Apache Maven Packages</name>
<url>https://maven.pkg.github.com/myuser/mypackage</url>
</repository>
</distributionManagement>
...
</project>
Other than this minor (but crucial) detail, my steps were the same as those outlined here. This allowed me to publish my Maven package to github package registry.
You can enable debug logging in the workflows.
Just add the secret:
ACTIONS_RUNNER_DEBUG
And set to true
See a similar answer here
I just spend 3 hours debugging why the guide on the page did not work for me. If you are following the guide posted here 1.
OWNER is your github username, and REPOSITORY is - you guessed it, the repo name.
Just remember to use lowercase in both OWNER and REPOSITORY.
When generating the personal access token, make sure the scopes for the token are the repo:* scopes as well as the more obvious write:packages and read:packages scopes (do not disable the repo scopes)
Otherwise it does just that
The following solution works for me:
Create a repository for packages e.g. maven-packages
Add <server></server> settings under <servers> in settings.xml: (do this per id used below)
<server>
<id>github</id>
<username>YOUR GITHUB USERNAME</username>
<password>A GITHUB TOKEN YOU CREATE FOR PUBLISHING PACKAGES</password>
</server>
Do NOT add <activeProfiles>, <profile> or <repositories> to settings.xml (only add <server> elements) as this is redundant for publishing and I am adding them to consuming projects' maven.xml so no need for duplication.
Add repository/ies to distributionManagement in pom.xml as follows:
<distributionManagement>
<snapshotRepository>
<id>github-snapshot</id>
<name>GitHub snapshot</name>
<url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
<uniqueVersion>true</uniqueVersion>
</snapshotRepository>
<repository>
<id>github-release</id>
<name>GitHub release</name>
<url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
<uniqueVersion>false</uniqueVersion>
</repository>
</distributionManagement>
Where OWNER is the GitHub account your project is / projects are under and maven-packages is the repositories you want to publish you project(s) to.
This enables using a dedicated repository for listing packages instead of publishing each project's package to a different (its own) repository, making consumption of multiple packages from your GitHub account easier, as you only need to configure a single repository for these packages:
<repositories>
<repository>
<id>github</id>
<name>GitHub</name>
<url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
</repository>
</repositories>
Note: in the <servers> section of your settings.xml define a <server> per id used in repositories and distributionManagement e.g. github-snapshot, github-release, github in the above examples.
I am trying to upload artifacts to my "maven-central" repository in Nexus. I am using the command:
curl -v --user admin:admin123 --upload-file /path/myjar.jar http://nexus-nexus3.apps.lab.ca/repository/maven-central/com/tp/mycompany/1.0/myjar.jar
I am getting the error:
User-Agent: curl/7.54.0
Accept: /
Content-Length: 560414
Expect: 100-continue
HTTP/1.1 400 Invalid path for a Maven 2 repository
Date: Fri, 09 Mar 2018 15:54:10 GMT
Server: Nexus/3.9.0-01 (OSS)
I've tried multiple curl commands from the sonatype docs but to no avail. My question is, is this even possible? The UI only gives me the option to upload to maven-releases and nuget-hosted. How do I get around this?
I am not sure if you really want to upload a proprietary jars to the open world through maven-central.
It is very common to specify and use a combination of maven-central and company specific repository hosting proprietary jars. You should be careful about the impact of this.
Coming to uploading an artifact on maven-central...
To upload your artifacts into central-maven, there are pre-requisite given here
Why Do We Have Requirements?
In order to ensure a minimum level of quality of the components available in the Central Repository, we have established a number of requirements your deployment components have to meet. This allows your users to find all the relevant details about the components from the metadata provided in the Central Repository.
Some of the points taken:
Supply Javadoc and Sources
Sign Files with GPG/PGP
Project Name, Description and URL
License Information
Developer Information
SCM Information
Complete Example POM
The following complete example shows the XML header and required elements of project and modelVersion as well as example elements and content.
<?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>com.simpligility.training</groupId>
<artifactId>ossrh-demo</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>ossrh-demo</name>
<description>A demo for deployment to the Central Repository via OSSRH</description>
<url>http://github.com/simpligility/ossrh-demo</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<name>Manfred Moser</name>
<email>manfred#sonatype.com</email>
<organization>Sonatype</organization>
<organizationUrl>http://www.sonatype.com</organizationUrl>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/simpligility/ossrh-demo.git</connection>
<developerConnection>scm:git:ssh://github.com:simpligility/ossrh-demo.git</developerConnection>
<url>http://github.com/simpligility/ossrh-demo/tree/master</url>
</scm>
...
</project>
I assume that by default the repository you are calling maven-central is a proxy repository which is mirroring Maven Central. And it does not make sense to upload into a proxy repository. You should upload your artifacts to a other repository for example maven-releases which is a so called hosted repository...
You can't upload artifacts to a proxy repository that's written in the Nexus docs. Create a separate hosted repository in Nexus (by default there are already some defined 3rd party for example) and upload them into that...
You need to handle your Nexus configuration correct which you obviously didn't. You have repository group which combines the different repositories to a logical one which you use to access (consume) artifacts.
To correctly access the nexus group you should have a settings which looks like the following. The given URL is the URL of the repository group which is configured in Nexus to consume the artifacts.
The distributionManagement in Maven should be configured to use two separate repos whereas one is the release repository and the other one the SNAPSHOT repository.
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
I am experiencing issues pulling in a new version of a library which lives in a different repository. I believe I have to update my settings.xml and my parent level pom.xml which specifies the new version.
Currently my settings.xml reads like the following:
<settings>
<mirrors>
<mirror>
<id>nexus</id>
<url>http://serenity.gm.edu/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>mods</id>
<url>http://7.169.72.8:8081/nexus/content/repositories/releases/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<id>mod-thirdparty</id>
<url>http://7.169.72.8:8081/nexus/content/repositories/thridparty/</url>
</repository>
<repository>
<id>mod-snapshots</id>
<url>http://7.169.72.8:8081/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>Tomcat</id>
<username>admin</username>
<password>xxx</password>
</server>
</servers>
The default mirror where everything gets pulled in from is serenity. I am trying to pull in a custom library mod3.2 from 7.169.72.8 but version 2.3 keeps getting pulled in from serenity. I have tried a number of <mirrorOf> settings such as *,!central with no success.
My parent pom.xml is fairly straightforward defining a list of modules, proerties, and global dependencies. Here are the items of interest (it is too long to show).
<project ...>
...
<distributionManagement>
<repository>
<id>releases</id>
<name>mod2-releases</name>
<url>http://7.169.72.8:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>mod2-snapshots</name>
<url>http://7.169.72.8:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<properties>
...
<mod2.version>3.2</mod2.version>
...
</properties>
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>mod2.commons</groupId>
<artifactId>mod2.commons.lang</groupId>
<version>${mod2.version}</version>
</dependency>
<dependency>
<groupId>mod2.commons</groupId>
<artifactId>mod2.commons.audit</groupId>
<version>${mod2.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
To recap - I'm trying to get version mod2 version 3.2 from 7.169.72.8 but all I can pull in mod2 version 2.3 from the serenity repo. Thanks for any help.
In your configuration, you are declaring multiple mirrors for the Central repository. However, Maven does not support that:
Note that there can be at most one mirror for a given repository. In other words, you cannot map a single repository to a group of mirrors that all define the same value. Maven will not aggregate the mirrors but simply picks the first match. If you want to provide a combined view of several repositories, use a repository manager instead.
In your case, Maven is picking the first mirror of Central, which is of id nexus, and ignoring the second one, which is of id mods. Therefore, when fetching for your artifact, it only searches nexus and fails to find it.
There are a couple of solutions:
If you really want to have multiple mirrors for the same repository, you will need to use a repository manager and configure this on the repo manager itself.
It's not clear why you need to mirror Central and point to 7.169.72.8:8081 if this repository doesn't have all the artifacts needed to make your build work. If the rest are hosted on serenity.gm.edu, you could host all of them on serenity.gm.edu.
You could also not use the mods mirror at all. Let serenity.gm.edu be the mirror for Central and just declare a new repository that isn't Central to fetch your artifacts. You already declared the mod-thirdparty and mod-snapshots repositories, so this is a matter of activating the profile they are under with:
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
in the settings.xml. With this, Maven will also look for your artifacts at the URL configured for those repo (and those are not mirrored by nexus).
I've run into a situation where configuring Nexus as a Mirror for everything doesn't quite suit my needs. My Nexus repository is behind a VPN. If I can't access the Nexus repository, I can't build anything because it's configured as a Mirror. What if I want to build a project that has no dependencies on my Nexus repository yet I can't access it? This would build fine by simply using the Central repository but it won't look there because of the Mirror.
Does anyone have any ideas on how to get around this? I think ideally I'd like to look at Nexus first but if it's not accessible I'd like to look at the Central repository. I'm also open to any other suggestions for achieving the same goal that anyone may have.
you need to configure multiple repositories
http://maven.apache.org/guides/mini/guide-multiple-repositories.html
maven-3.0.4\conf\settings.xml file could be configured this way:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups />
<proxies />
<servers>
<server>
<!-- local repository have restricted access -->
<id>central</id>
<username>myusername</username>
<password>mypassword</password>
</server>
<server>
<id>LocalRepository</id>
<username>myusername</username>
<password>mypassword</password>
</server>
</servers>
<mirrors>
<mirror>
<id>central</id>
<mirrorOf>external:*</mirrorOf>
<name>Central</name>
<url>url to repository</url>
</mirror>
<mirror>
<id>LocalRepository</id>
<mirrorOf>LocalRepository</mirrorOf>
<name>repository</name>
<url>url to repository</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>central</id>
<repositories>
<repository>
<id>central</id>
<name>Central</name>
<url>http://central/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>LocalRepository</id>
<name>specific repository</name>
<url>repository URL</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>central</activeProfile>
</activeProfiles>
</settings>
The best approach for this kind of requirement is to run Nexus locally on your development machine.
Its easy to install and run and you can just always point to it.
Configure it to proxy your corporate Nexus and Central.
Then when you are off the VPN .. the corporate proxy repo will just be unreachable but you still get anything else just fine. Nexus manages it all for you.
I have been doing this for years and it allows me to switch to different contexts all the time very easily. It is a bit of a standard practice for many Maven users in fact and should be for other tools that use remote repositories like Gradle or SBT as well. Makes things a LOT easier.
How can I deploy a .jar to a network path? I'm looking at maven-deploy-plugin and other examples and keep finding things about deploying to tomcat, glassfish and ftp. My needs are simpler. I only need to deploy to a network path.
Bonus: After running a network path, is it possible to run console commands on an external windows command prompt?
The maven-deploy-plugin is intended to deploy an artifact to a repository which means usually to a repository manager (Artifactory, Nexus, Archiva etc.). The things you are talking about can be handled by the tomcat6- or tomcat7-maven-plugin which support the things you need. Other containers like Glassfish can be handled by cargo2-maven-plugin. I'm not aware of a up-to-date glassfish-maven-plugin only this one maven-glassfish-plugin which looks out of date (Take a look here).
If you like making deployments via ftp you can use the following configuration for the maven-deploy-plugin:
<project>
...
<distributionManagement>
<repository>
<id>ftp-repository</id>
<url>ftp://repository.mycompany.com/repository</url>
</repository>
</distributionManagement>
<build>
<extensions>
<!-- Enabling the use of FTP -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-beta-6</version>
</extension>
</extensions>
</build>
...
</project>
<settings>
...
<servers>
<server>
<id>ftp-repository</id>
<username>user</username>
<password>pass</password>
</server>
</servers>
...
</settings>
But this is in contradiction to the idea of Maven.
You can try to use the deploy-file goal of the maven-deploy-plugin to see if this would be option to deploy to a network path. I'm not sure if this will work.