Skip to content

Commit 53c1d08

Browse files
jdneorougsig
authored andcommitted
Add more attributes to the classpath entries
Signed-off-by: sheche <[email protected]>
1 parent 5e5b913 commit 53c1d08

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/main/groovy/com/google/protobuf/gradle/Utils.groovy

+9
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ class Utils {
156156
SourceFolder entry = new SourceFolder(relativePath, getOutputPath(cp, sourceSetName))
157157
entry.entryAttributes.put("optional", "true")
158158
entry.entryAttributes.put("ignore_optional_problems", "true")
159+
160+
entry.entryAttributes.put("gradle_scope", isTest ? "test" : "main")
161+
entry.entryAttributes.put("gradle_used_by_scope", isTest ? "test" : "main,test")
162+
163+
// this attribute is optional, but it could be useful for IDEs to recognize that it is
164+
// generated source folder from protobuf, thus providing some support for that.
165+
// e.g. Hint user to run generate tasks if the folder is empty or does not exist.
166+
entry.entryAttributes.put("protobuf_generated_source", "true")
167+
159168
// check if output is not null here because test source folder
160169
// must have a separate output folder in Eclipse
161170
if (entry.output != null && isTest) {

src/test/groovy/com/google/protobuf/gradle/ProtobufJavaPluginTest.groovy

+10-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,16 @@ class ProtobufJavaPluginTest extends Specification {
437437
438438
Set<String> sourceDir = [] as Set
439439
srcEntries.each {
440-
sourceDir.add(it.@path)
440+
String path = it.@path
441+
sourceDir.add(path)
442+
if (path.startsWith("build/generated/source/proto")) {
443+
if (path.contains("test")) {
444+
// test source path has one more attribute: ["test"="true"]
445+
assert it.attributes.attribute.size() == 6
446+
} else {
447+
assert it.attributes.attribute.size() == 5
448+
}
449+
}
441450
}
442451
443452
Set<String> expectedSourceDir = ImmutableSet.builder()

0 commit comments

Comments
 (0)