You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by gd...@apache.org on 2007/03/29 20:49:16 UTC

svn commit: r523794 [8/8] - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/databinding/ adb/src/org/apache/axis2/databinding/i18n/ adb/src/org/apache/axis2/databinding/typemapping/ adb/src/org/apache/axis2/databinding/types/ adb/src...

Modified: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java (original)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/AbstractAarMojo.java Thu Mar 29 11:49:12 2007
@@ -16,13 +16,6 @@
  * 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;
@@ -31,14 +24,17 @@
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
 
 
-/**
- * Abstract base class of all the mojos in the axis2-aar-maven-plugin.
- */
+/** Abstract base class of all the mojos in the axis2-aar-maven-plugin. */
 public abstract class AbstractAarMojo
-    extends AbstractMojo
-{
+        extends AbstractMojo {
 
     /**
      * The projects base directory.
@@ -48,7 +44,7 @@
      * @readonly
      */
     protected File baseDir;
-    
+
     /**
      * The maven project.
      *
@@ -75,26 +71,26 @@
     protected File aarDirectory;
 
     /**
-     * The location of the services.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.
+     * The location of the services.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 
+     * @parameter
      */
     private File servicesXmlFile;
 
     /**
-     * The location of the WSDL file, if any. By default, no WSDL file is added
-     * and it is assumed, that Axis 2 will automatically generate a WSDL file.
+     * The location of the WSDL file, if any. By default, no WSDL file is added and it is assumed,
+     * that Axis 2 will automatically generate a WSDL file.
      *
-     * @parameter 
+     * @parameter
      */
     private File wsdlFile;
 
     /**
-     * Name, to which the wsdl file shall be mapped. By default, the name will
-     * be computed from the files path by removing the directory.
-     * 
+     * Name, to which the wsdl file shall be mapped. By default, the name will be computed from the
+     * files path by removing the directory.
+     *
      * @parameter default-value="service.wsdl"
      */
     private String wsdlFileName;
@@ -105,69 +101,65 @@
      * @parameter
      */
     private FileSet[] fileSets;
-    
+
     /**
      * Whether the dependency jars should be included in the aar
-     * 
+     *
      * @parameter expression="${includeDependencies}" default-value="true"
      */
     private boolean includeDependencies;
 
     /**
      * Builds the exploded AAR file.
+     *
      * @throws MojoExecutionException
      */
-    protected void buildExplodedAar( )
-        throws MojoExecutionException
-    {
-        getLog().debug( "Exploding aar..." );
+    protected void buildExplodedAar()
+            throws MojoExecutionException {
+        getLog().debug("Exploding aar...");
 
         aarDirectory.mkdirs();
-        getLog().debug( "Assembling aar " + project.getArtifactId() + " in " + aarDirectory );
+        getLog().debug("Assembling aar " + project.getArtifactId() + " in " + aarDirectory);
 
-        try
-        {
-            final File metaInfDir = new File( aarDirectory, "META-INF" );
+        try {
+            final File metaInfDir = new File(aarDirectory, "META-INF");
             final File libDir = new File(aarDirectory, "lib");
-            final File servicesFileTarget = new File( metaInfDir, "services.xml" );
+            final File servicesFileTarget = new File(metaInfDir, "services.xml");
             boolean existsBeforeCopyingClasses = servicesFileTarget.exists();
 
             String wsdlName = wsdlFileName;
-            if ( wsdlName == null  &&  wsdlFile != null )
-            {
+            if (wsdlName == null && wsdlFile != null) {
                 wsdlName = wsdlFile.getName();
             }
             File wsdlFileTarget = null;
-            if ( wsdlFile != null )
-            {
-                wsdlFileTarget = new File( metaInfDir, wsdlFileName );
+            if (wsdlFile != null) {
+                wsdlFileTarget = new File(metaInfDir, wsdlFileName);
             }
-            boolean wsdlExistsBeforeCopyingClasses = wsdlFileTarget == null ? false : wsdlFileTarget.exists();
+            boolean wsdlExistsBeforeCopyingClasses =
+                    wsdlFileTarget == null ? false : wsdlFileTarget.exists();
 
-            if ( classesDirectory.exists() && ( !classesDirectory.equals( aarDirectory ) ) )
-            {
-                FileUtils.copyDirectoryStructure( classesDirectory, aarDirectory );
+            if (classesDirectory.exists() && (!classesDirectory.equals(aarDirectory))) {
+                FileUtils.copyDirectoryStructure(classesDirectory, aarDirectory);
             }
 
-            if ( fileSets != null )
-            {
-                for ( int i = 0;  i < fileSets.length;   i++ )
-                {
+            if (fileSets != null) {
+                for (int i = 0; i < fileSets.length; i++) {
                     FileSet fileSet = fileSets[i];
-                    copyFileSet( fileSet, aarDirectory );
+                    copyFileSet(fileSet, aarDirectory);
                 }
             }
-            
-            copyMetaInfFile( servicesXmlFile, servicesFileTarget, existsBeforeCopyingClasses, "services.xml file" );
-            copyMetaInfFile( wsdlFile, wsdlFileTarget, wsdlExistsBeforeCopyingClasses, "WSDL file" );
 
-            if(includeDependencies){
+            copyMetaInfFile(servicesXmlFile, servicesFileTarget, existsBeforeCopyingClasses,
+                            "services.xml file");
+            copyMetaInfFile(wsdlFile, wsdlFileTarget, wsdlExistsBeforeCopyingClasses, "WSDL file");
+
+            if (includeDependencies) {
                 Set artifacts = project.getArtifacts();
 
                 List duplicates = findDuplicates(artifacts);
 
                 for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
-                    Artifact artifact = (Artifact) iter.next();
+                    Artifact artifact = (Artifact)iter.next();
                     String targetFileName = getDefaultFinalName(artifact);
 
                     getLog().debug("Processing: " + targetFileName);
@@ -192,9 +184,8 @@
                 }
             }
         }
-        catch ( IOException e )
-        {
-            throw new MojoExecutionException( "Could not explode aar...", e );
+        catch (IOException e) {
+            throw new MojoExecutionException("Could not explode aar...", e);
         }
     }
 
@@ -204,21 +195,16 @@
      * @param artifacts set of artifacts
      * @return List of duplicated artifacts
      */
-    private List findDuplicates( Set 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 );
+        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;
@@ -230,103 +216,92 @@
      * @param artifact
      * @return converted filename of the artifact
      */
-    private String getDefaultFinalName( Artifact artifact )
-    {
+    private String getDefaultFinalName(Artifact artifact) {
         return artifact.getArtifactId() + "-" + artifact.getVersion() + "." +
-            artifact.getArtifactHandler().getExtension();
+                artifact.getArtifactHandler().getExtension();
     }
 
     /**
-     * Copy file from source to destination only if source timestamp is later than the destination timestamp.
-     * The directories up to <code>destination</code> will be created if they don't already exist.
-     * <code>destination</code> will be overwritten if it already exists.
+     * Copy file from source to destination only if source timestamp is later than the destination
+     * timestamp. The directories up to <code>destination</code> will be created if they don't
+     * already exist. <code>destination</code> will be overwritten if it already exists.
      *
      * @param source      An existing non-directory <code>File</code> to copy bytes from.
      * @param destination A non-directory <code>File</code> to write bytes to (possibly
      *                    overwriting).
-     * @throws IOException                   if <code>source</code> does not exist, <code>destination</code> cannot be
-     *                                       written to, or an IO error occurs during copying.
+     * @throws IOException                   if <code>source</code> does not exist,
+     *                                       <code>destination</code> cannot be written to, or an IO
+     *                                       error occurs during copying.
      * @throws java.io.FileNotFoundException if <code>destination</code> is a directory
      *                                       <p/>
-     *                                       TO DO: Remove this method when Maven moves to plexus-utils version 1.4
+     *                                       TO DO: Remove this method when Maven moves to
+     *                                       plexus-utils version 1.4
      */
-    private void copyFileIfModified( File source, File destination )
-        throws IOException
-    {
+    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 );
+        if (destination.lastModified() < source.lastModified()) {
+            FileUtils.copyFile(source.getCanonicalFile(), destination);
             // preserve timestamp
-            destination.setLastModified( source.lastModified() );
+            destination.setLastModified(source.lastModified());
         }
     }
 
-    private void copyFileSet( FileSet fileSet, File targetDirectory )
-        throws IOException
-    {
+    private void copyFileSet(FileSet fileSet, File targetDirectory)
+            throws IOException {
         File dir = fileSet.getDirectory();
-        if ( dir == null )
-        {
+        if (dir == null) {
             dir = baseDir;
         }
         File targetDir = targetDirectory;
-        if ( fileSet.getOutputDirectory() != null )
-        {
-            targetDir = new File( targetDir, fileSet.getOutputDirectory() );
+        if (fileSet.getOutputDirectory() != null) {
+            targetDir = new File(targetDir, fileSet.getOutputDirectory());
         }
-        if ( targetDir.equals( dir ) )
-        {
+        if (targetDir.equals(dir)) {
             return;
         }
 
         DirectoryScanner ds = new DirectoryScanner();
-        ds.setBasedir( dir );
-        if ( !fileSet.isSkipDefaultExcludes() )
-        {
+        ds.setBasedir(dir);
+        if (!fileSet.isSkipDefaultExcludes()) {
             ds.addDefaultExcludes();
         }
         final String[] excludes = fileSet.getExcludes();
-        if ( excludes != null )
-        {
-            ds.setExcludes( excludes );
+        if (excludes != null) {
+            ds.setExcludes(excludes);
         }
         final String[] includes = fileSet.getIncludes();
-        if ( includes != null )
-        {
-            ds.setIncludes( includes );
+        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 );
+        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 );
+    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." );
+            if (!pExistsBeforeCopying && pTarget.exists()) {
+                getLog().warn("The configured " + pDescription +
+                        " overwrites another file from the classpath.");
             }
 
-            FileUtils.copyFile( pSource, pTarget );
+            FileUtils.copyFile(pSource, pTarget);
         }
     }
 }

Modified: webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/FileSet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/FileSet.java?view=diff&rev=523794&r1=523793&r2=523794
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/FileSet.java (original)
+++ webservices/axis2/trunk/java/modules/tool/axis2-aar-maven-plugin/src/main/java/org/apache/axis2/maven2/aar/FileSet.java Thu Mar 29 11:49:12 2007
@@ -19,102 +19,76 @@
 
 
 /**
- * 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
- * <a href="http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html">plugin documentation</a>
- * for details.
+ * 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 <a
+ * href="http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html">plugin
+ * documentation</a> for details.
  */
-public class FileSet
-{
+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.
+     * Returns the file sets base directory. May be omitted, in which case the projects base
+     * directory is assumed.
      */
-    public File getDirectory()
-    {
+    public File getDirectory() {
         return directory;
     }
 
     /**
-     * Sets the file sets base directory. May be omitted, in which
-     * case the projects base directory is assumed.
+     * Sets the file sets base directory. May be omitted, in which case the projects base directory
+     * is assumed.
      */
-    public void setDirectory( File directory )
-    {
+    public void setDirectory(File directory) {
         this.directory = directory;
     }
 
-    /**
-     * Returns the file sets exclusion list.
-     */
-    public String[] getExcludes()
-    {
+    /** Returns the file sets exclusion list. */
+    public String[] getExcludes() {
         return excludes;
     }
 
-    /**
-     * Sets the file sets exclusion list.
-     */
-    public void setExcludes( String[] excludes )
-    {
+    /** Sets the file sets exclusion list. */
+    public void setExcludes(String[] excludes) {
         this.excludes = excludes;
     }
 
-    /**
-     * Returns the file sets inclusion list.
-     */
-    public String[] getIncludes()
-    {
+    /** Returns the file sets inclusion list. */
+    public String[] getIncludes() {
         return includes;
     }
 
-    /**
-     * Sets the file sets inclusion list.
-     */
-    public void setIncludes( String[] 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.
+     * Sets a prefix, which the included files should have when being added to the Axis application
+     * archive.
      */
-    public String getOutputDirectory()
-    {
+    public String getOutputDirectory() {
         return outputDirectory;
     }
 
     /**
-     * Returns a prefix, which the included files should have
-     * when being added to the Axis application archive.
+     * Returns a prefix, which the included files should have when being added to the Axis
+     * application archive.
      */
-    public void setOutputDirectory( String outputDirectory )
-    {
+    public void setOutputDirectory(String outputDirectory) {
         this.outputDirectory = outputDirectory;
     }
 
-    /**
-     * Returns, whether the default excludes should be used. Defaults
-     * to true.
-     */
-    public boolean isSkipDefaultExcludes()
-    {
+    /** 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 )
-    {
+    /** Sets, whether the default excludes should be used. Defaults to true. */
+    public void setSkipDefaultExcludes(boolean skipDefaultExcludes) {
         this.skipDefaultExcludes = skipDefaultExcludes;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org