You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2014/12/24 15:19:15 UTC

svn commit: r1647791 - in /maven/plugins/trunk/maven-project-info-reports-plugin/src: it/java-version/ it/java-version/plugin/ it/java-version/pluginManagement/ it/java-version/property/ main/java/org/apache/maven/report/projectinfo/

Author: hboutemy
Date: Wed Dec 24 14:19:14 2014
New Revision: 1647791

URL: http://svn.apache.org/r1647791
Log:
[MPIR-263] restored old java version detection algorithm and added IT to check the supported and not yet supported conditions

Added:
    maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/
    maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/invoker.properties   (with props)
    maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/plugin/
    maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/plugin/pom.xml   (with props)
    maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pluginManagement/
    maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pluginManagement/pom.xml   (with props)
    maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pom.xml   (with props)
    maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/property/
    maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/property/pom.xml   (with props)
    maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/verify.groovy   (with props)
Modified:
    maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java

Added: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/invoker.properties?rev=1647791&view=auto
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/invoker.properties (added)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/invoker.properties Wed Dec 24 14:19:14 2014
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals = project-info-reports:summary

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/invoker.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/plugin/pom.xml?rev=1647791&view=auto
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/plugin/pom.xml (added)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/plugin/pom.xml Wed Dec 24 14:19:14 2014
@@ -0,0 +1,61 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.plugins.project-info-reports</groupId>
+    <artifactId>java-version</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>plugin</artifactId>
+  <name>target bytecode defined by plugin configuration</name>
+
+  <properties><!-- will be overridden -->
+    <maven.compiler.source>1.3</maven.compiler.source>
+    <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <configuration><!-- will be overridden -->
+            <source>1.4</source>
+            <target>1.4</target>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/plugin/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/plugin/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pluginManagement/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pluginManagement/pom.xml?rev=1647791&view=auto
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pluginManagement/pom.xml (added)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pluginManagement/pom.xml Wed Dec 24 14:19:14 2014
@@ -0,0 +1,52 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.plugins.project-info-reports</groupId>
+    <artifactId>java-version</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>pluginManagement</artifactId>
+  <name>target bytecode defined by pluginManagement configuration</name>
+
+  <properties><!-- will be overridden -->
+    <maven.compiler.source>1.3</maven.compiler.source>
+    <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <configuration>
+            <source>1.4</source>
+            <target>1.4</target>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pluginManagement/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pluginManagement/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pluginManagement/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pom.xml?rev=1647791&view=auto
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pom.xml (added)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pom.xml Wed Dec 24 14:19:14 2014
@@ -0,0 +1,46 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.project-info-reports</groupId>
+  <artifactId>java-version</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <name>MPIR IT test for minimum java version detection in summary</name>
+  <description>
+    Check that the detection algorithm finds the right value in every condition.
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+  </properties>
+
+  <modules>
+    <module>plugin</module>
+    <module>pluginManagement</module>
+    <module>property</module>
+  </modules>
+</project>

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/property/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/property/pom.xml?rev=1647791&view=auto
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/property/pom.xml (added)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/property/pom.xml Wed Dec 24 14:19:14 2014
@@ -0,0 +1,38 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.plugins.project-info-reports</groupId>
+    <artifactId>java-version</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>property</artifactId>
+  <name>target bytecode defined by maven.compiler.target property</name>
+
+  <properties>
+    <maven.compiler.source>1.3</maven.compiler.source>
+    <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
+  </properties>
+</project>

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/property/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/property/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/property/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/verify.groovy?rev=1647791&view=auto
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/verify.groovy (added)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/verify.groovy Wed Dec 24 14:19:14 2014
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+assert new File( basedir, 'plugin/target/site/project-summary.html' ).text.contains( '<td>1.5</td>' )
+assert new File( basedir, 'pluginManagement/target/site/project-summary.html' ).text.contains( '<td>1.4</td>' )
+//MPIR-263: assert new File( basedir, 'property/target/site/project-summary.html' ).text.contains( '<td>1.3</td>' )
+
+return true;
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/verify.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/java-version/verify.groovy
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java?rev=1647791&r1=1647790&r2=1647791&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java (original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java Wed Dec 24 14:19:14 2014
@@ -49,14 +49,6 @@ public class ProjectSummaryReport
     // Mojo parameters
     // ----------------------------------------------------------------------
 
-    /**
-     * The target Java version the artifact is built for. Should match the target used in the compiler plugin.
-     *
-     * @since 2.8
-     */
-    @Parameter( defaultValue = "${maven.compiler.target}" )
-    private String targetJavaVersion;
-
     // ----------------------------------------------------------------------
     // Public methods
     // ----------------------------------------------------------------------
@@ -143,7 +135,7 @@ public class ProjectSummaryReport
             tableRow( new String[] { getI18nString( "build.type" ), project.getPackaging() } );
             if ( isJavaProject( project ) )
             {
-                tableRow( new String[] { getI18nString( "build.javaVersion" ), targetJavaVersion } );
+                tableRow( new String[] { getI18nString( "build.javaVersion" ), getMinimumJavaVersion() } );
             }
             endTable();
             endSection();
@@ -163,6 +155,38 @@ public class ProjectSummaryReport
             endSection();
         }
 
+        private String getMinimumJavaVersion()
+        {
+
+            final String pluginId = "org.apache.maven.plugins:maven-compiler-plugin";
+            String sourceConfigured = getPluginParameter( pluginId, "source" );
+            String targetConfigured = getPluginParameter( pluginId, "target" );
+
+            String forkFlag = getPluginParameter( pluginId, "fork" );
+            String compilerVersionConfigured = null;
+            if ( "true".equalsIgnoreCase( forkFlag ) )
+            {
+                compilerVersionConfigured = getPluginParameter( pluginId, "compilerVersion" );
+            }
+
+            String minimumJavaVersion = compilerVersionConfigured;
+            if ( targetConfigured != null )
+            {
+                minimumJavaVersion = targetConfigured;
+            }
+            else if ( sourceConfigured != null )
+            {
+                minimumJavaVersion = sourceConfigured;
+            }
+            else
+            {
+                // no source, target, compilerVersion: toolchain? default target attribute of current
+                // maven-compiler-plugin's version? analyze packaged jar (like dependencies)?
+            }
+
+            return minimumJavaVersion;
+        }
+
         private void tableRowWithLink( String[] content )
         {
             sink.tableRow();