Question

Due to need for heavy customization I did developed my own Groovy plugin, which creates ZIP archive, which is 100% ready for deployment (like Maven assembly plugin does). Still, if I run

mvn clean install ...

command it creates an assembly (single ZIP file), puts it to ${project.build.directory} (.../target) and that's it.

How do I tell Maven, that it's now part of deployment and I would like to deploy this ZIP file?

Was it helpful?

Solution

You have two options:

Use buildhelper:attach-artifact:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.8</version>
    <executions>
      <execution>
        <id>attach-artifacts</id>
        <phase>package</phase>
        <goals>
          <goal>attach-artifact</goal>
        </goals>
        <configuration>
          <artifacts>
            <artifact>
              <file>some file</file>
              <type>extension of your file </type>
              <classifier>optional</classifier>
            </artifact>
            ...
          </artifacts>
        </configuration>
      </execution>
    </executions>
  </plugin>

Alternatively (and better), you could include the necessary code in your own plugin:

@Component
protected MavenProject project;

@Component
protected MavenProjectHelper projectHelper;

...

projectHelper.attachArtifact(project, "jar", resource.getClassifier(), targetArchive);

OTHER TIPS

Actually it worked in Groovy too (running from groovy-maven-plugin):

def helper =
        session.lookup("org.apache.maven.project.MavenProjectHelper");

helper.attachArtifact(project, "zip", _classifier, new File(_archiveFilename));

N.B.:

Both _classifier and _archiveFilename should be declared and initialized by your code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top