changeset 451:d1f2c90bd7f6

jmh-core-it: optionally run integration tests with ASMv4 generators, bypassing annotation processors.
author shade
date Sat, 01 Mar 2014 01:28:16 +0400
parents a0bc675db202
children 6a621d0090e7
files jmh-core-it/pom.xml jmh-generator-maven-plugin/src/main/java/org/openjdk/jmh/JmhMojo.java
diffstat 2 files changed, 126 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core-it/pom.xml	Sat Mar 01 01:24:06 2014 +0400
+++ b/jmh-core-it/pom.xml	Sat Mar 01 01:28:16 2014 +0400
@@ -47,7 +47,12 @@
         <dependency>
             <groupId>org.openjdk.jmh</groupId>
             <artifactId>jmh-core</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.openjdk.jmh</groupId>
+            <artifactId>jmh-generator-maven-plugin</artifactId>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>junit</groupId>
@@ -69,16 +74,6 @@
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.0</version>
-                <configuration>
-                    <compilerVersion>1.6</compilerVersion>
-                    <source>1.6</source>
-                    <target>1.6</target>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <version>2.14.1</version>
                 <configuration>
@@ -109,8 +104,103 @@
                     </execution>
                 </executions>
             </plugin>
-
         </plugins>
     </build>
 
+    <profiles>
+        <profile>
+            <id>default</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <version>3.0</version>
+                        <configuration>
+                            <compilerVersion>1.6</compilerVersion>
+                            <source>1.6</source>
+                            <target>1.6</target>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <profile>
+            <id>asm</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <version>3.0</version>
+                        <configuration>
+                            <compilerVersion>1.6</compilerVersion>
+                            <source>1.6</source>
+                            <target>1.6</target>
+                            <compilerArgument>-proc:none</compilerArgument>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>compile-java</id>
+                                <phase>process-test-sources</phase>
+                                <goals>
+                                    <goal>testCompile</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>compile-jmh</id>
+                                <phase>process-test-classes</phase>
+                                <goals>
+                                    <goal>testCompile</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>build-helper-maven-plugin</artifactId>
+                        <version>1.8</version>
+                        <executions>
+                            <execution>
+                                <id>add-source</id>
+                                <phase>process-test-sources</phase>
+                                <goals>
+                                    <goal>add-test-source</goal>
+                                </goals>
+                                <configuration>
+                                    <sources>
+                                        <source>${project.build.testOutputDirectory}/generated-jmh-sources/</source>
+                                    </sources>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.openjdk.jmh</groupId>
+                        <artifactId>jmh-generator-maven-plugin</artifactId>
+                        <version>${project.version}</version>
+                        <executions>
+                            <execution>
+                                <phase>process-test-sources</phase>
+                                <goals>
+                                    <goal>generate</goal>
+                                </goals>
+                                <configuration>
+                                    <compiledBytecodeDirectory>${project.build.testOutputDirectory}</compiledBytecodeDirectory>
+                                    <outputResourceDirectory>${project.build.testOutputDirectory}</outputResourceDirectory>
+                                    <outputSourceDirectory>${project.build.testOutputDirectory}/generated-jmh-sources/</outputSourceDirectory>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+    </profiles>
+
 </project>
--- a/jmh-generator-maven-plugin/src/main/java/org/openjdk/jmh/JmhMojo.java	Sat Mar 01 01:24:06 2014 +0400
+++ b/jmh-generator-maven-plugin/src/main/java/org/openjdk/jmh/JmhMojo.java	Sat Mar 01 01:28:16 2014 +0400
@@ -25,7 +25,15 @@
      * @parameter expression="${project.build.outputDirectory}"
      * @required
      */
-    private File classesDirectory;
+    private File compiledBytecodeDirectory;
+
+    /**
+     * Classes dir
+     *
+     * @parameter expression="${project.build.outputDirectory}"
+     * @required
+     */
+    private File outputResourceDirectory;
 
     /**
      * Classes dir
@@ -33,13 +41,16 @@
      * @parameter expression="${project.build.directory}/generated-sources/jmh/"
      * @required
      */
-    private File generatedSourcesDir;
+    private File outputSourceDirectory;
 
     public void execute() throws MojoExecutionException, MojoFailureException {
-        ASMGeneratorSource source = new ASMGeneratorSource(classesDirectory, generatedSourcesDir);
+        ASMGeneratorSource source = new ASMGeneratorSource(outputResourceDirectory, outputSourceDirectory);
 
         try {
-            source.processClasses(getClasses(classesDirectory));
+            Collection<File> classes = getClasses(compiledBytecodeDirectory);
+            getLog().info("Processing " + classes.size() + " classes from " + compiledBytecodeDirectory);
+            getLog().info("Writing out Java source to "  + outputSourceDirectory + " and resources to " + outputResourceDirectory);
+            source.processClasses(classes);
         } catch (IOException ioe) {
             throw new MojoExecutionException("IOException", ioe);
         }
@@ -64,12 +75,15 @@
         while (!newDirs.isEmpty()) {
             List<File> add = new ArrayList<File>();
             for (File dir : newDirs) {
-                for (File f : dir.listFiles()) {
-                    if (f.isDirectory()) {
-                        add.add(f);
-                    } else {
-                        if (f.getName().endsWith(".class")) {
-                            result.add(f);
+                File[] files = dir.listFiles();
+                if (files != null) {
+                    for (File f : files) {
+                        if (f.isDirectory()) {
+                            add.add(f);
+                        } else {
+                            if (f.getName().endsWith(".class")) {
+                                result.add(f);
+                            }
                         }
                     }
                 }