Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle resource are copied to resource/test not classes/test #737

Closed
peterquiel opened this issue Apr 15, 2019 · 8 comments
Closed

Gradle resource are copied to resource/test not classes/test #737

peterquiel opened this issue Apr 15, 2019 · 8 comments
Assignees
Milestone

Comments

@peterquiel
Copy link
Contributor

peterquiel commented Apr 15, 2019

The following configuration form the documentation ensures, that resource files in source directory are respected

sourceSets {
    test {
        resources {
            srcDir file('src/test/java')
            exclude '**/*.java'
        }
    }
}

With this configuration the resource files are copied to build/resource/test folder where they are not picked every relative to class method.

Changing the resource output directory to build/classes/java/test solves this problem.

sourceSets {
    test {
        output.resourcesDir = "build/classes/java/test"
   }
}

I personally find it surprising that the com.intuit.karate.Runner#runFeature(java.lang.Class, java.lang.String, java.util.Map<java.lang.String,java.lang.Object>, boolean)
and com.intuit.karate.Runner#runFeature(java.lang.String, java.util.Map<java.lang.String,java.lang.Object>, boolean) behaves different.

@ptrthomas
Copy link
Member

sounds like a gradle thing, marking this ticket as "help wanted" as we use maven

@peterquiel
Copy link
Contributor Author

peterquiel commented Apr 16, 2019

Could it be an option for you to create a fallback in the 'relative feature file resolving' method?

Something like: If don't find the feature file next to the class file, I will try to create a class path lookup for the feature like its done in all the classpath:com.x.y.karate.feature lookup methods.

Happy to create a PR...

@ptrthomas
Copy link
Member

ptrthomas commented Apr 16, 2019

I don't remember the details - but that routine has been through a few iterations to get resources within JAR files to work #520

not able to follow what you mean about the "behaves different", maybe you can add a test here: https://github.com/intuit/karate/blob/master/karate-core/src/test/java/com/intuit/karate/RunnerTest.java - and yes a PR sounds good

@peterquiel
Copy link
Contributor Author

peterquiel commented Apr 17, 2019

I created a PR #739 to fix the gradle build in karate-demo.
I will have a deeper look into the FileUtils/Resource lookup stuff in order to explain the problem in detail.

@peterquiel
Copy link
Contributor Author

I created a Test in my personal repository because it's tricky to reproduce the behavior with maven.

I hope this test explains the problem:
https://github.com/peterquiel/karate-experiment/blob/master/src/test/groovy/com/github/peterquiel/karate/experiment/CallFeatureFromJavaTest.groovy#L25

Here is a naive solution to the problem:
develop...peterquiel:experiment-to-solve-relative-resource-loading-with-gradle

@ptrthomas ptrthomas added this to the 0.9.3 milestone Apr 23, 2019
@ptrthomas ptrthomas modified the milestone: 0.9.3 May 4, 2019
@ptrthomas
Copy link
Member

@peterquiel it looks ok to me, you can go ahead with a PR if it doesn't break any existing tests.

@peterquiel
Copy link
Contributor Author

peterquiel commented May 8, 2019

Done: #764

ptrthomas added a commit that referenced this issue May 8, 2019
…ng-with-gradle

#737 - relative resource loading with gradle
@ptrthomas
Copy link
Member

released 0.9.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants