7
votes

I have a custom plugin that compresses files that I need to include in my maven build. So I have included this plugin in my pom.xml:

   <build>
        // Other tags
       <plugin>
            <groupId>someGroupId</groupId>
            <artifactId>somePlugin</artifactId>
            <version>1.0.0</version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>compress</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
      </plugins>
 </build>

Since it is a custom plugin, it is not available in any public Maven repository. So whenever I try to build, I get an error message saying:

Failed to read artifact .....

even though I have added it to my local repository. How can I refer to this plugin that is in my local repository?

1
What are the Maven coordinates for the plugin? (groupId, artifactId, version...) Was it installed in the local repo with mvn clean install?Tunaki

1 Answers

7
votes

If you mean local repository in the classic sense, make sure that you installed your plugin jar correctly. Install it to your local repository again with the following command:

mvn install:install-file -Dfile=/some/path/somePlugin.jar -DgroupId=someGroupId -DartifactId=somePlugin -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true

You should then be able to use your plugin in your Maven build.

If you mean local in the sense of some locally hosted repository, you need to specify the repository containing your artifact as a pluginRepository. Add the following to the top level of your pom.xml:

<pluginRepositories>
    <pluginRepository>
        <id>some-repo</id>
        <name>Some Repository</name>
        <url>http://some.host/some/path</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>