Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 2104 invoked from network); 23 Nov 2006 07:30:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Nov 2006 07:30:00 -0000 Received: (qmail 90885 invoked by uid 500); 23 Nov 2006 07:30:09 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 90697 invoked by uid 500); 23 Nov 2006 07:30:09 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 90686 invoked by uid 500); 23 Nov 2006 07:30:09 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 90680 invoked by uid 99); 23 Nov 2006 07:30:09 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Nov 2006 23:30:09 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Nov 2006 23:29:57 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id CCE491A9846; Wed, 22 Nov 2006 23:29:22 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r478500 - in /webservices/axis2/branches/java/1_1/modules/tool: ./ axis2-mar-maven-plugin/ axis2-mar-maven-plugin/src/ axis2-mar-maven-plugin/src/changes/ axis2-mar-maven-plugin/src/main/ axis2-mar-maven-plugin/src/main/java/ axis2-mar-mave... Date: Thu, 23 Nov 2006 07:29:22 -0000 To: axis2-cvs@ws.apache.org From: jochen@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061123072922.CCE491A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jochen Date: Wed Nov 22 23:29:21 2006 New Revision: 478500 URL: http://svn.apache.org/viewvc?view=rev&rev=478500 Log: Adding the axis2-mar-maven-plugin Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/ (with props) webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/pom.xml webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/changes/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/changes/changes.xml webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/AbstractMarMojo.java webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/FileSet.java webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarExplodedMojo.java webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarInPlaceMojo.java webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarMojo.java webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/resources/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/resources/META-INF/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/resources/META-INF/plexus/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/resources/META-INF/plexus/components.xml webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/configuration.apt webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/howto.apt webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/introduction.apt webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/site.xml Modified: webservices/axis2/branches/java/1_1/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojoTest.java webservices/axis2/branches/java/1_1/modules/tool/pom.xml Propchange: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Wed Nov 22 23:29:21 2006 @@ -0,0 +1 @@ +target Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/pom.xml URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/pom.xml?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/pom.xml (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/pom.xml Wed Nov 22 23:29:21 2006 @@ -0,0 +1,98 @@ + + + + + org.apache.axis2.maven2 + axis2-maven-tools + 1.1.0.1-SNAPSHOT + ../pom.xml + + 4.0.0 + axis2-mar-maven-plugin + maven-plugin + Axis 2 Mar Maven Plugin + + + A Maven 2 plugin for creating Axis 2 module archives (mar files) + + + + + org.apache.maven + maven-plugin-api + + + org.apache.maven + maven-project + + + org.apache.maven + maven-archiver + + + org.codehaus.plexus + plexus-utils + + + org.apache.maven + maven-artifact + + + org.apache.maven.shared + maven-plugin-testing-harness + + + + + + jochen + Jochen Wiedmann + jochen.wiedmann@gmail.com + + + + + + John Pfeifer + john.pfeifer@hnpsolutions.com + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + org.apache.maven.plugins + maven-changes-plugin + + + + changes-report + + + + + + + Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/changes/changes.xml URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/changes/changes.xml?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/changes/changes.xml (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/changes/changes.xml Wed Nov 22 23:29:21 2006 @@ -0,0 +1,12 @@ + + + Changes in the Axis2 MAR plugin for Maven 2 + + + + + Initial release. + + + + Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/AbstractMarMojo.java URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/AbstractMarMojo.java?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/AbstractMarMojo.java (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/AbstractMarMojo.java Wed Nov 22 23:29:21 2006 @@ -0,0 +1,295 @@ +package org.apache.axis2.maven2.mar; + +/* + * Copyright 2006 The Apache Software Foundation. + * + * Licensed 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 java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.util.DirectoryScanner; +import org.codehaus.plexus.util.FileUtils; + + + +/** + * Abstract base class of all the mojos in the axis2-mar-maven-plugin. + */ +public abstract class AbstractMarMojo + extends AbstractMojo +{ + + /** + * The projects base directory. + * + * @parameter expression="${project.basedir}" + * @required + * @readonly + */ + protected File baseDir; + + /** + * The maven project. + * + * @parameter expression="${project}" + * @required + * @readonly + */ + protected MavenProject project; + + /** + * The directory containing generated classes. + * + * @parameter expression="${project.build.outputDirectory}" + * @required + */ + private File classesDirectory; + + /** + * The directory where the mar is built. + * + * @parameter expression="${project.build.directory}/mar" + * @required + */ + protected File marDirectory; + + /** + * The location of the module.xml file. If it is present in the META-INF + * directory in src/main/resources with that name then it will automatically be + * included. Otherwise this parameter must be set. + * + * @parameter + */ + private File moduleXmlFile; + + /** + * Additional file sets, which are being added to the archive. + * + * @parameter + */ + private FileSet[] fileSets; + + /** + * Builds the exploded mar file. + * @throws MojoExecutionException + */ + protected void buildExplodedMar( ) + throws MojoExecutionException + { + getLog().debug( "Exploding mar..." ); + + marDirectory.mkdirs(); + getLog().debug( "Assembling mar " + project.getArtifactId() + " in " + marDirectory ); + + try + { + final File metaInfDir = new File( marDirectory, "META-INF" ); + final File libDir = new File(marDirectory, "lib"); + final File moduleFileTarget = new File( metaInfDir, "module.xml" ); + boolean existsBeforeCopyingClasses = moduleFileTarget.exists(); + + if ( classesDirectory.exists() && ( !classesDirectory.equals( marDirectory ) ) ) + { + FileUtils.copyDirectoryStructure( classesDirectory, marDirectory ); + } + + if ( fileSets != null ) + { + for ( int i = 0; i < fileSets.length; i++ ) + { + FileSet fileSet = fileSets[i]; + copyFileSet( fileSet, marDirectory ); + } + } + + copyMetaInfFile( moduleXmlFile, moduleFileTarget, existsBeforeCopyingClasses, "module.xml file" ); + + Set artifacts = project.getArtifacts(); + + List duplicates = findDuplicates( artifacts ); + + for ( Iterator iter = artifacts.iterator(); iter.hasNext(); ) + { + Artifact artifact = (Artifact) iter.next(); + String targetFileName = getDefaultFinalName( artifact ); + + getLog().debug( "Processing: " + targetFileName ); + + if ( duplicates.contains( targetFileName ) ) + { + getLog().debug( "Duplicate found: " + targetFileName ); + targetFileName = artifact.getGroupId() + "-" + targetFileName; + getLog().debug( "Renamed to: " + targetFileName ); + } + + // TODO: utilise appropriate methods from project builder + ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME ); + if ( !artifact.isOptional() && filter.include( artifact ) ) + { + String type = artifact.getType(); + if ( "jar".equals( type ) ) + { + copyFileIfModified( artifact.getFile(), new File( libDir, targetFileName ) ); + } + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Could not explode mar...", e ); + } + } + + /** + * Searches a set of artifacts for duplicate filenames and returns a list of duplicates. + * + * @param artifacts set of artifacts + * @return List of duplicated artifacts + */ + private List findDuplicates( Set artifacts ) + { + List duplicates = new ArrayList(); + List identifiers = new ArrayList(); + for ( Iterator iter = artifacts.iterator(); iter.hasNext(); ) + { + Artifact artifact = (Artifact) iter.next(); + String candidate = getDefaultFinalName( artifact ); + if ( identifiers.contains( candidate ) ) + { + duplicates.add( candidate ); + } + else + { + identifiers.add( candidate ); + } + } + return duplicates; + } + + /** + * Converts the filename of an artifact to artifactId-version.type format. + * + * @param artifact + * @return converted filename of the artifact + */ + private String getDefaultFinalName( Artifact artifact ) + { + return artifact.getArtifactId() + "-" + artifact.getVersion() + "." + + artifact.getArtifactHandler().getExtension(); + } + + /** + * Copy file from source to destination only if source timestamp is later than the destination timestamp. + * The directories up to destination will be created if they don't already exist. + * destination will be overwritten if it already exists. + * + * @param source An existing non-directory File to copy bytes from. + * @param destination A non-directory File to write bytes to (possibly + * overwriting). + * @throws IOException if source does not exist, destination cannot be + * written to, or an IO error occurs during copying. + * @throws java.io.FileNotFoundException if destination is a directory + *

