mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#202 allow remote debugging an intetegration test using a command like "mvn test -Dtest=SimpleTest#oracle_java_6 -DprocessorIntegrationTest.debug=true"
This commit is contained in:
parent
15aa13012e
commit
e9a74d1fc0
@ -47,6 +47,16 @@ import static org.apache.maven.shared.utils.io.FileUtils.deleteDirectory;
|
||||
*/
|
||||
public class ProcessorSuiteRunner extends ParentRunner<ProcessorTestCase> {
|
||||
|
||||
/**
|
||||
* System property for specifying the location of the toolchains.xml file
|
||||
*/
|
||||
public static final String SYS_PROP_TOOLCHAINS_FILE = "processorIntegrationTest.toolchainsFile";
|
||||
|
||||
/**
|
||||
* System property to enable remote debugging of the processor execution in the integration test
|
||||
*/
|
||||
public static final String SYS_PROP_DEBUG = "processorIntegrationTest.debug";
|
||||
|
||||
public static final class ProcessorTestCase {
|
||||
private final String baseDir;
|
||||
private final ProcessorType processor;
|
||||
@ -147,7 +157,22 @@ public class ProcessorSuiteRunner extends ParentRunner<ProcessorTestCase> {
|
||||
File destination = extractTest( child, description );
|
||||
PrintStream originalOut = System.out;
|
||||
|
||||
Verifier verifier = new Verifier( destination.getCanonicalPath() );
|
||||
final Verifier verifier;
|
||||
if ( Boolean.getBoolean( SYS_PROP_DEBUG ) ) {
|
||||
if ( child.processor.getToolchain() == null ) {
|
||||
// when not using toolchains for a test, then the compiler is executed within the Maven JVM. So make
|
||||
// sure we fork a new JVM for that, and let that new JVM use the command 'mvnDebug' instead of 'mvn'
|
||||
verifier = new Verifier( destination.getCanonicalPath(), null, true, true );
|
||||
verifier.setDebugJvm( true );
|
||||
}
|
||||
else {
|
||||
verifier = new Verifier( destination.getCanonicalPath() );
|
||||
verifier.addCliOption( "-Pdebug-forked-javac" );
|
||||
}
|
||||
}
|
||||
else {
|
||||
verifier = new Verifier( destination.getCanonicalPath() );
|
||||
}
|
||||
|
||||
List<String> goals = new ArrayList<String>( 3 );
|
||||
|
||||
@ -166,6 +191,11 @@ public class ProcessorSuiteRunner extends ParentRunner<ProcessorTestCase> {
|
||||
verifier.addCliOption( "-Dmapstruct-artifact-id=mapstruct" );
|
||||
}
|
||||
|
||||
if ( Boolean.getBoolean( SYS_PROP_DEBUG ) ) {
|
||||
originalOut.print( "Processor Integration Test: " );
|
||||
originalOut.println( "Listening for transport dt_socket at address: 8000 (in some seconds)" );
|
||||
}
|
||||
|
||||
goals.add( "test" );
|
||||
|
||||
originalOut.println( "executing " + child.processor.name().toLowerCase() );
|
||||
@ -222,7 +252,7 @@ public class ProcessorSuiteRunner extends ParentRunner<ProcessorTestCase> {
|
||||
}
|
||||
|
||||
private static File getSpecifiedToolchainsFile() {
|
||||
String specifiedToolchainsFile = System.getProperty( "processorIntegrationTest.toolchainsFile" );
|
||||
String specifiedToolchainsFile = System.getProperty( SYS_PROP_TOOLCHAINS_FILE );
|
||||
if ( null != specifiedToolchainsFile ) {
|
||||
try {
|
||||
File canonical = new File( specifiedToolchainsFile ).getCanonicalFile();
|
||||
|
@ -115,6 +115,34 @@
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>debug-forked-javac</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-compile</id>
|
||||
<configuration>
|
||||
<fork>true</fork>
|
||||
<compilerArgs>
|
||||
<arg>-J-Xdebug</arg>
|
||||
<arg>-J-Xnoagent</arg>
|
||||
<arg>-J-Djava.compiler=NONE</arg>
|
||||
<arg>-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
|
@ -43,6 +43,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<com.jolira.hickory.version>1.0.0</com.jolira.hickory.version>
|
||||
<org.apache.maven.plugins.enforcer.version>1.2</org.apache.maven.plugins.enforcer.version>
|
||||
<org.apache.maven.plugins.surefire.version>2.17</org.apache.maven.plugins.surefire.version>
|
||||
<org.springframework.version>4.0.3.RELEASE</org.springframework.version>
|
||||
|
||||
<forkCount>1</forkCount>
|
||||
@ -200,11 +201,11 @@
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.shared</groupId>
|
||||
<artifactId>maven-verifier</artifactId>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.shared</groupId>
|
||||
<artifactId>maven-verifier</artifactId>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Not directly used but required for dependency convergence -->
|
||||
<dependency>
|
||||
@ -337,10 +338,17 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<version>${org.apache.maven.plugins.surefire.version}</version>
|
||||
<configuration>
|
||||
<forkCount>${forkCount}</forkCount>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.surefire</groupId>
|
||||
<artifactId>surefire-junit47</artifactId>
|
||||
<version>${org.apache.maven.plugins.surefire.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.mycila.maven-license-plugin</groupId>
|
||||
@ -425,16 +433,16 @@
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.7.1.201405082137</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jvnet.jaxb2.maven2</groupId>
|
||||
<artifactId>maven-jaxb2-plugin</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>properties-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jvnet.jaxb2.maven2</groupId>
|
||||
<artifactId>maven-jaxb2-plugin</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>properties-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user