[MPLUGINTESTING-69] update plexus-utils (#17)
* update plexus-utils
* fix AbstractMojoTestCase
* close streams
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java
index a64fd1c..7296c01 100644
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java
+++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java
@@ -72,6 +72,7 @@
import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
+import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.logging.LoggerManager;
import org.codehaus.plexus.util.InterpolationFilterReader;
import org.codehaus.plexus.util.ReaderFactory;
@@ -144,34 +145,35 @@
MAVEN_VERSION == null || new DefaultArtifactVersion( "3.2.3" ).compareTo( MAVEN_VERSION ) < 0 );
configurator = getContainer().lookup( ComponentConfigurator.class, "basic" );
+ Context context = container.getContext();
+ Map<Object, Object> map = context.getContextData();
- InputStream is = getClass().getResourceAsStream( "/" + getPluginDescriptorLocation() );
-
- XmlStreamReader reader = new XmlStreamReader( is );
-
- InterpolationFilterReader interpolationFilterReader =
- new InterpolationFilterReader( new BufferedReader( reader ), container.getContext().getContextData() );
-
- PluginDescriptor pluginDescriptor = new PluginDescriptorBuilder().build( interpolationFilterReader );
-
- Artifact artifact =
- lookup( RepositorySystem.class ).createArtifact( pluginDescriptor.getGroupId(),
- pluginDescriptor.getArtifactId(),
- pluginDescriptor.getVersion(), ".jar" );
-
- artifact.setFile( getPluginArtifactFile() );
- pluginDescriptor.setPluginArtifact( artifact );
- pluginDescriptor.setArtifacts( Arrays.asList( artifact ) );
-
- for ( ComponentDescriptor<?> desc : pluginDescriptor.getComponents() )
+ try ( InputStream is = getClass().getResourceAsStream( "/" + getPluginDescriptorLocation() );
+ Reader reader = new BufferedReader( new XmlStreamReader( is ) );
+ InterpolationFilterReader interpolationReader = new InterpolationFilterReader( reader, map, "${", "}" ) )
{
- getContainer().addComponentDescriptor( desc );
- }
-
- mojoDescriptors = new HashMap<>();
- for ( MojoDescriptor mojoDescriptor : pluginDescriptor.getMojos() )
- {
- mojoDescriptors.put( mojoDescriptor.getGoal(), mojoDescriptor );
+
+ PluginDescriptor pluginDescriptor = new PluginDescriptorBuilder().build( interpolationReader );
+
+ Artifact artifact =
+ lookup( RepositorySystem.class ).createArtifact( pluginDescriptor.getGroupId(),
+ pluginDescriptor.getArtifactId(),
+ pluginDescriptor.getVersion(), ".jar" );
+
+ artifact.setFile( getPluginArtifactFile() );
+ pluginDescriptor.setPluginArtifact( artifact );
+ pluginDescriptor.setArtifacts( Arrays.asList( artifact ) );
+
+ for ( ComponentDescriptor<?> desc : pluginDescriptor.getComponents() )
+ {
+ getContainer().addComponentDescriptor( desc );
+ }
+
+ mojoDescriptors = new HashMap<>();
+ for ( MojoDescriptor mojoDescriptor : pluginDescriptor.getMojos() )
+ {
+ mojoDescriptors.put( mojoDescriptor.getGoal(), mojoDescriptor );
+ }
}
}
@@ -573,11 +575,12 @@
protected PlexusConfiguration extractPluginConfiguration( String artifactId, File pom )
throws Exception
{
- Reader reader = ReaderFactory.newXmlReader( pom );
-
- Xpp3Dom pomDom = Xpp3DomBuilder.build( reader );
-
- return extractPluginConfiguration( artifactId, pomDom );
+
+ try ( Reader reader = ReaderFactory.newXmlReader( pom ) )
+ {
+ Xpp3Dom pomDom = Xpp3DomBuilder.build( reader );
+ return extractPluginConfiguration( artifactId, pomDom );
+ }
}
/**
diff --git a/pom.xml b/pom.xml
index b89888b..67ad7c1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -178,8 +178,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
- <version>3.0.15</version>
- <scope>provided</scope>
+ <version>3.3.0</version>
</dependency>
<dependency>
@@ -192,16 +191,12 @@
</dependencyManagement>
<dependencies>
-
- <!-- misc -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
-
</dependencies>
-
<build>
<pluginManagement>
<plugins>