You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2010/08/20 00:23:51 UTC

svn commit: r987334 - in /maven/core-integration-testing/trunk: core-it-suite/src/test/java/org/apache/maven/it/ core-it-suite/src/test/resources/mng-4765/ core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/co...

Author: bentmann
Date: Thu Aug 19 22:23:51 2010
New Revision: 987334

URL: http://svn.apache.org/viewvc?rev=987334&view=rev
Log:
[MNG-4765] Failing to determine java version for profile....

o Added IT

Added:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4765LocalPomProjectBuilderTest.java   (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/pom.xml   (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/test.xml   (with props)
    maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java   (with props)
Modified:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java

Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java?rev=987334&r1=987333&r2=987334&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java Thu Aug 19 22:23:51 2010
@@ -82,6 +82,7 @@ public class IntegrationTestSuite
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
 
         suite.addTestSuite( MavenITmng4768NearestMatchConflictResolutionTest.class );
+        suite.addTestSuite( MavenITmng4765LocalPomProjectBuilderTest.class );
         suite.addTestSuite( MavenITmng4750ResolvedMavenProjectDependencyArtifactsTest.class );
         suite.addTestSuite( MavenITmng4747JavaAgentUsedByPluginTest.class );
         // suite.addTestSuite( MavenITmng4745PluginVersionUpdateTest.class );

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4765LocalPomProjectBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4765LocalPomProjectBuilderTest.java?rev=987334&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4765LocalPomProjectBuilderTest.java (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4765LocalPomProjectBuilderTest.java Thu Aug 19 22:23:51 2010
@@ -0,0 +1,62 @@
+package org.apache.maven.it;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4765">MNG-4765</a>.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class MavenITmng4765LocalPomProjectBuilderTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    public MavenITmng4765LocalPomProjectBuilderTest()
+    {
+        super( "[2.0.3,3.0-alpha-1),[3.0-beta-3,)" );
+    }
+
+    /**
+     * Test that the 2.x project builder can be invoked directly by plugins and can access the session state.
+     */
+    public void testit()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4765" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteDirectory( "target" );
+        verifier.setSystemProperty( "user.prop", "OK" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        Properties props = verifier.loadProperties( "target/pom.properties" );
+        assertEquals( "PASSED - OK", props.get( "test.xml.project.name" ) );
+    }
+
+}

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4765LocalPomProjectBuilderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4765LocalPomProjectBuilderTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/pom.xml?rev=987334&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/pom.xml Thu Aug 19 22:23:51 2010
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng4765</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1</version>
+  <packaging>jar</packaging>
+
+  <name>Maven Integration Test :: MNG-4765</name>
+  <description>
+    Test that the 2.x project builder can be invoked directly by plugins and can access the session state.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-project</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>test</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>local-pom</goal>
+            </goals>
+            <configuration>
+              <files>
+                <file>test.xml</file>
+              </files>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/test.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/test.xml?rev=987334&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/test.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/test.xml Thu Aug 19 22:23:51 2010
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng4765</groupId>
+  <artifactId>it</artifactId>
+  <version>0.1</version>
+  <packaging>jar</packaging>
+
+  <name>${profile.prop} - ${user.prop}</name>
+
+  <profiles>
+    <profile>
+      <id>it</id>
+      <activation>
+        <!-- tests usage of system properties -->
+        <jdk>!1.2</jdk>
+      </activation>
+      <properties>
+        <profile.prop>PASSED</profile.prop>
+      </properties>
+    </profile>
+  </profiles>
+</project>

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4765/test.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java?rev=987334&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java Thu Aug 19 22:23:51 2010
@@ -0,0 +1,98 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * Builds the local POMs.
+ * 
+ * @goal local-pom
+ * @author Benjamin Bentmann
+ */
+public class BuildLocalPomMojo
+    extends AbstractPomMojo
+{
+
+    /**
+     * The properties file to dump the POM info to.
+     * 
+     * @parameter default-value="target/pom.properties"
+     */
+    private File propertiesFile;
+
+    /**
+     * The local repository.
+     * 
+     * @parameter default-value="${localRepository}"
+     * @readonly
+     * @required
+     */
+    private ArtifactRepository localRepository;
+
+    /**
+     * The POM files to build.
+     * 
+     * @parameter
+     */
+    private File[] files;
+
+    /**
+     * Runs this mojo.
+     * 
+     * @throws MojoFailureException If the artifact file has not been set.
+     */
+    public void execute()
+        throws MojoExecutionException
+    {
+        Properties props = new Properties();
+
+        getLog().info( "[MAVEN-CORE-IT-LOG] Building local POMs" );
+
+        if ( files != null )
+        {
+            for ( int i = 0; i < files.length; i++ )
+            {
+                File file = files[i];
+
+                getLog().info( "[MAVEN-CORE-IT-LOG] Building " + file );
+
+                try
+                {
+                    MavenProject project = builder.build( file, localRepository, null );
+
+                    dump( props, file.getName() + ".", project );
+                }
+                catch ( Exception e )
+                {
+                    getLog().warn( "Failed to build local POM for " + file, e );
+                }
+            }
+        }
+
+        store( props, propertiesFile );
+    }
+
+}

Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision