Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload maven plugin to Nexus repository?

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>
like image 337
Sergey Avatar asked Jan 19 '12 11:01

Sergey


2 Answers

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.

like image 151
Sergey Avatar answered Sep 27 '22 17:09

Sergey


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.

like image 32
annihilate Avatar answered Sep 27 '22 16:09

annihilate