From c10d2c0069f8afc4c5c15edeb1ba616467463995 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Thu, 22 Nov 2012 14:50:49 +0100 Subject: [PATCH] Force source >= 1.5 and target >= source --- 0001-Customize-compiler-plugin.patch | 104 +++++++++++++++++++++++++++ maven.spec | 7 +- 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 0001-Customize-compiler-plugin.patch diff --git a/0001-Customize-compiler-plugin.patch b/0001-Customize-compiler-plugin.patch new file mode 100644 index 0000000..3a09e0c --- /dev/null +++ b/0001-Customize-compiler-plugin.patch @@ -0,0 +1,104 @@ +From c7d89b31e7764c514138135f91b2e290d410ebc7 Mon Sep 17 00:00:00 2001 +From: Mikolaj Izdebski +Date: Thu, 22 Nov 2012 15:28:28 +0100 +Subject: [PATCH] Customize compiler plugin + +In local mode require source to be >= 1.5 and target >= source. +--- + .../model/validation/DefaultModelValidator.java | 68 ++++++++++++++++++++++ + 1 file changed, 68 insertions(+) + +diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java +index 6c76173..bc0b836 100644 +--- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java ++++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java +@@ -19,6 +19,10 @@ package org.apache.maven.model.validation; + * under the License. + */ + ++import java.math.BigDecimal; ++import java.util.LinkedList; ++import org.codehaus.plexus.util.xml.Xpp3Dom; ++ + import java.io.File; + import java.util.Arrays; + import java.util.HashMap; +@@ -342,6 +346,8 @@ public class DefaultModelValidator + "distributionManagement.snapshotRepository", request ); + } + } ++ ++ customizeModel( model ); + } + + private void validateRawDependencies( ModelProblemCollector problems, List dependencies, String prefix, +@@ -924,4 +930,66 @@ public class DefaultModelValidator + } + } + ++ private void customizeModel( Model model ) ++ { ++ // Enable model customizations only in local mode ++ if ( System.getProperty( "maven.local.mode" ) == null ) ++ return; ++ ++ Build build = model.getBuild(); ++ if ( build == null ) ++ return; ++ ++ List plugins = build.getPlugins(); ++ if ( plugins == null ) ++ return; ++ ++ for ( Plugin plugin : plugins ) ++ { ++ String groupId = plugin.getGroupId(); ++ String artifactId = plugin.getArtifactId(); ++ ++ if ( groupId.equals( "org.apache.maven.plugins" ) && artifactId.equals( "maven-compiler-plugin" ) ) ++ customizeCompilerPlugin( plugin ); ++ } ++ } ++ ++ private void customizeCompilerPlugin( Plugin plugin ) ++ { ++ List configurations = new LinkedList(); ++ configurations.add( plugin.getConfiguration() ); ++ ++ List executions = plugin.getExecutions(); ++ for ( PluginExecution exec : executions ) ++ configurations.add( exec.getConfiguration() ); ++ ++ for ( Object configObj : configurations ) ++ { ++ try ++ { ++ Xpp3Dom config = (Xpp3Dom) configObj; ++ BigDecimal source = new BigDecimal( config.getChild( "source" ).getValue() ); ++ BigDecimal target = new BigDecimal( config.getChild( "target" ).getValue() ); ++ ++ // Source must be at least 1.5 ++ BigDecimal minSource = new BigDecimal( "1.5" ); ++ if ( source.compareTo( minSource ) < 0 ) ++ source = minSource; ++ ++ // Target must not be less than source ++ if ( target.compareTo( source ) < 0 ) ++ target = source; ++ ++ config.getChild( "source" ).setValue( source.toString() ); ++ config.getChild( "target" ).setValue( target.toString() ); ++ } ++ catch ( NullPointerException e ) ++ { ++ } ++ catch ( NumberFormatException e ) ++ { ++ } ++ } ++ } ++ + } +-- +1.7.11.7 + diff --git a/maven.spec b/maven.spec index 9e222a0..55246f4 100644 --- a/maven.spec +++ b/maven.spec @@ -2,7 +2,7 @@ Name: maven Version: 3.0.4 -Release: 25%{?dist} +Release: 26%{?dist} Summary: Java project management and project comprehension tool Group: Development/Tools @@ -41,6 +41,7 @@ Patch151: 0003-Use-utf-8-source-encoding.patch # Patch2XX for non-upstreamable patches Patch200: 0002-Use-custom-resolver.patch Patch201: 0004-Fix-text-scope-skipping-with-maven.test.skip.patch +Patch202: 0001-Customize-compiler-plugin.patch BuildArch: noarch @@ -151,6 +152,7 @@ BuildArch: noarch %patch151 -p1 %patch200 -p1 %patch201 -p1 +%patch202 -p1 %patch100 -p1 %patch101 -p1 @@ -424,6 +426,9 @@ ln -sf `rpm --eval '%%{_jnidir}'` %{_datadir}/%{name}/repository-jni/JPP %changelog +* Thu Nov 22 2012 Mikolaj Izdebski - 3.0.4-26 +- Force source >= 1.5 and target >= source + * Mon Nov 19 2012 Mikolaj Izdebski - 3.0.4-25 - Fix license tag