You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2004/08/21 01:22:15 UTC

cvs commit: maven/src/test/java/org/apache/maven/plugin/maven.home/plugins/jar plugin.properties

brett       2004/08/20 16:22:15

  Modified:    src/java/org/apache/maven/jelly MavenJellyContext.java
               src/java/org/apache/maven/plugin PluginManager.java
               src/test/java/org/apache/maven MavenUtilsTest.java
               src/test/java/org/apache/maven/plugin PluginManagerTest.java
               src/test/java/org/apache/maven/plugin/maven.home/plugins/jar
                        plugin.properties
  Log:
  tests and bugfixes for jelly update
  
  Revision  Changes    Path
  1.41      +11 -2     maven/src/java/org/apache/maven/jelly/MavenJellyContext.java
  
  Index: MavenJellyContext.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/jelly/MavenJellyContext.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- MavenJellyContext.java	23 Jul 2004 04:40:05 -0000	1.40
  +++ MavenJellyContext.java	20 Aug 2004 23:22:14 -0000	1.41
  @@ -180,7 +180,16 @@
        */
       public Object getVariable( String name )
       {
  -        Object value = super.getVariable( name );
  +        Object value;
  +
  +        // We need to avoid calling getVariable() on a parent context so
  +        // that expressions are evaluated lazily
  +        if ( isInherit() ) {
  +            value = super.findVariable( name );
  +        }
  +        else {
  +            value = super.getVariable( name );
  +        }
   
           if ( value instanceof Expression )
           {
  
  
  
  1.78      +28 -11    maven/src/java/org/apache/maven/plugin/PluginManager.java
  
  Index: PluginManager.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/plugin/PluginManager.java,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- PluginManager.java	23 Jul 2004 04:40:06 -0000	1.77
  +++ PluginManager.java	20 Aug 2004 23:22:14 -0000	1.78
  @@ -393,13 +393,19 @@
       public void processDependencies( Project project )
               throws MalformedURLException, Exception
       {
  -        if ( project.getArtifacts() == null )
  +        if ( project.getArtifacts() == null || project.getArtifacts().isEmpty() )
           {
               log.debug( "No dependencies to process for project " + project.getName() );
               return;
           }
   
  -        ForeheadClassLoader projectClassLoader = ( ForeheadClassLoader ) project.getContext().getClassLoader();
  +        ClassLoader cl = project.getContext().getClassLoader();
  +        if ( !( cl instanceof ForeheadClassLoader ) )
  +        {
  +            return;
  +        }
  +
  +        ForeheadClassLoader projectClassLoader = ( ForeheadClassLoader ) cl;
           log.debug( "Processing dependencies for project " + project.getName() + "; classloader " + projectClassLoader );
   
           // add the dependencies to the classpath
  @@ -484,6 +490,18 @@
           return projectHousings;
       }
   
  +    MavenJellyContext setupBaseContext( Project project )
  +    {
  +        MavenJellyContext prevBaseContext = baseContext;
  +        baseContext = new MavenJellyContext( mavenSession.getRootContext() );
  +        baseContext.setInherit( true );
  +        JellyUtils.populateVariables( baseContext, project.getContext() );
  +        project.pushContext( baseContext );
  +        baseContext.setProject( project );
  +
  +        return prevBaseContext;
  +    }
  +
       /**
        * Attain the goals.
        *
  @@ -495,12 +513,7 @@
        */
       public void attainGoals( Project project, List goals ) throws Exception
       {
  -        MavenJellyContext prevBaseContext = baseContext;
  -        baseContext = new MavenJellyContext( mavenSession.getRootContext() );
  -        baseContext.setInherit( true );
  -        JellyUtils.populateVariables( baseContext, project.getContext() );
  -        project.pushContext( baseContext );
  -        baseContext.setProject( project );
  +        MavenJellyContext prevBaseContext = setupBaseContext( project );
   
           // Set up the ant project.
           // Before attempting to attain the goals verify the project
  @@ -959,8 +972,12 @@
               // TODO: should differentiate between plugins and script housings better
               jellyScriptHousing.getProject().verifyDependencies();
               processDependencies( jellyScriptHousing.getProject() );
  -            ForeheadClassLoader pluginClassLoader = ( ForeheadClassLoader ) jellyScriptHousing.getProject().getContext().getClassLoader();
  -            pluginClassLoader.addURL( jellyScriptHousing.getPluginDirectory().toURL() );
  +            ClassLoader cl = jellyScriptHousing.getProject().getContext().getClassLoader();
  +            if ( cl instanceof ForeheadClassLoader )
  +            {
  +                ForeheadClassLoader pluginClassLoader = ( ForeheadClassLoader ) cl;
  +                pluginClassLoader.addURL( jellyScriptHousing.getPluginDirectory().toURL() );
  +            }
           }
   
           MavenJellyContext context = jellyScriptHousing.getProject().getContext();
  
  
  
  1.18      +4 -4      maven/src/test/java/org/apache/maven/MavenUtilsTest.java
  
  Index: MavenUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/maven/src/test/java/org/apache/maven/MavenUtilsTest.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- MavenUtilsTest.java	28 Jun 2004 15:09:17 -0000	1.17
  +++ MavenUtilsTest.java	20 Aug 2004 23:22:15 -0000	1.18
  @@ -168,7 +168,7 @@
           Properties driverProperties = new Properties();
   
           // System properties
  -        systemProperties.setProperty( "maven.home", "/projects/maven" );
  +        systemProperties.setProperty( "maven.foo", "/projects/maven" );
   
           // User build properties
           userBuildProperties.setProperty( "maven.username", "jvanzyl" );
  @@ -186,7 +186,6 @@
           String basedir = "/home/jvanzyl/projects/maven";
   
           // Driver properties
  -        driverProperties.setProperty( "basedir", basedir );
           driverProperties.setProperty( "maven.build.src", "${basedir}/src" );
           driverProperties.setProperty( "maven.build.dir", "${basedir}/target" );
           driverProperties.setProperty( "maven.build.dest", "${maven.build.dir}/classes" );
  @@ -205,10 +204,11 @@
           } );
   
           MavenJellyContext context = new MavenJellyContext();
  +        context.setVariable( "basedir", basedir );
           MavenUtils.integrateMapInContext( result, context );
   
           // Values that should be taken from systemProperties.
  -        assertEquals( "/projects/maven", ( String ) context.getVariable( "maven.home" ) );
  +        assertEquals( "/projects/maven", ( String ) context.getVariable( "maven.foo" ) );
   
           // Values that should be taken from userBuildProperties.
           assertEquals( "/opt/maven/repository", ( String ) context.getVariable( "maven.repo.local" ) );
  
  
  
  1.15      +29 -7     maven/src/test/java/org/apache/maven/plugin/PluginManagerTest.java
  
  Index: PluginManagerTest.java
  ===================================================================
  RCS file: /home/cvs/maven/src/test/java/org/apache/maven/plugin/PluginManagerTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PluginManagerTest.java	28 Jun 2004 15:09:17 -0000	1.14
  +++ PluginManagerTest.java	20 Aug 2004 23:22:15 -0000	1.15
  @@ -46,8 +46,11 @@
       /** directory for fake data */
       private static final String FAKE_BASE = "/target/PluginManagerTest/";
   
  +    private static String FS = File.separator;
  +
       /** source base */
  -    private static final String SOURCE_BASE = "/src/test/java/org/apache/maven/plugin/";
  +    private static final String SOURCE_BASE = FS + "src" + FS + "test" + FS + "java" + FS + "org" + FS
  +        + "apache" + FS + "maven" + FS + "plugin" + FS;
   
       /** base directory */
       private String basedir;
  @@ -72,16 +75,16 @@
       {
           super.setUp();
   
  -        MavenJellyContext context = MavenUtils.createContext( new File( System.getProperty("user.dir") ) );
  -        assertNotNull(context);
  -
  -        basedir = System.getProperty( "basedir" );
  +        basedir = System.getProperty("user.dir");
           assertNotNull( basedir );
  -
  +        
           // 1) need to fake out maven home, so that the unpacked plugin dir in the test
           //    directory
           fakeHome = basedir + SOURCE_BASE + "maven.home";
  -        context.setVariable( MavenConstants.MAVEN_HOME, fakeHome );
  +        System.setProperty("maven.home", fakeHome);
  +        
  +        MavenJellyContext context = MavenUtils.createContext( new File( basedir ) );
  +        assertNotNull(context);
   
           // 2) need to fake out maven home local
           String fakeHomeLocal = basedir + FAKE_BASE + "maven.home.local";
  @@ -107,6 +110,7 @@
   
           project = MavenUtils.getProject(projectFile, context);
           assertNotNull(project);
  +
           pluginManager = mavenSession.getPluginManager();
       }
   
  @@ -241,6 +245,24 @@
   
           assertTrue( "check extracted jar plugin is loaded",
               pluginManager.getGoalNames().contains( "jar:jar" ) );
  +    }
  +
  +    /**
  +     * Test plugin property substitution.
  +     */
  +    public void testPluginPropertySubstitution() throws Exception
  +    {
  +        assertNotNull(pluginManager);
  +        pluginManager.initialize();
  +        pluginManager.setupBaseContext( project );
  +
  +        MavenJellyContext context = pluginManager.getPluginContext( "maven-jar-plugin" );
  +        assertNotNull( "check context exists", context );
  +
  +        assertEquals( "check plugin.resources", fakeHome + FS + "plugins" + FS + "jar" + FS + "plugin-resources",
  +            ( (File) context.getVariable( "plugin.resources" ) ).getAbsolutePath() );
  +        assertEquals( "check plugin property", fakeHome + FS + "plugins" + FS + "jar" + FS + 
  +            "plugin-resources/foo.bar", context.getVariable( "maven.jar.foo" ) );
       }
   }
   
  
  
  
  1.4       +2 -1      maven/src/test/java/org/apache/maven/plugin/maven.home/plugins/jar/plugin.properties
  
  Index: plugin.properties
  ===================================================================
  RCS file: /home/cvs/maven/src/test/java/org/apache/maven/plugin/maven.home/plugins/jar/plugin.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- plugin.properties	23 Mar 2004 02:18:25 -0000	1.3
  +++ plugin.properties	20 Aug 2004 23:22:15 -0000	1.4
  @@ -21,4 +21,5 @@
   maven.jar.excludes = **/package.html
   maven.jar.index=false
   maven.jar.compress=true
  -maven.remote.group=maven
  \ No newline at end of file
  +maven.remote.group=maven
  +maven.jar.foo=${plugin.resources}/foo.bar
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org