Skip to content
Commits on Source (15)
......@@ -6,4 +6,5 @@ target
#idea
*.iml
.idea
.java-version
.svn
maven-plugin-testing (3.3.0-1) unstable; urgency=medium
* Team upload.
* New upstream release
- Refreshed the patches
* Fixed the build failure with plexus-utils 3.1
* Relocate the old org.apache.maven.shared groupId
* Removed the javadoc package
* Standards-Version updated to 4.2.1
* Switch to debhelper level 11
* Use salsa.debian.org Vcs-* URLs
* Track and download the new releases from GitHub
-- Emmanuel Bourg <ebourg@apache.org> Wed, 28 Nov 2018 11:55:53 +0100
maven-plugin-testing (2.1-1) unstable; urgency=medium
* Team upload.
......
......@@ -4,29 +4,25 @@ Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
Uploaders: Ludovic Claude <ludovic.claude@laposte.net>
Build-Depends:
debhelper (>= 10),
debhelper (>= 11),
default-jdk,
default-jdk-doc,
junit4,
libeasymock-java,
libmaven-invoker-java,
libmaven-javadoc-plugin-java,
libmaven3-core-java,
libplexus-archiver-java,
libplexus-component-metadata-java,
libplexus-utils-java,
libplexus-utils-java-doc,
maven-debian-helper (>= 2.2)
Standards-Version: 4.0.0
Vcs-Git: https://anonscm.debian.org/git/pkg-java/maven-plugin-testing.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/maven-plugin-testing.git
Standards-Version: 4.2.1
Vcs-Git: https://salsa.debian.org/java-team/maven-plugin-testing.git
Vcs-Browser: https://salsa.debian.org/java-team/maven-plugin-testing
Homepage: http://maven.apache.org/plugin-testing/
Package: libmaven-plugin-testing-java
Architecture: all
Depends: ${maven:Depends}, ${misc:Depends}
Recommends: ${maven:OptionalDepends}
Suggests: libmaven-plugin-testing-java-doc
Description: Maven Plugin Testing
Maven is a software project management and comprehension tool. Based on the
concept of a project object model (POM), Maven can manage a project's build,
......@@ -44,27 +40,3 @@ Description: Maven Plugin Testing
* Allowing transparent migration to new features
.
This package ships the necessary modules to be able to test Maven Plugins.
Package: libmaven-plugin-testing-java-doc
Architecture: all
Section: doc
Depends: ${maven:DocDepends}, ${misc:Depends}
Recommends: ${maven:DocOptionalDepends}
Suggests: libmaven-plugin-testing-java
Description: Documentation for Maven Plugin Testing
Maven is a software project management and comprehension tool. Based on the
concept of a project object model (POM), Maven can manage a project's build,
reporting and documentation from a central piece of information.
.
Maven's primary goal is to allow a developer to comprehend the complete
state of a development effort in the shortest period of time. In order to
attain this goal there are several areas of concern that Maven attempts
to deal with:
.
* Making the build process easy
* Providing a uniform build system
* Providing quality project information
* Providing guidelines for best practices development
* Allowing transparent migration to new features
.
This package contains the API documentation of libmaven-plugin-testing-java.
Document: libmaven-plugin-testing-java
Title: API Javadoc for Maven Plugin Testing
Author: Maven Plugin Testing developers
Abstract: This is the API Javadoc provided for the
libmaven-plugin-testing-java library.
Section: Programming
Format: HTML
Index: /usr/share/doc/libmaven-plugin-testing-java/api/index.html
Files: /usr/share/doc/libmaven-plugin-testing-java/api/*
target/site/apidocs/* usr/share/doc/libmaven-plugin-testing-java/api
......@@ -23,7 +23,7 @@
# --ignore-pom: don't install the POM with mh_install or mh_installpoms. To use with POM files that are created
# temporarily for certain artifacts such as Javadoc jars.
#
pom.xml --no-parent --has-package-version
maven-plugin-testing-harness/pom.xml --has-package-version
maven-plugin-testing-tools/pom.xml --has-package-version
maven-test-tools/pom.xml --has-package-version
pom.xml --no-parent --has-package-version --relocate=org.apache.maven.shared:maven-plugin-testing
maven-plugin-testing-harness/pom.xml --has-package-version --relocate=org.apache.maven.shared:maven-plugin-testing-harness
maven-plugin-testing-tools/pom.xml --has-package-version --relocate=org.apache.maven.shared:maven-plugin-testing-tools
maven-test-tools/pom.xml --has-package-version --relocate=org.apache.maven.shared:maven-test-tools
......@@ -14,4 +14,6 @@
# from the POM
# junit junit jar s/3\\..*/3.x/
org.apache.maven.plugins maven-enforcer-plugin * * * *
org.apache.maven.plugins maven-site-plugin * * * *
org.apache.maven.plugins maven-source-plugin * * * *
# Maven published rules - additional rules to publish, to help
# the packaging work of Debian maintainers using mh_make
# Format of this file is:
# [group] [artifact] [type] [version] [classifier] [scope]
# where each element can be either
# - the exact string, for example org.apache for the group, or 3.1
# for the version. In this case, the element is simply matched
# and left as it is
# - * (the star character, alone). In this case, anything will
# match and be left as it is. For example, using * on the
# position of the artifact field will match any artifact id
# - a regular expression of the form s/match/replace/
# in this case, elements that match are transformed using
# the regex rule.
# All elements much match before a rule can be applied
# Example rule: match jar with groupid= junit, artifactid= junit
# and version starting with 3., replacing the version with 3.x
# junit junit jar s/3\\..*/3.x/
s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-plugin-testing
s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-plugin-testing-harness
s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-plugin-testing-tools
s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-test-tools
......@@ -17,11 +17,6 @@
# junit junit jar s/3\\..*/3.x/
junit junit jar s/.*/4.x/ * *
s/easymock/org.easymock/ easymock * s/.*/debian/ * *
s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-plugin-testing-harness * s/.*/debian/ * *
s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-plugin-testing-tools * s/.*/debian/ * *
s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-plugin-testing * s/.*/debian/ * *
s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-test-tools * s/.*/debian/ * *
org.apache.maven maven-core * s/.*/3.x/ * *
org.apache.maven maven-compat * s/.*/3.x/ * *
......
#!/bin/sh -e
VERSION=$2
TAR=../maven-plugin-testing_$VERSION.orig.tar.xz
DIR=maven-plugin-testing-$VERSION
TAG=$(echo "maven-plugin-testing-$VERSION" | sed -re's/~(alpha|beta)/-\1-/')
svn export http://svn.apache.org/repos/asf/maven/plugin-testing/tags/${TAG}/ $DIR
XZ_OPT=--best tar -c -J -f $TAR --exclude '*.jar' --exclude '*.class' $DIR
rm -rf $DIR ../$TAG
# move to directory 'tarballs'
if [ -r .svn/deb-layout ]; then
. .svn/deb-layout
mv $TAR $origDir && echo "moved $TAR to $origDir"
fi
Description: Replaces the MockControl class removed from EasyMock 3.0
Author: Emmanuel Bourg <ebourg@apache.org>
Bug: https://github.com/apache/maven-plugin-testing/pull/2
--- a/maven-test-tools/src/main/java/org/apache/maven/shared/tools/easymock/MockManager.java
+++ b/maven-test-tools/src/main/java/org/apache/maven/shared/tools/easymock/MockManager.java
@@ -22,7 +22,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
/**
* Manager of MockControl
@@ -32,12 +32,12 @@
*/
public class MockManager
{
- private List<MockControl> mockControls = new ArrayList<MockControl>();
+ private List<IMocksControl> mockControls = new ArrayList<IMocksControl>();
/**
* @param control to be add to the manager
*/
- public void add( MockControl control )
+ public void add( IMocksControl control )
{
mockControls.add( control );
}
@@ -55,7 +55,7 @@
*/
public void replayAll()
{
- for ( MockControl control : mockControls )
+ for ( IMocksControl control : mockControls )
{
control.replay();
}
@@ -66,7 +66,7 @@
*/
public void verifyAll()
{
- for ( MockControl control : mockControls )
+ for ( IMocksControl control : mockControls )
{
control.verify();
}
Description: Fixes the compatibility with the latest version of Maven
Origin: backport, https://svn.apache.org/r1505991
--- 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
@@ -49,10 +49,12 @@
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.repository.RepositorySystem;
-import org.apache.maven.repository.internal.MavenRepositorySystemSession;
+import org.apache.maven.repository.internal.MavenAetherModule;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.PlexusTestCase;
@@ -169,7 +171,13 @@
{
ClassWorld classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() );
- return new DefaultContainerConfiguration().setClassWorld( classWorld ).setName( "embedder" );
+ ContainerConfiguration cc = new DefaultContainerConfiguration()
+ .setClassWorld( classWorld )
+ .setClassPathScanning( PlexusConstants.SCANNING_INDEX )
+ .setAutoWiring( true )
+ .setName( "maven" );
+
+ return cc;
}
protected PlexusContainer getContainer()
@@ -373,7 +381,7 @@
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
MavenExecutionResult result = new DefaultMavenExecutionResult();
- MavenSession session = new MavenSession( container, new MavenRepositorySystemSession(), request, result );
+ MavenSession session = new MavenSession( container, MavenRepositorySystemUtils.newSession(), request, result );
session.setCurrentProject( project );
session.setProjects( Arrays.asList( project ) );
return session;
--- a/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java
+++ b/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java
@@ -50,7 +50,7 @@
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
-import org.apache.maven.repository.internal.MavenRepositorySystemSession;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.util.FileUtils;
@@ -241,7 +241,7 @@
{
ProjectBuildingRequest request = new DefaultProjectBuildingRequest();
request.setLocalRepository( artifactRepositoryFactory.createArtifactRepository( "local", new File( "target/localrepo" ).getCanonicalFile().toURL().toExternalForm(), "default", null, null ) );
- request.setRepositorySession( new MavenRepositorySystemSession() );
+ request.setRepositorySession( MavenRepositorySystemUtils.newSession() );
MavenProject project = projectBuilder.build( pomInfo.getPomFile(), request ).getProject();
Artifact artifact = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(), project
--- a/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java
+++ b/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java
@@ -40,7 +40,7 @@
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
-import org.apache.maven.repository.internal.MavenRepositorySystemSession;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.apache.maven.settings.MavenSettingsBuilder;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusConstants;
@@ -218,7 +218,7 @@
destination.getParentFile().mkdirs();
}
- legacySupport.setSession( new MavenSession( container, new MavenRepositorySystemSession(),
+ legacySupport.setSession( new MavenSession( container, MavenRepositorySystemUtils.newSession(),
new DefaultMavenExecutionRequest(),
new DefaultMavenExecutionResult() ) );
try
--- a/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/ProjectToolTest.java
+++ b/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/ProjectToolTest.java
@@ -29,6 +29,8 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.apache.maven.shared.test.plugin.ProjectTool.PomInfo;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
@@ -110,4 +112,11 @@
assertTrue( foundPomMetadata );
}
+
+ @Override
+ protected void customizeContainerConfiguration(ContainerConfiguration configuration)
+ {
+ configuration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
+ configuration.setAutoWiring( true );
+ }
}
--- a/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/RepositoryToolTest.java
+++ b/maven-plugin-testing-tools/src/test/java/org/apache/maven/shared/test/plugin/RepositoryToolTest.java
@@ -26,6 +26,8 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.apache.maven.shared.tools.easymock.TestFileManager;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusTestCase;
/**
@@ -84,4 +86,11 @@
fileManager.assertFileContents( targetLocalRepoBasedir, "group/artifact/test/artifact-test.jar", jarContent );
}
+
+ @Override
+ protected void customizeContainerConfiguration(ContainerConfiguration configuration)
+ {
+ configuration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
+ configuration.setAutoWiring( true );
+ }
}
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/StubArtifactResolver.java
+++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/StubArtifactResolver.java
@@ -141,7 +141,7 @@
......
Description: Fixes the compatibility with the version of plexus-utils in Debian
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- 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
@@ -156,7 +156,7 @@
XmlStreamReader reader = new XmlStreamReader( is );
InterpolationFilterReader interpolationFilterReader =
- new InterpolationFilterReader( new BufferedReader( reader ), container.getContext().getContextData() );
+ new InterpolationFilterReader( new BufferedReader( reader ), (Map) container.getContext().getContextData() );
PluginDescriptor pluginDescriptor = new PluginDescriptorBuilder().build( interpolationFilterReader );
0001-easymock-upgrade.patch
0003-maven-compatibility.patch
0004-plexus-utils-compatibility.patch
......@@ -2,6 +2,3 @@
%:
dh $@
get-orig-source:
uscan --download-current-version --force-download --rename
version=3
opts="uversionmangle=s/-(alpha|beta)-/~$1/" \
http://svn.apache.org/repos/asf/maven/plugin-testing/tags/ \
maven-plugin-testing-(\d.*)/ debian debian/orig-tar.sh
version=4
opts="repack,compression=xz,uversionmangle=s/-(alpha|beta)-/~$1/" \
https://github.com/apache/maven-plugin-testing/tags .*/maven-plugin-testing-([\d\.]+).tar.gz
#!/bin/sh
#
# 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.
#
mvn -Preporting site site:stage $@
mvn scm-publish:publish-scm $@
......@@ -25,19 +25,13 @@ under the License.
<parent>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing</artifactId>
<version>2.1</version>
<version>3.3.0</version>
</parent>
<artifactId>maven-plugin-testing-harness</artifactId>
<name>Maven Plugin Testing Mechanism</name>
<description>The Maven Plugin Testing Harness provides mechanisms to manage tests on Mojo.</description>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/plugin-testing/tags/maven-plugin-testing-2.1/maven-plugin-testing-harness</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/plugin-testing/tags/maven-plugin-testing-2.1/maven-plugin-testing-harness</developerConnection>
<url>http://svn.apache.org/viewvc/maven/plugin-testing/tags/maven-plugin-testing-2.1/maven-plugin-testing-harness</url>
</scm>
<dependencies>
<!-- maven -->
<dependency>
......@@ -66,6 +60,11 @@ under the License.
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
......
......@@ -22,15 +22,23 @@ package org.apache.maven.plugin.testing;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.io.input.XmlStreamReader;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.DefaultMavenExecutionResult;
import org.apache.maven.execution.MavenExecutionRequest;
......@@ -49,10 +57,11 @@ import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.MavenRepositorySystemSession;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.DefaultContainerConfiguration;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.PlexusTestCase;
......@@ -64,14 +73,16 @@ import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.logging.LoggerManager;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.InterpolationFilterReader;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.ReflectionUtils;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.XmlStreamReader;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import com.google.inject.Module;
/**
* TODO: add a way to use the plugin POM for the lookup so that the user doesn't have to provide the a:g:v:goal
* as the role hint for the mojo lookup.
......@@ -83,11 +94,42 @@ import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
* descriptor and make this entirely declarative!
*
* @author jesse
* @version $Id: AbstractMojoTestCase.java 1345446 2012-06-02 05:52:30Z hboutemy $
* @version $Id$
*/
public abstract class AbstractMojoTestCase
extends PlexusTestCase
{
private static final DefaultArtifactVersion MAVEN_VERSION;
static
{
DefaultArtifactVersion version = null;
String path = "/META-INF/maven/org.apache.maven/maven-core/pom.properties";
InputStream is = AbstractMojoTestCase.class.getResourceAsStream( path );
try
{
Properties properties = new Properties();
if ( is != null )
{
properties.load( is );
}
String property = properties.getProperty( "version" );
if ( property != null )
{
version = new DefaultArtifactVersion( property );
}
}
catch ( IOException e )
{
// odd, where did this come from
}
finally
{
IOUtil.close( is );
}
MAVEN_VERSION = version;
}
private ComponentConfigurator configurator;
private PlexusContainer container;
......@@ -104,11 +146,14 @@ public abstract class AbstractMojoTestCase
protected void setUp()
throws Exception
{
assertTrue( "Maven 3.2.4 or better is required",
MAVEN_VERSION == null || new DefaultArtifactVersion( "3.2.3" ).compareTo( MAVEN_VERSION ) < 0 );
configurator = getContainer().lookup( ComponentConfigurator.class, "basic" );
InputStream is = getClass().getResourceAsStream( "/" + getPluginDescriptorLocation() );
XmlStreamReader reader = ReaderFactory.newXmlReader( is );
XmlStreamReader reader = new XmlStreamReader( is );
InterpolationFilterReader interpolationFilterReader =
new InterpolationFilterReader( new BufferedReader( reader ), container.getContext().getContextData() );
......@@ -119,7 +164,8 @@ public abstract class AbstractMojoTestCase
lookup( RepositorySystem.class ).createArtifact( pluginDescriptor.getGroupId(),
pluginDescriptor.getArtifactId(),
pluginDescriptor.getVersion(), ".jar" );
artifact.setFile( new File( getBasedir() ).getCanonicalFile() );
artifact.setFile( getPluginArtifactFile() );
pluginDescriptor.setPluginArtifact( artifact );
pluginDescriptor.setArtifacts( Arrays.asList( artifact ) );
......@@ -135,6 +181,63 @@ public abstract class AbstractMojoTestCase
}
}
/**
* Returns best-effort plugin artifact file.
* <p>
* First, attempts to determine parent directory of META-INF directory holding the plugin descriptor. If META-INF
* parent directory cannot be determined, falls back to test basedir.
*/
private File getPluginArtifactFile()
throws IOException
{
final String pluginDescriptorLocation = getPluginDescriptorLocation();
final URL resource = getClass().getResource( "/" + pluginDescriptorLocation );
File file = null;
// attempt to resolve relative to META-INF/maven/plugin.xml first
if ( resource != null )
{
if ( "file".equalsIgnoreCase( resource.getProtocol() ) )
{
String path = resource.getPath();
if ( path.endsWith( pluginDescriptorLocation ) )
{
file = new File( path.substring( 0, path.length() - pluginDescriptorLocation.length() ) );
}
}
else if ( "jar".equalsIgnoreCase( resource.getProtocol() ) )
{
// TODO is there a helper for this somewhere?
try
{
URL jarfile = new URL( resource.getPath() );
if ( "file".equalsIgnoreCase( jarfile.getProtocol() ) )
{
String path = jarfile.getPath();
if ( path.endsWith( pluginDescriptorLocation ) )
{
file =
new File( path.substring( 0, path.length() - pluginDescriptorLocation.length() - 2 ) );
}
}
}
catch ( MalformedURLException e )
{
// not jar:file:/ URL, too bad
}
}
}
// fallback to test project basedir if couldn't resolve relative to META-INF/maven/plugin.xml
if ( file == null || ! file.exists() )
{
file = new File( getBasedir() );
}
return file.getCanonicalFile();
}
protected InputStream getPublicDescriptorStream()
throws Exception
{
......@@ -156,7 +259,9 @@ public abstract class AbstractMojoTestCase
ContainerConfiguration cc = setupContainerConfiguration();
try
{
container = new DefaultPlexusContainer( cc );
List<Module> modules = new ArrayList<Module>();
addGuiceModules( modules );
container = new DefaultPlexusContainer( cc, modules.toArray( new Module[modules.size()] ) );
}
catch ( PlexusContainerException e )
{
......@@ -165,11 +270,25 @@ public abstract class AbstractMojoTestCase
}
}
/**
* @since 3.0.0
*/
protected void addGuiceModules( List<Module> modules )
{
// no custom guice modules by default
}
protected ContainerConfiguration setupContainerConfiguration()
{
ClassWorld classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() );
return new DefaultContainerConfiguration().setClassWorld( classWorld ).setName( "embedder" );
ContainerConfiguration cc = new DefaultContainerConfiguration()
.setClassWorld( classWorld )
.setClassPathScanning( PlexusConstants.SCANNING_INDEX )
.setAutoWiring( true )
.setName( "maven" );
return cc;
}
protected PlexusContainer getContainer()
......@@ -353,10 +472,15 @@ public abstract class AbstractMojoTestCase
{
configuration = new Xpp3Dom( "configuration" );
}
configuration = Xpp3Dom.mergeXpp3Dom( execution.getConfiguration(), configuration );
configuration = Xpp3Dom.mergeXpp3Dom( configuration, execution.getConfiguration() );
PlexusConfiguration pluginConfiguration = new XmlPlexusConfiguration( configuration );
if ( mojoDescriptor.getComponentConfigurator() != null )
{
configurator = getContainer().lookup( ComponentConfigurator.class, mojoDescriptor.getComponentConfigurator() );
}
configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() );
return mojo;
......@@ -373,7 +497,7 @@ public abstract class AbstractMojoTestCase
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
MavenExecutionResult result = new DefaultMavenExecutionResult();
MavenSession session = new MavenSession( container, new MavenRepositorySystemSession(), request, result );
MavenSession session = new MavenSession( container, MavenRepositorySystemUtils.newSession(), request, result );
session.setCurrentProject( project );
session.setProjects( Arrays.asList( project ) );
return session;
......@@ -388,7 +512,7 @@ public abstract class AbstractMojoTestCase
protected MojoExecution newMojoExecution( String goal )
{
MojoDescriptor mojoDescriptor = mojoDescriptors.get( goal );
assertNotNull( mojoDescriptor );
assertNotNull(String.format("The MojoDescriptor for the goal %s cannot be null.", goal), mojoDescriptor );
MojoExecution execution = new MojoExecution( mojoDescriptor );
finalizeMojoConfiguration( execution );
return execution;
......