Question

I'm mavenizing an ANT project and building the POM file. The current ANT build file has a target that generates 2 EAR files using weblogic's JwscTask. Now I just have to deploy only these 2 EAR files to a remote repo's weblogic server. I do not want Maven to generate any package, but take the generated 2 EAR files and deploy it. Essentially, the clean, compile and deploy phases have to be taken care of by Maven; packaging is done by ANT. I use the maven-antrun-plugin in the pom file to call the target in the build.xml file.

If I choose the packaging as 'POM', then Maven will not generate any packaging, but it won't compile the src files as well.

Is there any way in which I can skip the package phase in the Maven lifecycle? Say I specify the packaging as WAR in the POM, is there a way to skip the generation of the WAR file, and deploy the 2 EAR files?

Here is a section of the POM file:

<build>
  <plugins>
   <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-antrun-plugin</artifactId>
     <version>1.3</version>
     <executions>
      <execution>
        <phase>package</phase>
        <configuration>
        <tasks>
            <ant antfile="${basedir}/build.xml" target="build-service"/>
        </tasks>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
     </executions>
   </plugin>
  </plugins>
</build>
Was it helpful?

Solution

Use the mvn deploy:deploy-file goal. This allows you to deploy a file into a repository without having to do the rest of the project in Maven. You can give it either a pom.xml to deploy with it, or specify the various parameters:

$ mvn deploy:deploy-file -Dfile=app.ear \
    -DpomFile=pom.xml \
    -DrepositoryId=VeggieCorp \
    -Durl=http://mvn.veggiecorp.com/releases

Or

$ mvn deploy:deploy-file -Dfile=app.ear \
    -DgroupId=com.veggicorp \
    -DartifactId=app \
    -Dversion=3.2.1 \
    -DrepositoryId=VeggieCorp \
    -Durl=http://mvn.veggiecorp.com/releases

In fact, you don't even need the -DrepositoryId parameter unless you've created a settings.xml because the repository requires a username and password or need a proxy.

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