How to upload maven plugin to Nexus repository? - plugins

I want to upload my custom maven plugin to nexus repository.
My problem is that when I upload my plugin to nexus via web IU like ordinary dependency, maven can't find it:
Plugin com.huawei:maven-project-version-plugin:1.0 or one of its
dependencies could not be resolved: Failed to read artifact descriptor
for com.huawei:maven-project-version-plugin:jar:1.0: Failure to find
com.mycompany:maven-project-version-plugin:pom:1.0 in
http://localhost:8081/nexus/content/groups/public was cached in the
local repository, resolution will not be reattempted until the update
interval of nexus has elapsed or updates are forced -> [Help 1]
But when I am install my plugin to maven local repositiry (not nexus) via command line all is fine.
So, what is the difference between installing custom maven plugin and installing "non plugin" artefacts? Are there any tricks?
My settings.xml:
<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">
<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>

The problem was solved. Well, I don't know how, but today all is work. I think the problem was in Nexus cache. I just deleted my hosted repository and created it again. Perhaps, there are less radical methods, but I don't know them =) Delete artifact and then just "expire cache" not help in my case.
Well, the answer of my question: There is no any different between installation plugin and non plugin artifact in Nexus, except one. If you select GAV Definition: GAV parameters, you must select "maven-plugin" in combobox "Packaging".
I think there is no need to write step by step instruction, it is very simple. Just select your hosted repository -> Artifact Upload tab and fill required fields.

Also to add that you must also upload the pom of your Maven plugin. If you don't Nexus will auto generate one which is not correct. i.e. it will just be a basic pom consisting of version, artifactID, packaging, and groupID.

Related

How to cache artifact from a public repository(e.g., Maven Central) to a private-owned nexus repository?

Basically, I am asking the same thing as the question linked here.
However, I don't think the picked answer solved the question. In addition, the former one was asked years ago.
The Nexus OSS version I installed is 2.11.2-06(the latest version).
I CAN cache an artifact if I search with the nexus GUI and click download button.
However, an artifact IS NOT cached if I declare it in the pom file in eclipse. It will just fetch it from MAVEN CENTRAL and cache it locally in my computer but not in the Nexus Repository.
I WISH when I declare a dependency in the POM file in eclipse, if it is not cached locally, maven will fetch it from MAVEN CENTRAL, cache it both locally in my computer AND in the Nexus Repository as well.
My maven settings.xml is shown below:
<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">
<profiles>
<profile>
<id>kingstar-internal</id>
<repositories>
<repository>
<id>kingstar-internal-repository</id>
<name>Kingstar Internal Repository</name>
<url>http://localhost:8081/nexus/content/repositories/KingstarRepository</url>
</repository>
<repository>
<id>kingstar-snapshot-repository</id>
<name>Kingstar Snapshot Repository</name>
<url>http://localhost:8081/nexus/content/repositories/KingstarSnapshotRepository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<mirrors>
<mirror>
<id>public-mirror</id>
<mirrorOf>*</mirrorOf>
<name>public mirror</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<activeProfiles>
<activeProfile>kingstar-internal</activeProfile>
</activeProfiles>
<servers>
<server>
<id>kingstar-internal-repository</id>
<username>deployment</username>
<password>deployment</password>
</server>
<server>
<id>kingstar-snapshot-repository</id>
<username>deployment</username>
<password>deployment</password>
</server>
</servers>
</settings>
Any help is appreciated!

Maven Dependencies Location

I'm using Eclipse Luna and having trouble with a imported third party Maven project. In Maven Dependencies the project has several jars, but the project is insisting they are to be found in C:\Users\username.m2\repository when they're not.
How do I tell it they are not there but in E:\java\jars?
I tried changing Native Library Locations but that didn't work, and there is nothing in the pom file that says which folder location to use. All attempts to get the classpath to work have failed (probably due to my newness to this environment).
You can include your resource in your pom.xml as follows:
<project>
<build>
<resources>
<resource>
<directory>[your folder here]</directory>
</resource>
</resources>
</build>
</project>
Alternatively, you can add your 3rd Party JARs as a repository, like so:
<repositories>
<repository>
<id>lib_id</id>
<url>file://your_path_to_lib/lib</url>
</repository>
</repositories>
Resources:
Specifying resource directories.
Guides to installing 3rd Party JARs.
Introduction to Repository.
Related SO Question.

I integrated maven in eclipse . then i imported a existing maven project using import wizard. i got the following error please help me out

