You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2022/01/10 02:45:48 UTC

[maven-plugin-tools] 05/05: [MPLUGIN-387] Bump Ant to 1.9.16

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

slachiewicz pushed a commit to branch MPLUGIN-387
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git

commit de9a93564ba5023476e1b215ed2794489a56bddb
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Mon Jan 10 03:42:30 2022 +0100

    [MPLUGIN-387] Bump Ant to 1.9.16
---
 .../maven/script/ant/AntMojoWrapperTest.java       | 108 +++++++--------------
 .../test/resources/META-INF/maven/plugin-2.0.xml   |  63 ------------
 pom.xml                                            |   2 +-
 3 files changed, 36 insertions(+), 137 deletions(-)

diff --git a/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java b/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java
index 2b50e99..791c87f 100644
--- a/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java
+++ b/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java
@@ -87,16 +87,14 @@ public class AntMojoWrapperTest
     {
         String pluginXml = "META-INF/maven/plugin-2.1.xml";
 
-        List<String> messages = run( pluginXml, true );
+        List<String> messages = run( pluginXml );
 
-        assertPresence( messages, "Unpacked Ant build scripts (in Maven build directory).", false );
-        assertPresence( messages, "Maven parameter expression evaluator for Ant properties.", false );
-        assertPresence( messages, "Maven standard project-based classpath references.", false );
-        assertPresence( messages, "Maven standard plugin-based classpath references.", false );
-        assertPresence( messages,
-                        "Maven project, session, mojo-execution, or path-translation parameter information is", false );
-        assertPresence( messages, "maven-script-ant < 2.1.0, or used maven-plugin-tools-ant < 2.2 during release",
-                        false );
+        assertPresence( messages, "Unpacked Ant build scripts (in Maven build directory)." );
+        assertPresence( messages, "Maven parameter expression evaluator for Ant properties." );
+        assertPresence( messages, "Maven standard project-based classpath references." );
+        assertPresence( messages, "Maven standard plugin-based classpath references." );
+        assertPresence( messages, "Maven project, session, mojo-execution, or path-translation parameter information is" );
+        assertPresence( messages, "maven-script-ant < 2.1.0, or used maven-plugin-tools-ant < 2.2 during release" );
 
         ArgumentCaptor<BuildEvent> buildEvent = ArgumentCaptor.forClass(BuildEvent.class);
         verify( buildListener, atLeastOnce() ).messageLogged( buildEvent.capture() );
@@ -106,52 +104,19 @@ public class AntMojoWrapperTest
         assertThat( buildEvent.getValue().getMessage(), endsWith( ".test.jar" ) );
     }
 
-    @Test
-    public void test20StylePlugin()
-        throws PlexusConfigurationException, IOException, ComponentInstantiationException, MojoExecutionException,
-        ComponentConfigurationException, ArchiverException, URISyntaxException
-    {
-        String pluginXml = "META-INF/maven/plugin-2.0.xml";
-
-        List<String> messages = run( pluginXml, false );
-
-        assertPresence( messages, "Unpacked Ant build scripts (in Maven build directory).", true );
-        assertPresence( messages, "Maven parameter expression evaluator for Ant properties.", true );
-        assertPresence( messages, "Maven standard project-based classpath references.", true );
-        assertPresence( messages, "Maven standard plugin-based classpath references.", true );
-        assertPresence( messages,
-                        "Maven project, session, mojo-execution, or path-translation parameter information is", true );
-        assertPresence( messages, "maven-script-ant < 2.1.0, or used maven-plugin-tools-ant < 2.2 during release", true );
-
-        ArgumentCaptor<BuildEvent> buildEvent = ArgumentCaptor.forClass(BuildEvent.class);
-        verify( buildListener, atLeastOnce() ).messageLogged( buildEvent.capture() );
-
-        // last message
-        assertThat( buildEvent.getValue().getMessage(), startsWith( "plugin classpath is: " ) );
-        assertThat( buildEvent.getValue().getMessage(), endsWith( "path-is-missing" ) );
-    }
-
-    private void assertPresence( List<String> messages, String test, boolean shouldBePresent )
+    private void assertPresence( List<String> messages, String test )
     {
         for ( String message : messages )
         {
             if ( message.contains( test ) )
             {
-                if ( !shouldBePresent )
-                {
-                    fail( "Test string: '" + test + "' was found in output, but SHOULD NOT BE THERE." );
-                }
+                fail( "Test string: '" + test + "' was found in output, but SHOULD NOT BE THERE." );
                 return;
             }
         }
-
-        if ( shouldBePresent )
-        {
-            fail( "Test string: '" + test + "' was NOT found in output, but SHOULD BE THERE." );
-        }
     }
 
