Tuesday, October 21, 2014

How to install a maven plugin to the central repository

If you want to install a plugin to the central repository like Archiva or Artifactory, follow the below steps

1) Download the plugin jar from
2) Extract the jar file and from the META_INF folder copy the path to POM file
3) Open the command prompt and navigate to the directory where the jar and POM file resides
4) Run the following command by replacing the jar file name and pom name

For eg. to install  properties-maven-plugin-1.0-alpha-2.jar to central repository

mvn deploy:deploy-file -DpomFile=<path_to>\properties-maven-plugin-1.0-alpha-2\META-INF\maven\org.codehaus.mojo\properties-maven
-plugin\pom.xml -Dfile=properties-maven-plugin-1.0-alpha-2.jar -Durl=http://localhost:8091/artifactory/internal -DrepositoryId=internal


Now to use this plugin along with your POM file add the following section  in the POM file under the plugin section

 <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0-alpha-2</version>
                <executions>
                  <execution>
                    <phase>initialize</phase>
                    <goals>
                      <goal>read-project-properties</goal>
                    </goals>
                    <configuration>
                      <files>
                        <file>build-${deploy}.properties</file>
                      </files>
                    </configuration>
                  </execution>
                </executions>
              </plugin>

No comments:

Post a Comment