Skip to content

Commit

Permalink
Bug 414645 : limit runtime-scoped dependencies visibility to test cla…
Browse files Browse the repository at this point in the history
…sspath

Change-Id: Id128d2a867968463d4a6bc8a35f93a6bdfc8ead8
Signed-off-by: Fred Bricon <fbricon@gmail.com>
  • Loading branch information
fbricon committed Aug 21, 2018
1 parent ae8412f commit a7c65e3
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,18 @@ public boolean include(Artifact artifact) {
entry = classpath.addProjectEntry(projectPath);
ProjectTestAttributes testAttributes = projectTestAttributes.get(projectPath);
if(testAttributes == null) {
testAttributes = new ProjectTestAttributes(isTestScope(a), !isTestArtifact(a));
testAttributes = new ProjectTestAttributes(isOnlyVisibleByTests(a), !isTestArtifact(a));
projectTestAttributes.put(projectPath, testAttributes);
} else {
testAttributes.isTest &= isTestScope(a);
testAttributes.isTest &= isOnlyVisibleByTests(a);
testAttributes.excludeTestSources &= !isTestArtifact(a);
}

} else {
File artifactFile = a.getFile();
if(artifactFile != null /*&& artifactFile.canRead()*/) {
entry = classpath.addLibraryEntry(Path.fromOSString(artifactFile.getAbsolutePath()));
entry.setClasspathAttribute(IClasspathManager.TEST_ATTRIBUTE, isTestScope(a) ? "true" : null);
entry.setClasspathAttribute(IClasspathManager.TEST_ATTRIBUTE, isOnlyVisibleByTests(a) ? "true" : null);
}
}

Expand All @@ -158,8 +158,8 @@ public boolean include(Artifact artifact) {
});
}

private boolean isTestScope(Artifact a) {
return Artifact.SCOPE_TEST.equals(a.getScope());
private boolean isOnlyVisibleByTests(Artifact a) {
return Artifact.SCOPE_TEST.equals(a.getScope()) || Artifact.SCOPE_RUNTIME.equals(a.getScope());
}

private boolean isTestArtifact(Artifact a) {
Expand Down

0 comments on commit a7c65e3

Please sign in to comment.