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 2017/12/20 09:28:54 UTC

[maven-ant-plugin] 13/18: [MANT-51] Configuration from plugin management is not considered

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to annotated tag maven-ant-plugin-2.2
in repository https://gitbox.apache.org/repos/asf/maven-ant-plugin.git

commit b2f5d8817ca5fc519ce17773c3cfb29ba780dd71
Author: Benjamin Bentmann <be...@apache.org>
AuthorDate: Sat May 2 18:10:05 2009 +0000

    [MANT-51] Configuration from plugin management is not considered
    
    git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-ant-plugin@770974 13f79535-47bb-0310-9956-ffa450edef68
---
 src/it/plugin-mngt-config-only/pom.xml             | 39 ++++++++++++++++++
 .../src/main/java/Main.java                        |  6 +++
 src/it/plugin-mngt-config-only/verify.bsh          | 25 +++++++++++
 src/it/plugin-mngt-config/pom.xml                  | 48 ++++++++++++++++++++++
 src/it/plugin-mngt-config/src/main/java/Main.java  |  6 +++
 src/it/plugin-mngt-config/verify.bsh               | 25 +++++++++++
 .../maven/plugin/ant/AntBuildWriterUtil.java       |  7 ++++
 7 files changed, 156 insertions(+)

diff --git a/src/it/plugin-mngt-config-only/pom.xml b/src/it/plugin-mngt-config-only/pom.xml
new file mode 100644
index 0000000..3f16f2d
--- /dev/null
+++ b/src/it/plugin-mngt-config-only/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.its.ant</groupId>
+  <artifactId>plugin-mngt-config-only</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <description>
+    Checks the extraction of plugin configuration when only plugin management is present.
+  </description>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>2.0.2</version>
+          <configuration>
+            <target>1.3</target>
+            <source>1.4</source>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <!-- NOTE: It's essential part of this test to not define the maven-compiler-plugin here! -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ant-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/src/it/plugin-mngt-config-only/src/main/java/Main.java b/src/it/plugin-mngt-config-only/src/main/java/Main.java
new file mode 100644
index 0000000..10c0169
--- /dev/null
+++ b/src/it/plugin-mngt-config-only/src/main/java/Main.java
@@ -0,0 +1,6 @@
+public class Main
+{
+
+    private String test = "it";
+
+}
diff --git a/src/it/plugin-mngt-config-only/verify.bsh b/src/it/plugin-mngt-config-only/verify.bsh
new file mode 100644
index 0000000..cb522f2
--- /dev/null
+++ b/src/it/plugin-mngt-config-only/verify.bsh
@@ -0,0 +1,25 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+import org.codehaus.plexus.util.*;
+
+File buildFile = new File( basedir, "maven-build.xml" );
+String xml = FileUtils.fileRead( buildFile, "UTF-8" );
+
+Matcher m = Pattern.compile( "<javac\\s+[^>]*?>" ).matcher( xml );
+if ( !m.find() )
+{
+    throw new Exception( "Build script does not contain <javac> task." );
+}
+
+if ( m.group().indexOf( "target=\"1.3\"" ) < 0 )
+{
+    throw new Exception( "<javac> does not define target=1.3" );
+}
+
+if ( m.group().indexOf( "source=\"1.4\"" ) < 0 )
+{
+    throw new Exception( "<javac> does not define source=1.4" );
+}
+
+return true;
diff --git a/src/it/plugin-mngt-config/pom.xml b/src/it/plugin-mngt-config/pom.xml
new file mode 100644
index 0000000..e4f208a
--- /dev/null
+++ b/src/it/plugin-mngt-config/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.its.ant</groupId>
+  <artifactId>plugin-mngt-config</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <description>
+    Checks the extraction of plugin configuration when plugin management is also present.
+  </description>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>2.0.2</version>
+          <configuration>
+            <!-- "target" checks the general configuration via plugin management -->
+            <target>1.3</target>
+            <!-- "source" checks that normal plugin configuration is dominant over plugin management -->
+            <source>9.9</source>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.4</source>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ant-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/src/it/plugin-mngt-config/src/main/java/Main.java b/src/it/plugin-mngt-config/src/main/java/Main.java
new file mode 100644
index 0000000..10c0169
--- /dev/null
+++ b/src/it/plugin-mngt-config/src/main/java/Main.java
@@ -0,0 +1,6 @@
+public class Main
+{
+
+    private String test = "it";
+
+}
diff --git a/src/it/plugin-mngt-config/verify.bsh b/src/it/plugin-mngt-config/verify.bsh
new file mode 100644
index 0000000..cb522f2
--- /dev/null
+++ b/src/it/plugin-mngt-config/verify.bsh
@@ -0,0 +1,25 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+import org.codehaus.plexus.util.*;
+
+File buildFile = new File( basedir, "maven-build.xml" );
+String xml = FileUtils.fileRead( buildFile, "UTF-8" );
+
+Matcher m = Pattern.compile( "<javac\\s+[^>]*?>" ).matcher( xml );
+if ( !m.find() )
+{
+    throw new Exception( "Build script does not contain <javac> task." );
+}
+
+if ( m.group().indexOf( "target=\"1.3\"" ) < 0 )
+{
+    throw new Exception( "<javac> does not define target=1.3" );
+}
+
+if ( m.group().indexOf( "source=\"1.4\"" ) < 0 )
+{
+    throw new Exception( "<javac> does not define source=1.4" );
+}
+
+return true;
diff --git a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
index ef27282..a9bc262 100644
--- a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
+++ b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
@@ -946,6 +946,13 @@ public class AntBuildWriterUtil
         {
             plugins.add( it.next() );
         }
+        if ( project.getBuild().getPluginManagement() != null )
+        {
+            for ( Iterator it = project.getBuild().getPluginManagement().getPlugins().iterator(); it.hasNext(); )
+            {
+                plugins.add( it.next() );
+            }
+        }
 
         for ( Iterator it = plugins.iterator(); it.hasNext(); )
         {

-- 
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.