maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/verifier ProjectVerifier.java
Date Wed, 04 Dec 2002 07:01:16 GMT
jvanzyl     2002/12/03 23:01:16

  Modified:    src/java/org/apache/maven AbstractMavenComponent.java
                        CreateDependencyClasspath.java
               src/java/org/apache/maven/jelly MavenJellyContext.java
               src/java/org/apache/maven/plugin PluginManager.java
               src/java/org/apache/maven/repository AbstractArtifact.java
                        DefaultJarArtifact.java
               src/java/org/apache/maven/verifier ProjectVerifier.java
  Log:
  o refactoring
  
  Revision  Changes    Path
  1.3       +2 -2      jakarta-turbine-maven/src/java/org/apache/maven/AbstractMavenComponent.java
  
  Index: AbstractMavenComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/AbstractMavenComponent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractMavenComponent.java	3 Dec 2002 02:50:57 -0000	1.2
  +++ AbstractMavenComponent.java	4 Dec 2002 07:01:15 -0000	1.3
  @@ -72,7 +72,7 @@
       // ------------------------------------------------------------
   
       /** Jelly conext. */
  -    protected MavenJellyContext context;
  +    private MavenJellyContext context;
   
       // ------------------------------------------------------------
       // C O N S T R U C T O R S
  
  
  
  1.22      +9 -20     jakarta-turbine-maven/src/java/org/apache/maven/CreateDependencyClasspath.java
  
  Index: CreateDependencyClasspath.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/CreateDependencyClasspath.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- CreateDependencyClasspath.java	2 Dec 2002 07:33:57 -0000	1.21
  +++ CreateDependencyClasspath.java	4 Dec 2002 07:01:15 -0000	1.22
  @@ -59,7 +59,6 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.maven.project.Dependency;
  -import org.apache.maven.project.Project;
   import org.apache.maven.repository.Artifact;
   import org.apache.maven.repository.DefaultArtifactFactory;
   import org.apache.tools.ant.types.Path;
  @@ -130,18 +129,9 @@
       public void execute()
           throws Exception
       {
  -
           try
           {
  -
  -            // If a maven project hasn't been set explicity then use the one
  -            // in the jelly context.
  -            if ( getContext().getProject() == null )
  -            {
  -                getContext().setProject( (Project) context.getVariable( MavenConstants.MAVEN_POM
) );
  -            }
  -
  -            Object b = context.getVariable( MavenConstants.JAR_OVERRIDE );
  +            Object b = getContext().getVariable( MavenConstants.JAR_OVERRIDE );
               boolean mavenJarOverride = ( ( b != null )
                                            &&
                                            ( b instanceof Boolean )
  @@ -149,15 +139,14 @@
                                            ( ( (Boolean) b ).booleanValue() ) );
   
               String mavenRepoLocal =
  -                (String) context.getVariable( MavenConstants.REPO_LOCAL );
  +                (String) getContext().getVariable( MavenConstants.REPO_LOCAL );
   
               org.apache.tools.ant.Project antProject = (org.apache.tools.ant.Project)
  -                context.getVariable( MavenConstants.MAVEN_ANT_PROJECT );
  +                getContext().getVariable( MavenConstants.MAVEN_ANT_PROJECT );
   
               Path classpath = new Path( antProject );
   
  -            for ( Iterator i = getContext().getProject().getDependencies().iterator();
  -                  i.hasNext(); )
  +            for ( Iterator i = getContext().getProject().getDependencies().iterator();
i.hasNext(); )
               {
                   Dependency d = (Dependency) i.next();
   
  @@ -168,13 +157,15 @@
                   }
   
                   String mavenJarProperty = (String)
  -                    context.getVariable( MavenConstants.JAR_OVERRIDE_PROPERTY + d.getId()
);
  +                    getContext().getVariable( MavenConstants.JAR_OVERRIDE_PROPERTY + d.getId()
);
   
                   Path path = new Path( antProject );
   
                   if ( mavenJarOverride
  -                    && ( mavenJarProperty != null )
  -                    && ( mavenJarProperty.length() > 0 ) )
  +                      &&
  +                     mavenJarProperty != null
  +                      &&
  +                     mavenJarProperty.length() > 0 )
                   {
                       // The jar override option has been set and we have a property
                       // for the this dependency so override the path with the user
  @@ -204,7 +195,5 @@
               e.printStackTrace();
               throw e;
           }
  -
  -
       }
   }
  
  
  
  1.14      +31 -1     jakarta-turbine-maven/src/java/org/apache/maven/jelly/MavenJellyContext.java
  
  Index: MavenJellyContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/MavenJellyContext.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- MavenJellyContext.java	2 Dec 2002 03:15:08 -0000	1.13
  +++ MavenJellyContext.java	4 Dec 2002 07:01:15 -0000	1.14
  @@ -632,6 +632,26 @@
       }
   
       /**
  +     * Set flag indicating if the remote repository is enabled for use.
  +     *
  +     * @param remoteRepositoryEnabled Remote repository usage flag.
  +     */
  +    public void setRemoteRepositoryEnabled( Boolean remoteRepositoryEnabled )
  +    {
  +        setVariable( MavenConstants.REPO_REMOTE_ENABLED, remoteRepositoryEnabled );
  +    }
  +
  +    /**
  +     * Set flag indicating if the remote repository is enabled for use.
  +     *
  +     * @return Remote repository usage flag.
  +     */
  +    public Boolean getRemoteRepositoryEnabled()
  +    {
  +        return getBoolean( MavenConstants.REPO_REMOTE_ENABLED );
  +    }
  +
  +    /**
        * Set the maven bean.
        *
        * @param maven The maven bean.
  @@ -709,5 +729,15 @@
       public File getDescriptorFile()
       {
           return (File) getVariable( MavenConstants.DESCRIPTOR_FILE );
  +    }
  +
  +    /**
  +     * Get Maven home.
  +     *
  +     * @return Maven home.
  +     */
  +    public String getMavenHome()
  +    {
  +        return (String) getVariable( MavenConstants.MAVEN_HOME );
       }
   }
  
  
  
  1.10      +10 -23    jakarta-turbine-maven/src/java/org/apache/maven/plugin/PluginManager.java
  
  Index: PluginManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/plugin/PluginManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PluginManager.java	2 Dec 2002 07:31:43 -0000	1.9
  +++ PluginManager.java	4 Dec 2002 07:01:15 -0000	1.10
  @@ -167,7 +167,7 @@
       public void initialize()
           throws Exception
       {
  -        setPluginsDir( new File( (String) context.getVariable( MavenConstants.HOME ), "plugins"
) );
  +        setPluginsDir( new File( getContext().getMavenHome(), "plugins" ) );
   
           loadCache();
   
  @@ -377,12 +377,7 @@
        */
       void cachePlugin( final String name ) throws Exception
       {
  -        MavenJellyContext context = getContext();
  -
  -        com.werken.werkz.Project werkzProject
  -            = (com.werken.werkz.Project) context.getVariable( MavenConstants.WERKZ_PROJECT
);
  -
  -        Set originalGoals = new HashSet( werkzProject.getGoals() );
  +        Set originalGoals = new HashSet( getContext().getWerkzProject().getGoals() );
   
           Set origPreCallbacks = new HashSet();
           Set origPostCallbacks = new HashSet();
  @@ -411,7 +406,7 @@
               e.printStackTrace();
           }
   
  -        Set currentGoals = new HashSet( werkzProject.getGoals() );
  +        Set currentGoals = new HashSet( getContext().getWerkzProject().getGoals() );
   
           currentGoals.removeAll( originalGoals );
   
  @@ -464,7 +459,7 @@
               }
           }
   
  -        for ( Iterator i = werkzProject.getGoals().iterator(); i.hasNext(); )
  +        for ( Iterator i = getContext().getWerkzProject().getGoals().iterator(); i.hasNext();
)
           {
               Goal eachGoal = (Goal) i.next();
   
  @@ -527,12 +522,7 @@
       public void loadProjectBuildFile( File projectBuildFile )
           throws Exception
       {
  -        MavenJellyContext context = getContext();
  -
  -        com.werken.werkz.Project werkzProject
  -            = (com.werken.werkz.Project) context.getVariable( MavenConstants.WERKZ_PROJECT
);
  -
  -        Set originalGoals = new HashSet( werkzProject.getGoals() );
  +        Set originalGoals = new HashSet( getContext().getWerkzProject().getGoals() );
   
           for ( Iterator i = originalGoals.iterator(); i.hasNext(); )
           {
  @@ -554,7 +544,7 @@
                                 pluginJellyContext,
                                 getContext().getXMLOutput() );
   
  -        Set currentGoals = new HashSet( werkzProject.getGoals() );
  +        Set currentGoals = new HashSet( getContext().getWerkzProject().getGoals() );
   
           currentGoals.removeAll( originalGoals );
   
  @@ -925,12 +915,8 @@
               if ( classloader != null
                   && ( dependency.isCompileType() || dependency.isTestType() ) )
               {
  -                Artifact artifact = DefaultArtifactFactory.createArtifact(
  -                    dependency );
  -
  -                String localRepo = (String) getContext()
  -                    .getVariable( MavenConstants.REPO_LOCAL );
  -
  +                Artifact artifact = DefaultArtifactFactory.createArtifact( dependency );
  +                String localRepo = getContext().getMavenRepoLocal();
                   File jarFile = new File( localRepo, artifact.getPath() );
   
                   if ( log.isDebugEnabled() )
  @@ -963,6 +949,7 @@
           MavenJellyContext pluginJellyContext = new MavenJellyContext( getContext() );
           pluginJellyContext.setInherit( true );
           pluginJellyContext.setVariable( "plugin.dir", getPluginDir( name ) );
  +        //pluginJellyContext.setProject( pluginProject );
   
           pluginJellyContext.addLazyTagLibraries( this.taglibsCache.keySet() );
   
  
  
  
  1.9       +30 -1     jakarta-turbine-maven/src/java/org/apache/maven/repository/AbstractArtifact.java
  
  Index: AbstractArtifact.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/repository/AbstractArtifact.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractArtifact.java	3 Dec 2002 06:33:47 -0000	1.8
  +++ AbstractArtifact.java	4 Dec 2002 07:01:15 -0000	1.9
  @@ -1,5 +1,7 @@
   package org.apache.maven.repository;
   
  +import org.apache.maven.project.Dependency;
  +
   import java.io.File;
   
   /* ====================================================================
  @@ -58,6 +60,8 @@
    * ====================================================================
    */
   
  +import org.apache.maven.project.Dependency;
  +
   /**
    *
    * @author <a href="jason@zenplex.com">Jason van Zyl</a>
  @@ -66,6 +70,31 @@
   public abstract class AbstractArtifact
       implements Artifact
   {
  +    /** Platform specific file separator used for file system operations. */
  +    protected static final String ps = File.separator;
  +
  +    /** Dependency this artifact is based on. */
  +    private Dependency dependency;
  +    /**
  +     * Set the dependency for this JAR artifact.
  +     *
  +     * @param dependency Dependency this artifact is based on.
  +     */
  +    public void setDependency( Dependency dependency )
  +    {
  +        this.dependency = dependency;
  +    }
  +
  +    /**
  +     * Get the dependency.
  +     *
  +     * @return The dependency this artifact is based on.
  +     */
  +    public Dependency getDependency()
  +    {
  +        return dependency;
  +    }
  +
       /** @see Artifact#getPath */
       public abstract String getPath();
   
  
  
  
  1.10      +7 -33     jakarta-turbine-maven/src/java/org/apache/maven/repository/DefaultJarArtifact.java
  
  Index: DefaultJarArtifact.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/repository/DefaultJarArtifact.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultJarArtifact.java	3 Dec 2002 06:33:47 -0000	1.9
  +++ DefaultJarArtifact.java	4 Dec 2002 07:01:15 -0000	1.10
  @@ -75,42 +75,16 @@
       /** Log. */
       private static final Log log = LogFactory.getLog( DefaultJarArtifact.class );
   
  -    /** Platform specific file separator used for file system operations. */
  -    private static final String ps = File.separator;
  -
  -    /** Dependency this artifact is based on. */
  -    private Dependency dependency;
  -
  -    /**
  -     * Set the dependency for this JAR artifact.
  -     *
  -     * @param dependency Dependency this artifact is based on.
  -     */
  -    public void setDependency( Dependency dependency )
  -    {
  -        this.dependency = dependency;
  -    }
  -
  -    /**
  -     * Get the dependency.
  -     *
  -     * @return The dependency this artifact is based on.
  -     */
  -    public Dependency getDependency()
  -    {
  -        return dependency;
  -    }
  -
       /**
        * Get the path of the artifact using platform specific
        * naming conventions.
        *
  -     * @return Path to the dependency.
  +     * @return Path to the getDependency().
        */
       public String getPath()
       {
  -        String groupId = dependency.getGroupId();
  -        String artifact = dependency.getArtifact();
  +        String groupId = getDependency().getGroupId();
  +        String artifact = getDependency().getArtifact();
   
           log.debug( "artifact: " + artifact );
   
  @@ -124,8 +98,8 @@
        */
       public String getUrlPath()
       {
  -        String groupId = dependency.getGroupId();
  -        String artifact = dependency.getArtifact();
  +        String groupId = getDependency().getGroupId();
  +        String artifact = getDependency().getArtifact();
   
           log.debug( "artifact: " + artifact );
   
  @@ -139,7 +113,7 @@
        */
       public String getName()
       {
  -        return dependency.getArtifact();
  +        return getDependency().getArtifact();
       }
   
       /** @see Artifact#exists */
  
  
  
  1.10      +24 -18    jakarta-turbine-maven/src/java/org/apache/maven/verifier/ProjectVerifier.java
  
  Index: ProjectVerifier.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/verifier/ProjectVerifier.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ProjectVerifier.java	3 Dec 2002 06:33:47 -0000	1.9
  +++ ProjectVerifier.java	4 Dec 2002 07:01:15 -0000	1.10
  @@ -175,7 +175,7 @@
        */
       private void clearFailedDependencies()
       {
  -       for ( int i = 0; i < failedDependencies.size(); i++ )
  +        for ( int i = 0; i < failedDependencies.size(); i++ )
           {
               failedDependencies.remove( i );
           }
  @@ -189,16 +189,16 @@
       private void verifyDependencies()
           throws Exception
       {
  -        Boolean remoteRepoEnabled = context.getBoolean( MavenConstants.REPO_REMOTE_ENABLED
);
  +        Boolean remoteRepoEnabled = getContext().getRemoteRepositoryEnabled();
   
  -        if ( remoteRepoEnabled != null && !remoteRepoEnabled.booleanValue() )
  +        if ( remoteRepoEnabled != null && remoteRepoEnabled.booleanValue() == false
)
           {
  -            log.info( getMessage( "remote.repository.disabled.warning") );
  +            log.info( getMessage( "remote.repository.disabled.warning" ) );
           }
   
           clearFailedDependencies();
   
  -        File mavenRepoLocal = new File ( getContext().getMavenRepoLocal() );
  +        File mavenRepoLocal = new File( getContext().getMavenRepoLocal() );
   
           for ( Iterator i = getContext().getProject().getDependencies().iterator(); i.hasNext();
)
           {
  @@ -206,7 +206,7 @@
   
               Artifact artifact = DefaultArtifactFactory.createArtifact( dependency );
   
  -            if ( artifact.exists( mavenRepoLocal) == false )
  +            if ( artifact.exists( mavenRepoLocal ) == false )
               {
                   // The directory structure for this project may
                   // not exists so create it if missing.
  @@ -224,17 +224,7 @@
           // them for the user.
           if ( failedDependencies.size() > 0 )
           {
  -            for ( Iterator i = failedDependencies.iterator(); i.hasNext(); )
  -            {
  -                Artifact artifact = (Artifact) i.next();
  -                File destinationFile = new File( getContext().getMavenRepoLocal(), artifact.getPath()
);
  -                String artifactName = artifact.getName();
  -
  -                if ( getRemoteFile( artifact.getUrlPath(), destinationFile ) == false )
  -                {
  -                    warnings.append( getMessage( "failed.download.warning", artifactName
) ).append( "\n" );
  -                }
  -            }
  +            getDependencies();
           }
   
           if ( warnings.length() > 1 )
  @@ -242,6 +232,22 @@
               log.info( "\n" + warnings.toString() );
           }
       }
  +
  +    private void getDependencies()
  +    {
  +        for ( Iterator i = failedDependencies.iterator(); i.hasNext(); )
  +        {
  +            Artifact artifact = (Artifact) i.next();
  +            File destinationFile = new File( getContext().getMavenRepoLocal(), artifact.getPath()
);
  +            String artifactName = artifact.getName();
  +
  +            if ( getRemoteFile( artifact.getUrlPath(), destinationFile ) == false )
  +            {
  +                warnings.append( getMessage( "failed.download.warning", artifactName )
).append( "\n" );
  +            }
  +        }
  +    }
  +
   
       /**
        * Retrieve a <code>remoteFile</code> from the maven remote repositories
  
  
  

Mime
View raw message