-    private List<String> run( String pluginXml, boolean includeImplied )
+    private List<String> run( String pluginXml )
         throws PlexusConfigurationException, IOException, ComponentInstantiationException, MojoExecutionException,
         ComponentConfigurationException, ArchiverException, URISyntaxException
     {
@@ -185,43 +150,40 @@ public class AntMojoWrapperTest
         Artifact artifact = mock( Artifact.class );
         PathTranslator pt = mock( PathTranslator.class );
 
-        if ( includeImplied )
-        {
-            File pluginXmlFile = Paths.get( resource.toURI() ).toFile();
+        File pluginXmlFile = Paths.get( resource.toURI() ).toFile();
 
-            File jarFile = File.createTempFile( "AntMojoWrapperTest.", ".test.jar" );
-            jarFile.deleteOnExit();
+        File jarFile = File.createTempFile( "AntMojoWrapperTest.", ".test.jar" );
+        jarFile.deleteOnExit();
 
-            JarArchiver archiver = new JarArchiver();
-            archiver.enableLogging( new ConsoleLogger( Logger.LEVEL_ERROR, "archiver" ) );
-            archiver.setDestFile( jarFile );
-            archiver.addFile( pluginXmlFile, pluginXml );
-            archiver.createArchive();
+        JarArchiver archiver = new JarArchiver();
+        archiver.enableLogging( new ConsoleLogger( Logger.LEVEL_ERROR, "archiver" ) );
+        archiver.setDestFile( jarFile );
+        archiver.addFile( pluginXmlFile, pluginXml );
+        archiver.createArchive();
 
-            when( artifact.getFile() ).thenReturn( jarFile );
+        when( artifact.getFile() ).thenReturn( jarFile );
 
-            Model model = new Model();
+        Model model = new Model();
 
-            Build build = new Build();
-            build.setDirectory( "target" );
+        Build build = new Build();
+        build.setDirectory( "target" );
 
-            model.setBuild( build );
+        model.setBuild( build );
 
-            MavenProject project = new MavenProject( model );
-            project.setFile( new File( "pom.xml" ).getAbsoluteFile() );
+        MavenProject project = new MavenProject( model );
+        project.setFile( new File( "pom.xml" ).getAbsoluteFile() );
 
-            pd.setPluginArtifact( artifact );
-            pd.setArtifacts( Collections.singletonList( artifact ) );
+        pd.setPluginArtifact( artifact );
+        pd.setArtifacts( Collections.singletonList( artifact ) );
 
-            config.put( "project", project );
-            config.put( "session", new MavenSession( null, null, null, null, null, null, null, null, null, null ) );
-            config.put( "mojoExecution", new MojoExecution( md ) );
+        config.put( "project", project );
+        config.put( "session", new MavenSession( null, null, null, null, null, null, null, null, null, null ) );
+        config.put( "mojoExecution", new MojoExecution( md ) );
 
-            ComponentRequirement cr = new ComponentRequirement();
-            cr.setRole( PathTranslator.class.getName() );
+        ComponentRequirement cr = new ComponentRequirement();
+        cr.setRole( PathTranslator.class.getName() );
 
-            wrapper.addComponentRequirement( cr, pt );
-        }
+        wrapper.addComponentRequirement( cr, pt );
 
         wrapper.setComponentConfiguration( config );
 
@@ -251,7 +213,7 @@ public class AntMojoWrapperTest
             messages.addAll( tbl.messages );
         }
         
-        messages.add( new String( baos.toByteArray() ) );
+        messages.add( baos.toString() );
         
         return messages;
     }
@@ -259,7 +221,7 @@ public class AntMojoWrapperTest
     private static final class TestBuildListener
         implements BuildListener
     {
-        private List<String> messages = new ArrayList<>();
+        private final List<String> messages = new ArrayList<>();
 
         public void buildFinished( BuildEvent arg0 )
         {
diff --git a/maven-script/maven-script-ant/src/test/resources/META-INF/maven/plugin-2.0.xml b/maven-script/maven-script-ant/src/test/resources/META-INF/maven/plugin-2.0.xml
deleted file mode 100644
index 63f8bf2..0000000
--- a/maven-script/maven-script-ant/src/test/resources/META-INF/maven/plugin-2.0.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version='1.0'?>
-<!--
-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.
--->
-
-<plugin>
-  <description>Test Plugin</description>
-  <groupId>org.myplugin</groupId>
-  <artifactId>my-plugin</artifactId>
-  <version>1</version>
-  <goalPrefix>myplugin</goalPrefix>
-  <isolatedRealm>false</isolatedRealm>
-  <inheritedByDefault>true</inheritedByDefault>
-  <mojos>
-    <mojo>
-      <goal>test</goal>
-      <description>Build a JAR from the current project.</description>
-      <requiresDirectInvocation>false</requiresDirectInvocation>
-      <requiresProject>false</requiresProject>
-      <requiresReports>false</requiresReports>
-      <aggregator>false</aggregator>
-      <requiresOnline>false</requiresOnline>
-      <inheritedByDefault>true</inheritedByDefault>
-      <implementation>test.build.xml:test</implementation>
-      <language>ant</language>
-      <instantiationStrategy>per-lookup</instantiationStrategy>
-      <executionStrategy>once-per-session</executionStrategy>
-      <parameters>
-		<parameter>
-			<name>basedir</name>
-			<required>true</required>
-			<editable>false</editable>
-			<type>java.io.File</type>
-		</parameter>
-		<parameter>
-			<name>messageLevel</name>
-			<required>true</required>
-			<editable>false</editable>
-			<type>java.lang.String</type>
-		</parameter>
-      </parameters>
-      <configuration>
-        <basedir implementation="java.io.File">${basedir}</basedir>
-        <messageLevel implementation="java.lang.String">${messageLevel}</messageLevel>
-      </configuration>
-    </mojo>
-  </mojos>
-</plugin>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index af80d2f..3f57cbb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,7 +94,7 @@
     <javaVersion>7</javaVersion>
     <pluginTestingHarnessVersion>3.3.0</pluginTestingHarnessVersion>
     <mavenVersion>3.2.5</mavenVersion>
-    <antVersion>1.7.1</antVersion>
+    <antVersion>1.9.16</antVersion>
     <sisuVersion>0.3.5</sisuVersion>
     <mavenInvokerPluginVersion>3.2.2</mavenInvokerPluginVersion>
     <maven.site.path>plugin-tools-archives/plugin-tools-LATEST</maven.site.path>