melix / jmh-gradle-plugin

Integrates the JMH benchmarking framework with Gradle
Apache License 2.0
676 stars 87 forks source link

jmh doesn't respect $buildDir #81

Open sherter opened 8 years ago

sherter commented 8 years ago

When setting $buildDir to something else than /build, the jmh task fails with an exception:

Processing 0 classes from /home/simon/repositories/minijavac/build/classes/jmh with "reflection" generator
Writing out Java source to /home/simon/repositories/minijavac/build/jmh-generated-sources and resources to /home/simon/repositories/minijavac/build/jmh-generated-classes
Error writing compiler hint list 
java.io.IOException: Unable to create /home/simon/repositories/minijavac/build/jmh-generated-classes/META-INF
    at org.openjdk.jmh.generators.core.FileSystemDestination.newResource(FileSystemDestination.java:56)
    at org.openjdk.jmh.generators.core.CompilerControlPlugin.finish(CompilerControlPlugin.java:101)
    at org.openjdk.jmh.generators.core.BenchmarkGenerator.complete(BenchmarkGenerator.java:128)
    at org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator.main(JmhBytecodeGenerator.java:101)

Error writing benchmark list
java.io.IOException: Unable to create /home/simon/repositories/minijavac/build/jmh-generated-classes/META-INF
    at org.openjdk.jmh.generators.core.FileSystemDestination.newResource(FileSystemDestination.java:56)
    at org.openjdk.jmh.generators.core.BenchmarkGenerator.complete(BenchmarkGenerator.java:199)
    at org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator.main(JmhBytecodeGenerator.java:101)

It looks like the path build is hardcoded somewhere or $buildDir is evaluated too early...

sgraf812 commented 8 years ago

Actually, it's not that it's hard-coded, but that there is no way we can set the buildDir before the plugins{}. One could use the old plugins syntax though.

sherter commented 8 years ago

Well, then the evaluation of the buildDir variable must be delayed (put it in the afterEvaluate section)