Maven war artifact with car extension
Asked Answered
C

1

6

I am trying to use Maven to generate an artifact for deploying on Vignette Portal. The packaging is exactly the same as a war artifact but the file should have car extension instead.

Options I've tried and I've not been able to complete.

  • Use war plugin and rename the final artifact (keeps adding .war extension)
  • Use assembly plugin with zip descriptor (not able to change .zip to .car extension)
  • Create a new packaging type as described here (can't use war plugin for .car extension)

Which would be the easiest 'Maven' way to generate the .car file? Could you give me some guidance?

Thank you.

Cheater answered 16/5, 2011 at 9:51 Comment(0)
H
8

I think it's not possible to rename the main deliverable artifact of a project.

Anyway, in the past, what I've done so far was making maven copy the file with a new name and then "attach" it to the deliverables of a build; by configuring two plugins:

  • maven-ant-run to copy
  • maven-build-helper to attach in order to be deployed to my repo along with the main artifact of my project.

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-antrun-plugin</artifactId>
      <executions>
        <execution>
          <phase>package</phase>
            <configuration>
              <target>
                <copy file="${project.build.directory}/${project.build.finalName}.war"
                  tofile="${project.build.directory}/${project.build.finalName}.car" />
              </target>
            </configuration>
            <goals>
             <goal>run</goal>
            </goals>
          </execution>
        </executions>
    </plugin>
    

And the second:

    <plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <executions>
        <execution>
          <id>attach-instrumented-jar</id>
            <phase>verify</phase>
              <goals>
                <goal>attach-artifact</goal>
              </goals>
      <configuration>
                <artifacts>
                  <artifact>
                    <file>${project.build.directory}/${project.build.finalName}.car</file>
                    <type>car</type>
                  </artifact>
                </artifacts>
              </configuration>
          </execution>
       </executions>
     </plugin>

I hope that can help you. At least until you find a better solution.

Hairbrush answered 19/6, 2011 at 7:55 Comment(3)
For the first example it works for me with the child of configuration being tasks instead of target, maybe because of a newer antrun version?Aeon
@jaime yes, possibly.Gynandry
@jaime check the MOJO documentation, looks like tasks has been deprecated in favour of target. maven.apache.org/plugins/maven-antrun-plugin/run-mojo.htmlGynandry

© 2022 - 2024 — McMap. All rights reserved.