Author: snicoll Date: Sat Mar 17 06:50:48 2007 New Revision: 519315 URL: http://svn.apache.org/viewvc?view=rev&rev=519315 Log: MWAR-76: Allow Axis2 archives (.aar files) to be imported into WEB-INF/services directory. Submitted by: John Pfeifer Reviewed by: Stephane Nicoll
Added: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AarArtifactStub.java maven/plugins/trunk/maven-war-plugin/src/test/resources/unit/sample_wars/simple.aar Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java?view=diff&rev=519315&r1=519314&r2=519315 ============================================================================== --- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java (original) +++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java Sat Mar 17 06:50:48 2007 @@ -569,6 +569,8 @@ File libDirectory = new File( webinfDir, "lib" ); + File servicesDirectory = new File( webinfDir, "services" ); + File tldDirectory = new File( webinfDir, "tld" ); File webappClassesDirectory = new File( webappDirectory, WEB_INF + "/classes" ); @@ -613,6 +615,10 @@ if ( "tld".equals( type ) ) { copyFileIfModified( artifact.getFile(), new File( tldDirectory, targetFileName ) ); + } + else if("aar".equals(type)) + { + copyFileIfModified( artifact.getFile(), new File( servicesDirectory, targetFileName ) ); } else { Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java?view=diff&rev=519315&r1=519314&r2=519315 ============================================================================== --- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java (original) +++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java Sat Mar 17 06:50:48 2007 @@ -32,6 +32,7 @@ import org.apache.maven.plugin.war.stub.SimpleWarArtifactStub; import org.apache.maven.plugin.war.stub.TLDArtifactStub; import org.apache.maven.plugin.war.stub.EJBArtifactStubWithClassifier; +import org.apache.maven.plugin.war.stub.AarArtifactStub; import org.codehaus.plexus.util.FileUtils; import java.io.BufferedReader; @@ -569,6 +570,43 @@ expectedWebSourceFile.delete(); expectedWebSource2File.delete(); expectedPARArtifact.delete(); + } + + public void testExplodedWarWithAar() + throws Exception + { + // setup test data + String testId = "ExplodedWarWithAar"; + MavenProjectArtifactsStub project = new MavenProjectArtifactsStub(); + File webAppDirectory = new File( getTestDirectory(), testId ); + File webAppSource = createWebAppSource( testId ); + File classesDir = createClassesDir( testId, true ); + // Fake here since the aar artifact handler does not exist: no biggie + ArtifactHandler artifactHandler = (ArtifactHandler) lookup( ArtifactHandler.ROLE, "jar" ); + ArtifactStub aarArtifact = new AarArtifactStub( getBasedir(), artifactHandler ); + File aarFile = aarArtifact.getFile(); + + assertTrue( "jar not found: " + aarFile.toString(), aarFile.exists() ); + + // configure mojo + project.addArtifact( aarArtifact ); + this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project ); + mojo.execute(); + + // validate operation + File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" ); + File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" ); + // final name form is <artifactId>-<version>.<type> + File expectedJarArtifact = new File( webAppDirectory, "WEB-INF/services/aarartifact-0.0-Test.jar" ); + + assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() ); + assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() ); + assertTrue( "jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists() ); + + // house keeping + expectedWebSourceFile.delete(); + expectedWebSource2File.delete(); + expectedJarArtifact.delete(); } /** Added: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AarArtifactStub.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AarArtifactStub.java?view=auto&rev=519315 ============================================================================== --- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AarArtifactStub.java (added) +++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AarArtifactStub.java Sat Mar 17 06:50:48 2007 @@ -0,0 +1,79 @@ +package org.apache.maven.plugin.war.stub; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +import org.apache.maven.artifact.handler.ArtifactHandler; + +import java.io.File; + +/** + * @author Stephane Nicoll + */ +public class AarArtifactStub + extends AbstractArtifactStub +{ + protected String groupId; + + private ArtifactHandler artifactHandler; + + public AarArtifactStub( String basedir, ArtifactHandler artifactHandler ) + { + super( basedir ); + this.artifactHandler = artifactHandler; + } + + public void setGroupId( String id ) + { + groupId = id; + } + + public String getGroupId() + { + if ( groupId != null ) + { + return groupId; + } + else + { + return "org.sample.aar"; + } + } + + public String getType() + { + return "aar"; + } + + public String getArtifactId() + { + return "aarartifact"; + } + + public File getFile() + { + return new File( basedir, "/target/test-classes/unit/sample_wars/simple.aar" ); + } + + public ArtifactHandler getArtifactHandler() + { + return artifactHandler; + } +} Added: maven/plugins/trunk/maven-war-plugin/src/test/resources/unit/sample_wars/simple.aar URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/resources/unit/sample_wars/simple.aar?view=auto&rev=519315 ============================================================================== Binary files /tmp/tmpHNn_KS and /tmp/tmpLwjD6X differ