jmh-gradle-plugin icon indicating copy to clipboard operation
jmh-gradle-plugin copied to clipboard

jmh resources folder not used

Open fabienrenaud opened this issue 7 years ago • 1 comments

I expect the files in src/jmh/resources to have precedence to the main ones (src/main/resources). This is the normal behavior for tests.

Repro:

build.gradle

plugins {
  id 'me.champeau.gradle.jmh' version '0.3.1'
}

apply plugin: 'java'

repositories {
  mavenCentral()
}

dependencies {
}

src/jmh/java/test/Bench.java

package test;

import org.openjdk.jmh.annotations.*;
import java.io.*;

public class Bench {

  @Benchmark
  public void foo() {
    InputStream is = getClass().getClassLoader().getResourceAsStream("file.txt");
    char[] buf = new char[100];
    try {
      InputStreamReader r = new InputStreamReader(is);
      r.read(buf, 0, 100);
    } catch (IOException ex) {
      ex.printStackTrace();
    }
    System.out.println(buf);
  }

}

src/jmh/resources/file.txt

jmh file

src/main/resources/file.txt

main file

Expected output: jmh file jmh file ...

Actual output: main file main file ...

Running gradle jmh copies the jmh resource folder and file correctly under build/resources/jmh/file.txt. However, the generated jar contains 2 entries for file.txt...

fabienrenaud avatar Jan 08 '17 01:01 fabienrenaud

@fabienrenaud Do you expect a file from jmh/resources to override main/resources?

vyazelenko avatar Mar 23 '17 16:03 vyazelenko