maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb EjbMojo.java
Date Wed, 30 Mar 2005 08:14:52 GMT
brett       2005/03/30 00:14:52

  Modified:    maven-archiver/src/main/java/org/apache/maven/archiver
                        MavenArchiver.java
               maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war
                        WarMojo.java
               maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar
                        JarMojo.java
               maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb
                        EjbMojo.java
  Added:       maven-archiver/src/main/java/org/apache/maven/archiver
                        ManifestConfiguration.java
                        MavenArchiveConfiguration.java
  Log:
  change archiving plugins to use a shred archive configuration
  
  Revision  Changes    Path
  1.6       +23 -17    maven-components/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java
  
  Index: MavenArchiver.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MavenArchiver.java	22 Mar 2005 13:25:58 -0000	1.5
  +++ MavenArchiver.java	30 Mar 2005 08:14:52 -0000	1.6
  @@ -29,9 +29,9 @@
   import java.util.Set;
   
   /**
  - * @todo improve the use of this now that plugin fields are used instead of a request object
- add an <archive> element to configuration?
    * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
    * @version $Revision$ $Date$
  + * @todo improve the use of this now that plugin fields are used instead of a request object
- add an <archive> element to configuration?
    */
   public class MavenArchiver
   {
  @@ -44,8 +44,7 @@
        *
        * @todo Add user attributes list and user groups list
        */
  -    public Manifest getManifest( MavenProject project, String mainClass, String packageName,
boolean addClasspath,
  -                                 boolean addExtensions )
  +    public Manifest getManifest( MavenProject project, ManifestConfiguration config )
           throws ManifestException
       {
           // Added basic entries
  @@ -55,16 +54,16 @@
           Manifest.Attribute createdAttr = new Manifest.Attribute( "Created-By", "Apache
Maven" );
           m.addConfiguredAttribute( createdAttr );
   
  -        if ( packageName != null )
  +        if ( config.getPackageName() != null )
           {
  -            Manifest.Attribute packageAttr = new Manifest.Attribute( "Package", packageName
);
  +            Manifest.Attribute packageAttr = new Manifest.Attribute( "Package", config.getPackageName()
);
               m.addConfiguredAttribute( packageAttr );
           }
   
           Manifest.Attribute buildJdkAttr = new Manifest.Attribute( "Build-Jdk", System.getProperty(
"java.version" ) );
           m.addConfiguredAttribute( buildJdkAttr );
   
  -        if ( addClasspath )
  +        if ( config.isAddClasspath() )
           {
               StringBuffer classpath = new StringBuffer();
               Set artifacts = project.getArtifacts();
  @@ -118,6 +117,7 @@
                                                                                  project.getVersion()
);
           m.addConfiguredAttribute( implementationVersionAttr );
   
  +        String mainClass = config.getMainClass();
           if ( mainClass != null && !"".equals( mainClass ) )
           {
               Manifest.Attribute mainClassAttr = new Manifest.Attribute( "Main-Class", mainClass
);
  @@ -125,7 +125,7 @@
           }
   
           // Added extensions
  -        if ( addExtensions )
  +        if ( config.isAddExtensions() )
           {
               StringBuffer extensionsList = new StringBuffer();
               Set artifacts = project.getArtifacts();
  @@ -162,11 +162,15 @@
                       String name = artifact.getArtifactId() + "-Implementation-Version";
                       Manifest.Attribute archImplVersionAttr = new Manifest.Attribute( name,
artifact.getVersion() );
                       m.addConfiguredAttribute( archImplVersionAttr );
  -                    // TODO: make repo configurable
  -                    name = artifact.getArtifactId() + "-Implementation-URL";
  -                    String url = "http://www.ibiblio.org/maven/" + artifact.toString();
  -                    Manifest.Attribute archImplUrlAttr = new Manifest.Attribute( name,
url );
  -                    m.addConfiguredAttribute( archImplUrlAttr );
  +
  +                    if ( artifact.getRepository() != null )
  +                    {
  +                        // TODO: is this correct
  +                        name = artifact.getArtifactId() + "-Implementation-URL";
  +                        String url = artifact.getRepository().getUrl() + "/" + artifact.toString();
  +                        Manifest.Attribute archImplUrlAttr = new Manifest.Attribute( name,
url );
  +                        m.addConfiguredAttribute( archImplUrlAttr );
  +                    }
                   }
               }
           }
  @@ -189,8 +193,7 @@
           archiveFile = outputFile;
       }
   
  -    public void createArchive( MavenProject project, String manifestFile, boolean compress,
boolean index,
  -                               Manifest manifest )
  +    public void createArchive( MavenProject project, MavenArchiveConfiguration archiveConfiguration
)
           throws ArchiverException, ManifestException, IOException
       {
           // ----------------------------------------------------------------------
  @@ -199,16 +202,19 @@
   
           archiver.addFile( project.getFile(), "META-INF/maven/pom.xml" );
   
  +        String manifestFile = archiveConfiguration.getManifestFile();
           if ( manifestFile != null && !"".equals( manifestFile ) )
           {
               archiver.setManifest( new File( manifestFile ) );
           }
   
  +        Manifest manifest = getManifest( project, archiveConfiguration.getManifest() );
  +
           // Configure the jar
           archiver.addConfiguredManifest( manifest );
   
  -        archiver.setCompress( compress );
  -        archiver.setIndex( index );
  +        archiver.setCompress( archiveConfiguration.isCompress() );
  +        archiver.setIndex( archiveConfiguration.isIndex() );
           archiver.setDestFile( archiveFile );
   
           // create archive
  
  
  
  1.1                  maven-components/maven-archiver/src/main/java/org/apache/maven/archiver/ManifestConfiguration.java
  
  Index: ManifestConfiguration.java
  ===================================================================
  package org.apache.maven.archiver;
  
  /*
   * Copyright 2001-2005 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.
   */
  
  /**
   * Capture common manifest configuration.
   *
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   * @version $Id: ManifestConfiguration.java,v 1.1 2005/03/30 08:14:52 brett Exp $
   * @todo is this general enough to be in Plexus Archiver?
   */
  public class ManifestConfiguration
  {
      private String mainClass;
  
      private String packageName;
  
      /**
       * @todo boolean instead
       */
      private String addClasspath;
  
      /**
       * @todo boolean instead
       */
      private String addExtensions;
  
      public String getMainClass()
      {
          return mainClass;
      }
  
      public boolean isAddClasspath()
      {
          return addClasspath != null ? Boolean.valueOf( addClasspath ).booleanValue() : false;
      }
  
      public boolean isAddExtensions()
      {
          return addExtensions != null ? Boolean.valueOf( addExtensions ).booleanValue() :
false;
      }
  
      public String getPackageName()
      {
          return packageName;
      }
  }
  
  
  
  1.1                  maven-components/maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiveConfiguration.java
  
  Index: MavenArchiveConfiguration.java
  ===================================================================
  package org.apache.maven.archiver;
  
  /*
   * Copyright 2001-2005 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.
   */
  
  /**
   * Capture common archive configuration.
   *
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   * @version $Id: MavenArchiveConfiguration.java,v 1.1 2005/03/30 08:14:52 brett Exp $
   * @todo is this general enough to be in Plexus Archiver?
   */
  public class MavenArchiveConfiguration
  {
      /**
       * @todo boolean instead
       */
      private String compress;
  
      /**
       * @todo boolean instead
       */
      private String index;
  
      private String manifestFile;
  
      private ManifestConfiguration manifest;
  
      public boolean isCompress()
      {
          return compress != null ? Boolean.valueOf( compress ).booleanValue() : true;
      }
  
      public boolean isIndex()
      {
          return index != null ? Boolean.valueOf( index ).booleanValue() : false;
      }
  
      public String getManifestFile()
      {
          return manifestFile;
      }
  
      public ManifestConfiguration getManifest()
      {
          if ( manifest == null )
          {
              manifest = new ManifestConfiguration();
          }
          return manifest;
      }
  }
  
  
  
  1.12      +8 -67     maven-components/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
  
  Index: WarMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- WarMojo.java	22 Mar 2005 13:25:58 -0000	1.11
  +++ WarMojo.java	30 Mar 2005 08:14:52 -0000	1.12
  @@ -16,13 +16,13 @@
    * limitations under the License.
    */
   
  +import org.apache.maven.archiver.MavenArchiveConfiguration;
   import org.apache.maven.archiver.MavenArchiver;
   import org.apache.maven.artifact.Artifact;
   import org.apache.maven.plugin.AbstractPlugin;
   import org.apache.maven.plugin.PluginExecutionException;
   import org.apache.maven.project.MavenProject;
   import org.codehaus.plexus.archiver.ArchiverException;
  -import org.codehaus.plexus.archiver.jar.Manifest;
   import org.codehaus.plexus.archiver.jar.ManifestException;
   import org.codehaus.plexus.archiver.war.WarArchiver;
   import org.codehaus.plexus.util.FileUtils;
  @@ -44,38 +44,11 @@
    * validator=""
    * expression="#project.build.finalName"
    * description=""
  - * @parameter name="compress"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.jar.compress"
  - * default="true"
  - * description=""
  - * @parameter name="index"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.jar.index"
  - * default="false"
  - * description=""
  - * @parameter name="packageName"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.jar.package"
  - * description=""
  - * @parameter name="manifest"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.jar.manifest"
  - * description=""
  - * @parameter name="addExtensions"
  - * type="String"
  + * @parameter name="archive"
  + * type=""
    * required="false"
  + * expression=""
    * validator=""
  - * expression="#maven.jar.addExtensions"
  - * default="false"
    * description=""
    * @parameter name="warSourceDirectory"
    * type="String"
  @@ -183,31 +156,7 @@
   
       private String warName;
   
  -    private String mainClass;
  -
  -    private String packageName;
  -
  -    private String manifest;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String addClasspath;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String addExtensions;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String index;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String compress;
  +    private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
   
       public void copyResources( File sourceDirectory, File webappDirectory, String includes,
String excludes,
                                  String webXml )
  @@ -302,7 +251,7 @@
           catch ( Exception e )
           {
               // TODO: improve error handling
  -            throw new PluginExecutionException( "Error assembling EJB", e );
  +            throw new PluginExecutionException( "Error assembling WAR", e );
           }
       }
   
  @@ -335,17 +284,9 @@
                   warArchiver.setWebxml( new File( webappDirectory, "WEB-INF/web.xml" ) );
   
                   // create archive
  -                Manifest configuredManifest = archiver.getManifest( project, mainClass,
packageName,
  -                                                                    convertBoolean( addClasspath
),
  -                                                                    convertBoolean( addExtensions
) );
  -                archiver.createArchive( project, manifest, convertBoolean( compress ),
convertBoolean( index ),
  -                                        configuredManifest );
  +                archiver.createArchive( project, archive );
               }
           }
       }
   
  -    private static boolean convertBoolean( String s )
  -    {
  -        return Boolean.valueOf( s ).booleanValue();
  -    }
   }
  
  
  
  1.21      +7 -80     maven-components/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java
  
  Index: JarMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- JarMojo.java	29 Mar 2005 06:02:57 -0000	1.20
  +++ JarMojo.java	30 Mar 2005 08:14:52 -0000	1.21
  @@ -16,11 +16,11 @@
    * limitations under the License.
    */
   
  +import org.apache.maven.archiver.MavenArchiveConfiguration;
   import org.apache.maven.archiver.MavenArchiver;
   import org.apache.maven.plugin.AbstractPlugin;
   import org.apache.maven.plugin.PluginExecutionException;
   import org.apache.maven.project.MavenProject;
  -import org.codehaus.plexus.archiver.jar.Manifest;
   
   import java.io.File;
   
  @@ -36,51 +36,11 @@
    * validator=""
    * expression="#project.build.finalName"
    * description=""
  - * @parameter name="compress"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.jar.compress"
  - * default="true"
  - * description=""
  - * @parameter name="index"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.jar.index"
  - * default="false"
  - * description=""
  - * @parameter name="packageName"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.jar.package"
  - * description=""
  - * @parameter name="manifest"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.jar.manifest"
  - * description=""
  - * @parameter name="mainClass"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.jar.mainClass"
  - * description=""
  - * @parameter name="addClasspath"
  - * type="String"
  + * @parameter name="archive"
  + * type=""
    * required="false"
  + * expression=""
    * validator=""
  - * expression="#maven.jar.addClasspath"
  - * default="false"
  - * description=""
  - * @parameter name="addExtensions"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.jar.addExtensions"
  - * default="false"
    * description=""
    * @parameter name="outputDirectory"
    * type="String"
  @@ -119,31 +79,7 @@
   
       private MavenProject project;
   
  -    private String manifest;
  -
  -    private String mainClass;
  -
  -    private String packageName;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String addClasspath;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String addExtensions;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String index;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String compress;
  +    private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
   
       /**
        * @todo Add license files in META-INF directory.
  @@ -169,12 +105,7 @@
                   archiver.getArchiver().addDirectory( contentDirectory, DEFAULT_INCLUDES,
DEFAULT_EXCLUDES );
               }
   
  -            // create archive
  -            Manifest configuredManifest = archiver.getManifest( project, mainClass, packageName,
  -                                                                convertBoolean( addClasspath
),
  -                                                                convertBoolean( addExtensions
) );
  -            archiver.createArchive( project, manifest, convertBoolean( compress ), convertBoolean(
index ),
  -                                    configuredManifest );
  +            archiver.createArchive( project, archive );
           }
           catch ( Exception e )
           {
  @@ -183,8 +114,4 @@
           }
       }
   
  -    private static boolean convertBoolean( String s )
  -    {
  -        return Boolean.valueOf( s ).booleanValue();
  -    }
   }
  
  
  
  1.5       +9 -85     maven-components/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java
  
  Index: EjbMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EjbMojo.java	22 Mar 2005 13:25:58 -0000	1.4
  +++ EjbMojo.java	30 Mar 2005 08:14:52 -0000	1.5
  @@ -16,11 +16,11 @@
    * limitations under the License.
    */
   
  +import org.apache.maven.archiver.MavenArchiveConfiguration;
   import org.apache.maven.archiver.MavenArchiver;
   import org.apache.maven.plugin.AbstractPlugin;
   import org.apache.maven.plugin.PluginExecutionException;
   import org.apache.maven.project.MavenProject;
  -import org.codehaus.plexus.archiver.jar.Manifest;
   
   import java.io.File;
   
  @@ -36,51 +36,11 @@
    * validator=""
    * expression="#project.build.finalName"
    * description=""
  - * @parameter name="compress"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.ejb.compress"
  - * default="true"
  - * description=""
  - * @parameter name="index"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.ejb.index"
  - * default="false"
  - * description=""
  - * @parameter name="packageName"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.ejb.package"
  - * description=""
  - * @parameter name="manifest"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.ejb.manifest"
  - * description=""
  - * @parameter name="mainClass"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.ejb.mainClass"
  - * description=""
  - * @parameter name="addClasspath"
  - * type="String"
  - * required="false"
  - * validator=""
  - * expression="#maven.ejb.addClasspath"
  - * default="false"
  - * description=""
  - * @parameter name="addExtensions"
  - * type="String"
  + * @parameter name="archive"
  + * type=""
    * required="false"
  + * expression=""
    * validator=""
  - * expression="#maven.ejb.addExtensions"
  - * default="false"
    * description=""
    * @parameter name="generateClient"
    * type="String"
  @@ -133,31 +93,7 @@
   
       private MavenProject project;
   
  -    private String mainClass;
  -
  -    private String packageName;
  -
  -    private String manifest;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String addClasspath;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String addExtensions;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String index;
  -
  -    /**
  -     * @todo boolean instead
  -     */
  -    private String compress;
  +    private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
   
       /**
        * @todo Add license files in META-INF directory.
  @@ -183,13 +119,9 @@
               archiver.getArchiver().addFile( new File( outputDirectory, ejbJarXmlFile ),
ejbJarXmlFile );
   
               // create archive
  -            Manifest configuredManifest = archiver.getManifest( project, mainClass, packageName,
  -                                                                convertBoolean( addClasspath
),
  -                                                                convertBoolean( addExtensions
) );
  -            archiver.createArchive( project, manifest, convertBoolean( compress ), convertBoolean(
index ),
  -                                    configuredManifest );
  +            archiver.createArchive( project, archive );
   
  -            if ( convertBoolean( generateClient ) )
  +            if ( new Boolean( generateClient ).booleanValue() )
               {
                   getLog().info( "Building ejb client " + jarName + "-client" );
   
  @@ -203,11 +135,7 @@
                                                              DEFAULT_EXCLUDES );
   
                   // create archive
  -                configuredManifest =
  -                    clientArchiver.getManifest( project, mainClass, packageName, convertBoolean(
addClasspath ),
  -                                                convertBoolean( addExtensions ) );
  -                clientArchiver.createArchive( project, manifest, convertBoolean( compress
), convertBoolean( index ),
  -                                              configuredManifest );
  +                archiver.createArchive( project, archive );
               }
           }
           catch ( Exception e )
  @@ -217,8 +145,4 @@
           }
       }
   
  -    private static boolean convertBoolean( String s )
  -    {
  -        return new Boolean( s ).booleanValue();
  -    }
   }
  \ No newline at end of file
  
  
  

Mime
View raw message