protected String packageAndInstallCustomWar ( String warName ) throws MojoExecutionException { final String warArtifactId = "${project.artifactId}-" + warName ; final String warSourceDir = getWarOutputDir ( warName ) ; // Package the customized war file // Note. don't use the maven-war-plugin here as it will package the module files twice, once from the // target/classes dir and once via the JAR String warPath = project . getBuild ( ) . getDirectory ( ) + "/" + warName + ".war" ; ZipUtil . pack ( new File ( warSourceDir ) , new File ( warPath ) ) ; // Install the customized war file in the local maven repo executeMojo ( plugin ( groupId ( "org.apache.maven.plugins" ) , artifactId ( "maven-install-plugin" ) , version ( MAVEN_INSTALL_PLUGIN_VERSION ) ) , goal ( "install-file" ) , configuration ( element ( name ( "file" ) , warPath ) , element ( name ( "groupId" ) , "${project.groupId}" ) , element ( name ( "artifactId" ) , warArtifactId ) , element ( name ( "version" ) , "${project.version}" ) , element ( name ( "packaging" ) , "war" ) // Don't forget, otherwise installed as .POM ) , execEnv ) ; return warArtifactId ; }
Package customized war file and install it in local maven repo .