+ * TO DO: Remove this method when Maven moves to plexus-utils version 1.4 + */ + private void copyFileIfModified( File source, File destination ) + throws IOException + { + // TO DO: Remove this method and use the method in WarFileUtils when Maven 2 changes + // to plexus-utils 1.2. + if ( destination.lastModified() < source.lastModified() ) + { + FileUtils.copyFile( source.getCanonicalFile(), destination ); + // preserve timestamp + destination.setLastModified( source.lastModified() ); + } + } + + private void copyFileSet( FileSet fileSet, File targetDirectory ) + throws IOException + { + File dir = fileSet.getDirectory(); + if ( dir == null ) + { + dir = baseDir; + } + File targetDir = targetDirectory; + if ( fileSet.getOutputDirectory() != null ) + { + targetDir = new File( targetDir, fileSet.getOutputDirectory() ); + } + if ( targetDir.equals( dir ) ) + { + return; + } + + DirectoryScanner ds = new DirectoryScanner(); + ds.setBasedir( dir ); + if ( !fileSet.isSkipDefaultExcludes() ) + { + ds.addDefaultExcludes(); + } + final String[] excludes = fileSet.getExcludes(); + if ( excludes != null ) + { + ds.setExcludes( excludes ); + } + final String[] includes = fileSet.getIncludes(); + if ( includes != null ) + { + ds.setIncludes( includes ); + } + ds.scan(); + String[] files = ds.getIncludedFiles(); + for ( int i = 0; i < files.length; i++ ) + { + File sourceFile = new File( dir, files[i] ); + File targetFile = new File( targetDir, files[i] ); + FileUtils.copyFile( sourceFile, targetFile ); + } + } + + + private void copyMetaInfFile( final File pSource, final File pTarget, + final boolean pExistsBeforeCopying, + final String pDescription ) + throws MojoExecutionException, IOException + { + if ( pSource != null && pTarget != null ) + { + if ( !pSource.exists() ) + { + throw new MojoExecutionException( "The configured " + pDescription + " could not be found at " + + pSource ); + } + + if ( !pExistsBeforeCopying && pTarget.exists() ) + { + getLog().warn( "The configured " + pDescription + " overwrites another file from the classpath." ); + } + + FileUtils.copyFile( pSource, pTarget ); + } + } +} Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/FileSet.java URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/FileSet.java?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/FileSet.java (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/FileSet.java Wed Nov 22 23:29:21 2006 @@ -0,0 +1,120 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * Licensed 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. + */ +package org.apache.axis2.maven2.mar; + +import java.io.File; + + +/** + * A FileSet defines additional files, which are being added to the + * Axis application archive. The objects structure follows the + * FileSet object from the maven-assembly-plugin, see the + * plugin documentation + * for details. + */ +public class FileSet +{ + private File directory; + private String outputDirectory; + private String[] includes, excludes; + private boolean skipDefaultExcludes; + + /** + * Returns the file sets base directory. May be omitted, in which + * case the projects base directory is assumed. + */ + public File getDirectory() + { + return directory; + } + + /** + * Sets the file sets base directory. May be omitted, in which + * case the projects base directory is assumed. + */ + public void setDirectory( File directory ) + { + this.directory = directory; + } + + /** + * Returns the file sets exclusion list. + */ + public String[] getExcludes() + { + return excludes; + } + + /** + * Sets the file sets exclusion list. + */ + public void setExcludes( String[] excludes ) + { + this.excludes = excludes; + } + + /** + * Returns the file sets inclusion list. + */ + public String[] getIncludes() + { + return includes; + } + + /** + * Sets the file sets inclusion list. + */ + public void setIncludes( String[] includes ) + { + this.includes = includes; + } + + /** + * Sets a prefix, which the included files should have + * when being added to the Axis application archive. + */ + public String getOutputDirectory() + { + return outputDirectory; + } + + /** + * Returns a prefix, which the included files should have + * when being added to the Axis application archive. + */ + public void setOutputDirectory( String outputDirectory ) + { + this.outputDirectory = outputDirectory; + } + + /** + * Returns, whether the default excludes should be used. Defaults + * to true. + */ + public boolean isSkipDefaultExcludes() + { + return skipDefaultExcludes; + } + + /** + * Sets, whether the default excludes should be used. Defaults to + * true. + */ + public void setSkipDefaultExcludes( boolean skipDefaultExcludes ) + { + this.skipDefaultExcludes = skipDefaultExcludes; + } +} Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarExplodedMojo.java URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarExplodedMojo.java?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarExplodedMojo.java (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarExplodedMojo.java Wed Nov 22 23:29:21 2006 @@ -0,0 +1,36 @@ +package org.apache.axis2.maven2.mar; + +/* + * Copyright 2006 The Apache Software Foundation. + * + * Licensed 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.plugin.MojoExecutionException; + +/** + * Generate the exploded mar + * + * @goal exploded + * @phase package + * @requiresDependencyResolution runtime + */ +public class MarExplodedMojo + extends AbstractMarMojo +{ + public void execute() + throws MojoExecutionException + { + buildExplodedMar(); + } +} Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarInPlaceMojo.java URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarInPlaceMojo.java?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarInPlaceMojo.java (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarInPlaceMojo.java Wed Nov 22 23:29:21 2006 @@ -0,0 +1,38 @@ +package org.apache.axis2.maven2.mar; + +/* + * Copyright 2006 The Apache Software Foundation. + * + * Licensed 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.plugin.MojoExecutionException; + +/** + * Generates mar in the source directory + * + * @goal inplace + * @requiresDependencyResolution runtime + */ +public class MarInPlaceMojo + extends AbstractMarMojo +{ + + public void execute() + throws MojoExecutionException + { + + getLog().debug("Generating mar in source directory... " + marDirectory); + buildExplodedMar(); + } +} Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarMojo.java URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarMojo.java?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarMojo.java (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/java/org/apache/axis2/maven2/mar/MarMojo.java Wed Nov 22 23:29:21 2006 @@ -0,0 +1,161 @@ +package org.apache.axis2.maven2.mar; + +/* + * Copyright 2006 The Apache Software Foundation. + * + * Licensed 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 java.io.File; +import java.io.IOException; + +import org.apache.maven.archiver.MavenArchiveConfiguration; +import org.apache.maven.archiver.MavenArchiver; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DependencyResolutionRequiredException; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProjectHelper; +import org.codehaus.plexus.archiver.ArchiverException; +import org.codehaus.plexus.archiver.jar.JarArchiver; +import org.codehaus.plexus.archiver.jar.ManifestException; + +/** + * Build a mar. + * + * @goal mar + * @phase package + * @requiresDependencyResolution runtime + */ +public class MarMojo extends AbstractMarMojo +{ + /** + * The directory for the generated mar. + * + * @parameter expression="${project.build.directory}" + * @required + */ + private String outputDirectory; + + /** + * The name of the generated mar. + * + * @parameter expression="${project.build.finalName}" + * @required + */ + private String marName; + + /** + * The Jar archiver. + * + * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#jar}" + * @required + */ + private JarArchiver jarArchiver; + + /** + * The maven archive configuration to use. + * + * @parameter + */ + private MavenArchiveConfiguration archive = new MavenArchiveConfiguration(); + + /** + * Classifier to add to the artifact generated. If given, the artifact will be an attachment instead. + * + * @parameter + */ + private String classifier; + + /** + * Whether this is the main artifact being built. Set to false if you don't want to install or deploy + * it to the local repository instead of the default one in an execution. + * + * @parameter expression="${primaryArtifact}" default-value="true" + */ + private boolean primaryArtifact; + + /** + * @component + */ + private MavenProjectHelper projectHelper; + + /** + * Executes the MarMojo on the current project. + * + * @throws MojoExecutionException + * if an error occured while building the webapp + */ + public void execute() throws MojoExecutionException + { + + File marFile = new File( outputDirectory, marName + ".mar" ); + + try + { + performPackaging( marFile ); + } + catch ( Exception e ) + { + throw new MojoExecutionException( "Error assembling mar", e ); + } + } + + /** + * Generates the mar. + * + * @param marFile + * the target mar file + * @throws IOException + * @throws ArchiverException + * @throws ManifestException + * @throws DependencyResolutionRequiredException + */ + private void performPackaging( File marFile ) + throws IOException, ArchiverException, ManifestException, DependencyResolutionRequiredException, + MojoExecutionException + { + + buildExplodedMar( ); + + // generate mar file + getLog().info( "Generating mar " + marFile.getAbsolutePath() ); + MavenArchiver archiver = new MavenArchiver(); + archiver.setArchiver( jarArchiver ); + archiver.setOutputFile( marFile ); + jarArchiver.addDirectory( marDirectory ); + + // create archive + archiver.createArchive( project, archive ); + + if ( classifier != null ) + { + projectHelper.attachArtifact( project, "mar", classifier, marFile ); + } + else + { + Artifact artifact = project.getArtifact(); + if ( primaryArtifact ) + { + artifact.setFile( marFile ); + } + else if ( artifact.getFile() == null || artifact.getFile().isDirectory() ) + { + artifact.setFile( marFile ); + } + else + { + projectHelper.attachArtifact( project, "mar", marFile ); + } + } + } +} Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/resources/META-INF/plexus/components.xml URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/resources/META-INF/plexus/components.xml?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/resources/META-INF/plexus/components.xml (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/main/resources/META-INF/plexus/components.xml Wed Nov 22 23:29:21 2006 @@ -0,0 +1,34 @@ + + + + org.apache.maven.artifact.handler.ArtifactHandler + mar + org.apache.maven.artifact.handler.DefaultArtifactHandler + + + mar + mar + jar + java + false + + + + org.apache.maven.lifecycle.mapping.LifecycleMapping + mar + org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping + + + org.apache.maven.plugins:maven-resources-plugin:resources + org.apache.maven.plugins:maven-compiler-plugin:compile + org.apache.maven.plugins:maven-resources-plugin:testResources + org.apache.maven.plugins:maven-compiler-plugin:testCompile + org.apache.maven.plugins:maven-surefire-plugin:test + org.apache.axis2.maven2:axis2-mar-maven-plugin:mar + org.apache.maven.plugins:maven-install-plugin:install + org.apache.maven.plugins:maven-deploy-plugin:deploy + + + + + Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/configuration.apt URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/configuration.apt?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/configuration.apt (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/configuration.apt Wed Nov 22 23:29:21 2006 @@ -0,0 +1,98 @@ +Configuration + + All Mar plugin goals takes the following configuration parameters as input: + +*------------------+----------------------------------+------------------------------------------------+ +| Parameter name | Default value | Description | +*------------------+----------------------------------+------------------------------------------------+ +| marDirectory | ${project.build.directory}/mar | Directory where the mar file is built. | +*------------------+----------------------------------+------------------------------------------------+ +| classesDirectory | ${project.build.outputDirectory} | Directory with compiled classes and resources. | +*------------------+----------------------------------+------------------------------------------------+ +| fileSets | | Additional file sets, which are being added to | +| | | the archive. See "File Sets" below for an | +| | | example. | +*------------------+----------------------------------+------------------------------------------------+ +| moduleXmlFile | | Location of the module.xml file. By default, | +| | | it is assumed that the file is already present | +| | | in classesDirectory/META-INF and no special | +| | | processing is required. | +*------------------+----------------------------------+------------------------------------------------+ + + +The mar goal + + The mar goal allows the following additional parameters: + +*------------------+----------------------------+------------------------------------------------+ +| Parameter name | Default value | Description | +*------------------+----------------------------+------------------------------------------------+ +| outputDirectory | ${project.build.directory} | Directory where to generate the MAR file. | +*------------------+----------------------------+------------------------------------------------+ +| marName | ${project.build.finalName} | The generated MAR files name. | +*------------------+----------------------------+------------------------------------------------+ +| archive | | A Maven archive configuration. This allows, | +| | | for example, to configure the MANIFEST.MF | +| | | file. | +*------------------+----------------------------+------------------------------------------------+ +| classifier | | A classifier, which should be added to the | +| | | generated MAR files name. Setting this | +| | | parameter has the side effect, that the | +| | | artifact is treated as an attachment and not | +| | | as the projects primary artifact. | +*------------------+----------------------------+------------------------------------------------+ +| primaryArtifact | true | Setting this property to false disables | +| | | installation or deployment of the artifact as | +| | | the projects primary artifact. | +*------------------+----------------------------+------------------------------------------------+ + + +File Sets + + Additional file sets may be configured for inclusion into the MAR file. A file set looks + as follows: + +----------------- + + + src/mar/files + META-INF/docs + + **/*.html + + + + src/mar/files + META-INF/etc + + **/*.html + + + +----------------- + + The example specifies, that the contents of the directory src/mar/files shall + be added to the MAR file. HTML files will go into META-INF/docs, all other + files to META-INF/etc. + + A file set is configured through the following configuration parameters: + +*---------------------+-------------------------------------------------------------------+ +| Parameter name | Description | +*---------------------+-------------------------------------------------------------------+ +| directory | The directory, from which to read the file set. This parameter is | +| | required. | +*---------------------+-------------------------------------------------------------------+ +| outputDirectory | The target directory within the MAR file. Defaults to the MAR | +| | files root directory. | +*---------------------+-------------------------------------------------------------------+ +| includes | Configures the set of files, which shall be included into the MAR | +| | file. Defaults to **/*. | +*---------------------+-------------------------------------------------------------------+ +| excludes | Configures a set of files, which shall be excluded from the file | +| | set. Defaults to the Maven default excludes (**/*~, **/cvs/**/*, | +| | **/.svn/**/*, etc.) | +*---------------------+-------------------------------------------------------------------+ +| skipDefaultExcludes | If this parameter is set to true, then no default excludes are | +| | being used. | +*---------------------+-------------------------------------------------------------------+ Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/howto.apt URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/howto.apt?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/howto.apt (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/howto.apt Wed Nov 22 23:29:21 2006 @@ -0,0 +1,23 @@ + ------ + Maven 2 Mar Plugin: configuration examples + ------ + Jochen Wiedmann + + ------ + +Goals + + The Mar plugin allows the packaging of an Axis 2 service mar in 3 different modes: + + * mar (default): generates the mar artifact + + * inplace: package the mar in the source tree + + * exploded : package an exploded mar application + + Each mode is materialized by a goal. For instance, to generate an exploded + mar from the current project, one would type + ++-------- + mvn mar:exploded ++--------- Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/introduction.apt URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/introduction.apt?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/introduction.apt (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/apt/introduction.apt Wed Nov 22 23:29:21 2006 @@ -0,0 +1,15 @@ + ------ + Maven 2 Aar Plugin + ------ + Jochen Wiedmann + + ------ + +Introduction + + This plugin generates an Axis 2 service file (AAR file). + + The full description of goals is available {{{howto.html}here}}. + + + Added: webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/site.xml URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/site.xml?view=auto&rev=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/site.xml (added) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-mar-maven-plugin/src/site/site.xml Wed Nov 22 23:29:21 2006 @@ -0,0 +1,45 @@ + + + + + + + Maven Axis 2 MAR Plugin + http://maven.apache.org/images/apache-maven-project.png + http://maven.apache.org/ + + + http://maven.apache.org/images/maven-small.gif + + + + + + + + + +

+ + + + + ${reports} + + Modified: webservices/axis2/branches/java/1_1/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojoTest.java URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojoTest.java?view=diff&rev=478500&r1=478499&r2=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojoTest.java (original) +++ webservices/axis2/branches/java/1_1/modules/tool/axis2-wsdl2code-maven-plugin/src/test/java/org/apache/axis2/maven2/wsdl2code/WSDL2CodeMojoTest.java Wed Nov 22 23:29:21 2006 @@ -24,7 +24,6 @@ import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; -import org.codehaus.plexus.util.FileUtils; /** * Test class for running the wsdl2code mojo. Modified: webservices/axis2/branches/java/1_1/modules/tool/pom.xml URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/tool/pom.xml?view=diff&rev=478500&r1=478499&r2=478500 ============================================================================== --- webservices/axis2/branches/java/1_1/modules/tool/pom.xml (original) +++ webservices/axis2/branches/java/1_1/modules/tool/pom.xml Wed Nov 22 23:29:21 2006 @@ -42,6 +42,7 @@ axis2-aar-maven-plugin + axis2-mar-maven-plugin axis2-java2wsdl-maven-plugin axis2-wsdl2code-maven-plugin --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org