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

Failed to resolve test scope #759

Closed
jdneo opened this issue Aug 1, 2019 · 3 comments · Fixed by #762
Closed

Failed to resolve test scope #759

jdneo opened this issue Aug 1, 2019 · 3 comments · Fixed by #762
Labels
Milestone

Comments

@jdneo
Copy link
Member

jdneo commented Aug 1, 2019

@jdneo Thanks for working this through with everyone! I'm experiencing another weird issue, related to this--

My .classpath does not by default generate the for my test sources, and my configuration is a bit complicated, so instead of a re-work I implemented this into my build.gradle:

def testSources = entries.findAll {element -> element.path == "src/test/java" || element.path == "src/test/resources" || element.path == "src/integrationTest/java" || element.path == "src/integrationTest/resources" }
  testSources.forEach { entry -> 
    entry.entryAttributes['test'] = 'true'
  }
}

This adds the test attribute, but at the bottom, see here:
Not Working ClassPath Gist

This does not work. However, if I let Eclipse do it , it generates the same xml, but with the test attribute at top, and it DOES work:
Working ClassPath Gist

Originally posted by @tthorntone in #470 (comment)

@jdneo
Copy link
Member Author

jdneo commented Aug 1, 2019

@tthorntone the implementation is here:

public static boolean isTest(IClasspathEntry entry) {
if (entry.getEntryKind() != ClasspathEntry.CPE_SOURCE) {
return false;
}
for (final IClasspathAttribute attribute : entry.getExtraAttributes()) {
if (MAVEN_SCOPE_ATTRIBUTE.equals(attribute.getName()) ||
GRADLE_SCOPE_ATTRIBUTE.equals(attribute.getName())) {
return TEST_SCOPE.equals(attribute.getValue());
}
if (TEST_SCOPE.equals(attribute.getName())) {
return "true".equalsIgnoreCase(attribute.getValue());
}
}
return entry.isTest();

It seems that there are two potential issues there:

  • It should keep searching instead of just returning in line 128.
  • We only consider test in the scope attribute, but ignored the integrationTest.

Is it possible for you to share a sample project to us? I can use that to do some validation.

Thanks.

@tthorntone
Copy link

@jdneo sorry for my delayed response-- I tested this change and it worked! Thank you so much.

@jdneo
Copy link
Member Author

jdneo commented Aug 3, 2019

@tthorntone Glad to know the problem is solved. Thank you for the information!

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