Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include a Maven plugin from a local repository?

Tags:

maven

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?

like image 404
brk Avatar asked Dec 29 '15 14:12

brk


People also ask

Where do I put Maven plugins?

Introduction. In Maven, there are two kinds of plugins, build and reporting: Build plugins are executed during the build and configured in the <build/> element. Reporting plugins are executed during the site generation and configured in the <reporting/> element.

How do I force Maven to download dependencies from remote repository?

We can use -U/--update-snapshots flag when building a maven project to force maven to download dependencies from the remote repository. Here, -U,--update-snapshots : Forces a check for missing releases and updated snapshots on remote repositories.


1 Answers

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>
like image 158
heenenee Avatar answered Sep 18 '22 13:09

heenenee