Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -144,34 +145,35 @@ protected void setUp()
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 );
}
}
}

Expand Down Expand Up @@ -573,11 +575,12 @@ private void finalizeMojoConfiguration( MojoExecution mojoExecution )
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 );
}
}

/**
Expand Down
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ under the License.
<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>
Expand All @@ -192,16 +191,12 @@ under the License.
</dependencyManagement>

<dependencies>

<!-- misc -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

</dependencies>


<build>
<pluginManagement>
<plugins>
Expand Down