Search code examples
javamavendeploymentpackaging

How to specify artifact name in maven that I want installed/deployed


I have a maven pom orchestrator file used to control the build of all my modules. As a final build in my orchestrator step, I am calling a shell script via the exec-maven-plugin to manually create a zip file.

I would like to put this zip file that I have created in my m2 folder and deployed to my nexus repo.

Is there a simple of indicating to maven to deploy/install this zip file? Right now my packaging type for my file is pom, but I can change that to be something else.

Changing the build to use a plugin and not the shell script is not an option at this time.

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.proj</groupId>
    <artifactId>proj</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>Proj</name>

    <modules>
        <module>ProjCommon</module>
        <module>ProjEar</module>
    </modules>

    <build>
        <plugins>
            <plugin>
                <artifactId>exec-maven-plugin</artifactId>
                <groupId>org.codehaus.mojo</groupId>
                <executions>
                    <execution>
                        <id>Zip packaging and deployment</id>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${bash.path}</executable>
                            <arguments>
                                <argument>${bash.arguments}</argument>
                                <argument>${basedir}/../deployer/post-build-sbic.sh</argument>
                            </arguments>
                            <environmentVariables>
                                <MAJOR_VERSION>${major.version}</MAJOR_VERSION>
                                <MINOR_VERSION>${minor.version}</MINOR_VERSION>
                                <ARTIFACTS_DIR>${artifacts.folder}</ARTIFACTS_DIR>
                            </environmentVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project> 

Solution

  • Try something like this:

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>build-helper-maven-plugin</artifactId>
      <executions>
          <execution>
              <id>attach-artifacts</id>
              <phase>package</phase>
              <goals>
                  <goal>attach-artifact</goal>
              </goals>
              <configuration>
                  <artifacts>
                      <artifact>
                          <file>target/my-custom-archive.zip</file>
                          <type>zip</type>
                          <classifier>dist</classifier>
                      </artifact>
                  </artifacts>
              </configuration>
          </execution>
      </executions>
    </plugin>