Search code examples
eclipsemavenm2eclipse

Maven plugin could not find artifact when using remote server


I'm trying to write my own maven plugin. When I manually mvn install the plugin project, I can use it without a problem, but I'm having a problem retrieving it from our remote maven repository. This error occurs if I delete the com/company/my-plugin from my .m2/repository directory and then try to do mvn install.

[WARNING] The POM for com.company:my-plugin:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.472s
[INFO] Finished at: Wed Jun 19 16:15:29 EDT 2013
[INFO] Final Memory: 4M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin com.company:my-plugin:0.0.1-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.company:my-plugin:jar:0.0.1-SNAPSHOT: Could not find artifact com.company:my-plugin:pom:0.0.1-SNAPSHOT -> [Help 1]

The only reference to the plugin in the pom is in the build/plugins section:

<plugin>
    <groupId>com.company</groupId>
    <artifactId>my-plugin</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <configuration>
        <sourceFiles>
            <sourceFile>infile.foo</sourceFile>
        </sourceFiles>
        <outputFile>outpath/myfile.foo</outputFile>
    </configuration>
    <executions>
        <execution>
            <phase>process-resources</phase>
            <goals>
                <goal>my-goal</goal>
            </goals>
        </execution>
    </executions>
</plugin>

I've confirmed that the project exists in our remote repository and that other dependencies in that repository are resolving. The other dependencies are not plugins, however.

Is there additional configuration I need to specify to resolve a plugin dependency? Is there an approach I can use to help me figure out what's causing this problem more specifically?


Solution

  • Turns out I needed to separately specify the location of plugin repositories in the pom (in addition to specifying the remote repository normally). I was missing the following block:

    <pluginRepositories>
      <pluginRepository>
        <id>my-plugin-repo</id>
        <url>https://nexus.company.com:8443/path/to/repository/</url>
      </pluginRepository>
    </pluginRepositories>