Project build error: Non-resolvable parent POM for org.alfresco.maven:alfresco-sdk-parent:1.1.1: Failure to transfer org.alfresco.maven:alfresco-lifecycle-aggregator:pom:1.1.1 from https://artifacts.alfresco.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of alfresco-public has elapsed or updates are forced. Original error: Could not transfer artifact org.alfresco.maven:alfresco-lifecycle-aggregator:pom:1.1.1 from/to alfresco-public (https://artifacts.alfresco.com/nexus/content/groups/public): No response received after 60000here
error point first line of the code which is
File Name Pom.xml
I am using Eclipse Kepler
//Eclipse shows error in first line
<?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>fosspro</groupId>
<artifactId>fosspro_aid</artifactId>
<version>1.0-SNAPSHOT</version>
<name>fosspro_aid AMP project</name>
<packaging>amp</packaging>
<description>Manages the lifecycle of the fosspro_aid AMP (Alfresco Module Package)</description>
<parent>
<groupId>org.alfresco.maven</groupId>
<artifactId>alfresco-sdk-parent</artifactId>
<version>1.1.1</version>
</parent>
Please Help me Out
You may need to add the repository in your pom (inside project)...
<repositories>
<repository>
<id>alfresco-public</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</repository>
<!-- You may not need the snapshots? -->
<repository>
<id>alfresco-public-snapshots</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
</repository>
</repositories>
...or if you prefer, in the settings.xml of your Maven configuration.
I assume that the issue is as follow: the repository address is defined in the pom of the SDK, but in order to access the pom of the SDK, Eclipse needs to know the address of the repository.
Maven fails to access https://artifacts.alfresco.com/nexus/content/groups/public/, so it's not an issue with your setup it seems that there are issues connecting to Alfresco's Nexus to fetch the dependencies.
It seems unresponsive for me at this very minute, try again in a few minutes.

m2eclipse not showing latest artifacts in search

I am using Eclipse with the m2eclipse plugin and have setup a nexus repository mirror. When I search for artifacts it does not show the most recent versions; sometimes it shows very outdated versions of artifacts. I usually end up searching online for the latest version. Do I have something configured incorrectly, or is this a bug? I am currently on Eclipse Kepler, but this also happened in the Juno version.
For example, I tried adding the groovy dependency, which is currently on version 2.1.6. The latest (non-beta) shown is 1.8.1:
I don't think it has anything to do with Nexus. I can view my nexus repository in the Maven Repositories view in Eclipse. Also, if I manually type in the latest version there are not errors, so the JAR file(s) are pulled in correctly.
Here is my local settings.xml referencing the Nexus mirror:
<?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>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>nexus</id>
<username>deployment</username>
<password>mypassword</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>central</mirrorOf>
<url>http://myserver/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<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>
<activeProfile>nexus</activeProfile>
</activeProfiles>
This is most probably a problem with downloading the index files from Nexus.
Make sure you can find the latest version of the dependency when searching in the Nexus web UI. If this doesn't work, then Nexus fails to download the indexes from the upstream sites. Check for errors in the logs and manually trigger the download.
If the search on your Nexus works, make sure m2e can download the indexes when you start Eclipse. Look in the progress view when you start Eclipse; it should tell you that it downloads the indexes from Nexus.
You can also have a look at the Maven Console (in your console view; enable DEBUG to see more) right after starting Eclipse.
Lastly, you can start Eclipse with java instead of javaw. It will then print some debug information to a console/terminal window.

Getting javahg 0.6-SNAPSHOT from Maven

I'm trying to get JavaHG 0.6 snapshot using the following Maven pom:
<dependencies>
<dependency>
<groupId>com.aragost.javahg</groupId>
<artifactId>javahg</artifactId>
<version>0.6-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>sonatype-ossrh</id>
<name>Sonatype Open Source Software Repository Hosting</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
This makes the build fail with the following error:
Could not find artifact com.aragost.javahg:javahg-parent:pom:0.6-SNAPSHOT in sonatype-ossrh (https://oss.sonatype.org/content/repositories/snapshots/) -> [Help 1]
I think this is because 0.6-SNAPSHOT is not found in
https://oss.sonatype.org/content/repositories/snapshots/com/aragost/javahg/javahg-parent/
Does anyone know how to make it work?
Unfortunately recent builds aren't in maven currently. It is possible to build locally.
This thread has some details: https://bitbucket.org/mercurialeclipse/main/issue/424/plugin-readmemd-information-out-of-date
Clone the JavaHg repositories, including javahg-parent
Update to the 0.6 tag for each
Invoke mvn install for javahg-parent, and then again for the other repositories