You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by jd...@apache.org on 2005/03/10 22:36:58 UTC

cvs commit: maven-components/maven-core-it/it0016 pom.xml

jdcasey     2005/03/10 13:36:58

  Modified:    .        .cvsignore
               maven-core-it/it0017 pom.xml
               maven-core/src/main/java/org/apache/maven/plugin
                        DefaultPluginManager.java
               maven-core-it/it0007 expected-results.txt pom.xml
               maven-core/src/main/java/org/apache/maven/artifact/repository/authentication
                        MavenAuthenticationInfoProvider.java
               maven-core/src/main/resources/org/apache/maven/project
                        pom-4.0.0.xml
               maven-core-it/it0008 pom.xml
               maven-core-it/it0016 pom.xml
  Added:       maven-core-it/it0016/src/main/webapp/WEB-INF .cvsignore
               maven-core/src/main/java/org/apache/maven/plugin
                        PluginVersionNotConfiguredException.java
  Log:
  o Added plugin version management/enforcement through the POM's build section.
  
  Revision  Changes    Path
  1.12      +1 -0      maven-components/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/maven-components/.cvsignore,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- .cvsignore	10 Mar 2005 01:35:24 -0000	1.11
  +++ .cvsignore	10 Mar 2005 21:36:57 -0000	1.12
  @@ -12,3 +12,4 @@
   *.iml
   *.iws
   *.ipr
  +log.txt
  
  
  
  1.2       +10 -0     maven-components/maven-core-it/it0017/pom.xml
  
  Index: pom.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core-it/it0017/pom.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- pom.xml	10 Mar 2005 17:14:39 -0000	1.1
  +++ pom.xml	10 Mar 2005 21:36:57 -0000	1.2
  @@ -4,4 +4,14 @@
     <artifactId>maven-core-it0017</artifactId>
     <packaging>ejb</packaging>
     <version>1.0</version>
  +
  +  <build>
  +    <plugins>
  +      <plugin>
  +        <groupId>maven</groupId>
  +        <artifactId>maven-ejb-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
  +      </plugin>
  +    </plugins>
  +  </build>
   </model>
  \ No newline at end of file
  
  
  
  1.1                  maven-components/maven-core-it/it0016/src/main/webapp/WEB-INF/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  classes
  
  
  
  1.46      +60 -26    maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
  
  Index: DefaultPluginManager.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- DefaultPluginManager.java	10 Mar 2005 01:35:14 -0000	1.45
  +++ DefaultPluginManager.java	10 Mar 2005 21:36:57 -0000	1.46
  @@ -48,6 +48,7 @@
   import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
   import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
   import org.codehaus.plexus.util.CollectionUtils;
  +import org.codehaus.plexus.util.StringUtils;
   import org.codehaus.plexus.util.dag.CycleDetectedException;
   
   import java.util.ArrayList;
  @@ -123,8 +124,7 @@
   
       private Set pluginsInProcess = new HashSet();
   
  -    public void processPluginDescriptor( MavenPluginDescriptor mavenPluginDescriptor )
  -        throws CycleDetectedException
  +    public void processPluginDescriptor( MavenPluginDescriptor mavenPluginDescriptor ) throws CycleDetectedException
       {
           if ( pluginsInProcess.contains( mavenPluginDescriptor.getPluginId() ) )
           {
  @@ -193,8 +193,7 @@
       }
   
       // TODO: don't throw Exception
  -    public void verifyPluginForGoal( String goalName, MavenSession session )
  -        throws Exception
  +    public void verifyPluginForGoal( String goalName, MavenSession session ) throws Exception
       {
           String pluginId = getPluginId( goalName );
   
  @@ -203,20 +202,53 @@
       }
   
       // TODO: don't throw Exception
  -    public void verifyPlugin( String groupId, String artifactId, MavenSession session )
  -        throws Exception
  +    public void verifyPlugin( String groupId, String artifactId, MavenSession session ) throws Exception
       {
           if ( !isPluginInstalled( groupId, artifactId ) )
           {
               //!! This is entirely crappy. We need a better naming for plugin
               // artifact ids and
  -            //   we definitely need better version extraction support.
  -
  -            String version = "1.0-SNAPSHOT";
   
               ArtifactFactory artifactFactory = null;
               try
               {
  +                MavenProject project = session.getProject();
  +
  +                List projectPlugins = project.getPlugins();
  +
  +                org.apache.maven.model.Plugin pluginConfig = null;
  +
  +                for ( Iterator it = project.getPlugins().iterator(); it.hasNext(); )
  +                {
  +                    org.apache.maven.model.Plugin plugin = (org.apache.maven.model.Plugin) it.next();
  +
  +                    if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals( plugin.getArtifactId() ) )
  +                    {
  +                        pluginConfig = plugin;
  +                        break;
  +                    }
  +                }
  +
  +                String version = null;
  +
  +                if ( pluginConfig != null )
  +                {
  +                    if ( StringUtils.isEmpty( pluginConfig.getVersion() ) )
  +                    {
  +                        throw new PluginVersionNotConfiguredException( groupId, artifactId );
  +                    }
  +                    else
  +                    {
  +                        version = pluginConfig.getVersion();
  +                    }
  +                }
  +
  +                // TODO: Default over to a sensible value (is 1.0-SNAPSHOT right?)
  +                if ( StringUtils.isEmpty( version ) )
  +                {
  +                    version = "1.0-SNAPSHOT";
  +                }
  +
                   artifactFactory = (ArtifactFactory) container.lookup( ArtifactFactory.ROLE );
   
                   Artifact pluginArtifact = artifactFactory.createArtifact( "maven", artifactId, version, null, "plugin",
  @@ -235,8 +267,7 @@
       }
   
       // TODO: don't throw Exception
  -    protected void addPlugin( Artifact pluginArtifact, MavenSession session )
  -        throws Exception
  +    protected void addPlugin( Artifact pluginArtifact, MavenSession session ) throws Exception
       {
           ArtifactResolver artifactResolver = null;
           MavenProjectBuilder mavenProjectBuilder = null;
  @@ -271,8 +302,7 @@
       // Plugin execution
       // ----------------------------------------------------------------------
   
  -    public PluginExecutionResponse executeMojo( MavenSession session, String goalName )
  -        throws GoalExecutionException
  +    public PluginExecutionResponse executeMojo( MavenSession session, String goalName ) throws GoalExecutionException
       {
           try
           {
  @@ -386,8 +416,7 @@
       }
   
       // TODO: don't throw Exception
  -    private void releaseComponents( MojoDescriptor goal, PluginExecutionRequest request )
  -        throws Exception
  +    private void releaseComponents( MojoDescriptor goal, PluginExecutionRequest request ) throws Exception
       {
           if ( request != null && request.getParameters() != null )
           {
  @@ -413,8 +442,7 @@
       // Mojo Parameter Handling
       // ----------------------------------------------------------------------
   
  -    public static Map createParameters( MojoDescriptor goal, MavenSession session )
  -        throws PluginConfigurationException
  +    public static Map createParameters( MojoDescriptor goal, MavenSession session ) throws PluginConfigurationException
       {
           Map map = null;
   
  @@ -508,8 +536,8 @@
       {
           StringBuffer message = new StringBuffer();
   
  -        message.append( "The '" + parameter.getName() ).append( "' parameter is required for the execution of the " ).append(
  -            mojo.getId() ).append( " mojo and cannot be null." );
  +        message.append( "The '" + parameter.getName() ).append( "' parameter is required for the execution of the " )
  +               .append( mojo.getId() ).append( " mojo and cannot be null." );
   
           return message.toString();
       }
  @@ -518,8 +546,7 @@
       // Lifecycle
       // ----------------------------------------------------------------------
   
  -    public void contextualize( Context context )
  -        throws ContextException
  +    public void contextualize( Context context ) throws ContextException
       {
           container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
       }
  @@ -527,10 +554,17 @@
       public void initialize()
       {
           // TODO: configure this from bootstrap or scan lib
  -        artifactFilter = new ExclusionSetFilter( new String[]{"maven-core", "maven-artifact", "maven-model",
  -                                                              "maven-monitor", "maven-plugin", "plexus-container-api",
  -                                                              "plexus-container-default", "plexus-artifact-container",
  -                                                              "wagon-provider-api", "classworlds"} );
  +        artifactFilter = new ExclusionSetFilter( new String[] {
  +            "maven-core",
  +            "maven-artifact",
  +            "maven-model",
  +            "maven-monitor",
  +            "maven-plugin",
  +            "plexus-container-api",
  +            "plexus-container-default",
  +            "plexus-artifact-container",
  +            "wagon-provider-api",
  +            "classworlds" } );
   
           // TODO: move this to be configurable from the Maven component
           remotePluginRepositories = new ArrayList();
  @@ -544,7 +578,7 @@
       // ----------------------------------------------------------------------
   
       private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver,
  -                                                MavenProjectBuilder mavenProjectBuilder )
  +                                               MavenProjectBuilder mavenProjectBuilder )
           throws ArtifactResolutionException
       {
           MavenProject project = context.getProject();
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginVersionNotConfiguredException.java
  
  Index: PluginVersionNotConfiguredException.java
  ===================================================================
  package org.apache.maven.plugin;
  
  /* ====================================================================
   *   Copyright 2001-2004 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.
   * ====================================================================
   */
  
  /**
   * @author jdcasey
   */
  public class PluginVersionNotConfiguredException
      extends Exception
  {
  
      private final String groupId;
  
      private final String artifactId;
  
      public PluginVersionNotConfiguredException( String groupId, String artifactId )
      {
          super( "The maven plugin with groupId: \'" + groupId + "\' and artifactId: \'" + artifactId
              + "\' which was configured for use in this project does not have a version associated with it." );
  
          this.groupId = groupId;
  
          this.artifactId = artifactId;
      }
  
      public String getGroupId()
      {
          return groupId;
      }
  
      public String getArtifactId()
      {
          return artifactId;
      }
  
  }
  
  
  1.4       +1 -1      maven-components/maven-core-it/it0007/expected-results.txt
  
  Index: expected-results.txt
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core-it/it0007/expected-results.txt,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- expected-results.txt	2 Sep 2004 12:34:18 -0000	1.3
  +++ expected-results.txt	10 Mar 2005 21:36:57 -0000	1.4
  @@ -2,4 +2,4 @@
   target/test-classes/org/apache/maven/it0007/PersonTest.class
   target/maven-core-it0007-1.0.jar
   target/maven-core-it0007-1.0.jar!/it0007.properties
  -${localRepository}/maven/poms/maven-it-support-parent-1.0.pom
  +${localRepository}/maven/poms/maven-it-support-1.0.pom
  
  
  
  1.4       +2 -2      maven-components/maven-core-it/it0007/pom.xml
  
  Index: pom.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core-it/it0007/pom.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- pom.xml	10 Mar 2005 01:35:22 -0000	1.3
  +++ pom.xml	10 Mar 2005 21:36:57 -0000	1.4
  @@ -1,6 +1,6 @@
   <model>
     <parent>
  -    <artifactId>maven-it-support-parent</artifactId>
  +    <artifactId>maven-it-support</artifactId>
       <groupId>maven</groupId>
       <version>1.0</version>
     </parent>
  @@ -18,4 +18,4 @@
         <scope>test</scope>
       </dependency>
     </dependencies>
  -</model>
  \ No newline at end of file
  +</model>
  
  
  
  1.2       +15 -10    maven-components/maven-core/src/main/java/org/apache/maven/artifact/repository/authentication/MavenAuthenticationInfoProvider.java
  
  Index: MavenAuthenticationInfoProvider.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/artifact/repository/authentication/MavenAuthenticationInfoProvider.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MavenAuthenticationInfoProvider.java	9 Mar 2005 05:48:30 -0000	1.1
  +++ MavenAuthenticationInfoProvider.java	10 Mar 2005 21:36:57 -0000	1.2
  @@ -5,6 +5,7 @@
   import org.apache.maven.util.UserModelUtils;
   import org.apache.maven.wagon.authentication.AuthenticationInfo;
   import org.apache.maven.wagon.repository.Repository;
  +import org.codehaus.plexus.util.StringUtils;
   
   /**
    * @author jdcasey
  @@ -17,18 +18,22 @@
       {
           UserModel userModel = UserModelUtils.getUserModel();
   
  -        ServerProfile serverProfile = UserModelUtils.getServerProfile( userModel, repo.getId() );
  -
  -        AuthenticationInfo info = new AuthenticationInfo();
  -        if ( serverProfile != null )
  +        String repoId = repo.getId();
  +        if ( !StringUtils.isEmpty( repoId ) )
           {
  -            info.setUserName( serverProfile.getUsername() );
  -            info.setPassword( serverProfile.getPassword() );
  -            info.setPrivateKey( serverProfile.getPrivateKey() );
  -            info.setPassphrase( serverProfile.getPassphrase() );
  -        }
  +            ServerProfile serverProfile = UserModelUtils.getServerProfile( userModel, repo.getId() );
   
  -        repo.setAuthenticationInfo( info );
  +            AuthenticationInfo info = new AuthenticationInfo();
  +            if ( serverProfile != null )
  +            {
  +                info.setUserName( serverProfile.getUsername() );
  +                info.setPassword( serverProfile.getPassword() );
  +                info.setPrivateKey( serverProfile.getPrivateKey() );
  +                info.setPassphrase( serverProfile.getPassphrase() );
  +            }
  +
  +            repo.setAuthenticationInfo( info );
  +        }
       }
   
   }
  \ No newline at end of file
  
  
  
  1.7       +49 -1     maven-components/maven-core/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
  
  Index: pom-4.0.0.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/resources/org/apache/maven/project/pom-4.0.0.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- pom-4.0.0.xml	10 Mar 2005 01:35:14 -0000	1.6
  +++ pom-4.0.0.xml	10 Mar 2005 21:36:57 -0000	1.7
  @@ -4,7 +4,7 @@
   
     <repositories>
       <repository>
  -      <id>central</id>
  +      <artifactId>central</artifactId>
         <name>Maven Repository Switchboard</name>
         <url>http://repo1.maven.org</url>
       </repository>
  @@ -29,6 +29,54 @@
           <directory>src/test/resources</directory>
         </testResource>
       </testResources>
  +    <!-- Default plugins -->
  +    <plugins>
  +      <plugin>
  +        <groupId>maven</groupId>
  +        <artifactId>maven-compiler-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
  +      </plugin>
  +      <plugin>
  +        <groupId>maven</groupId>
  +        <artifactId>maven-resources-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
  +      </plugin>
  +      <plugin>
  +        <groupId>maven</groupId>
  +        <artifactId>maven-jar-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
  +      </plugin>
  +      <plugin>
  +        <groupId>maven</groupId>
  +        <artifactId>maven-surefire-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
  +      </plugin>
  +      <plugin>
  +        <groupId>maven</groupId>
  +        <artifactId>maven-clean-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
  +      </plugin>
  +      <plugin>
  +        <groupId>maven</groupId>
  +        <artifactId>maven-deploy-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
  +      </plugin>
  +      <plugin>
  +        <groupId>maven</groupId>
  +        <artifactId>maven-install-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
  +      </plugin>
  +      <plugin>
  +        <groupId>maven</groupId>
  +        <artifactId>maven-pom-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
  +      </plugin>
  +      <plugin>
  +        <groupId>maven</groupId>
  +        <artifactId>maven-plugin-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
  +      </plugin>
  +    </plugins>
     </build>
   </project>
   
  
  
  
  1.6       +2 -1      maven-components/maven-core-it/it0008/pom.xml
  
  Index: pom.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core-it/it0008/pom.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- pom.xml	10 Mar 2005 01:35:22 -0000	1.5
  +++ pom.xml	10 Mar 2005 21:36:58 -0000	1.6
  @@ -18,7 +18,8 @@
         <plugin>
           <groupId>maven</groupId>
           <artifactId>maven-core-it-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
         </plugin>
       </plugins>
     </build>
  -</model>
  \ No newline at end of file
  +</model>
  
  
  
  1.4       +10 -0     maven-components/maven-core-it/it0016/pom.xml
  
  Index: pom.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core-it/it0016/pom.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- pom.xml	10 Mar 2005 01:35:23 -0000	1.3
  +++ pom.xml	10 Mar 2005 21:36:58 -0000	1.4
  @@ -4,4 +4,14 @@
     <artifactId>maven-core-it0016</artifactId>
     <packaging>war</packaging>
     <version>1.0</version>
  +  
  +  <build>
  +    <plugins>
  +      <plugin>
  +        <groupId>maven</groupId>
  +        <artifactId>maven-war-plugin</artifactId>
  +        <version>1.0-SNAPSHOT</version>
  +      </plugin>
  +    </plugins>
  +  </build>
   </model>
  \ No newline at end of file