Closed altro3 closed 5 years ago
Hi @altro3 ,
thanks for the report. Not sure I can follow... is this about the generated sources?
By the way, you don't need to specify dirName
on your test sets if it's the same as the test set's name :-)
In general, when using Gradle you should not make any modifications to the module settings in IDEA - those are usually overwritten by the next Gradle sync.
Hi, @tkrullmann!
Yes, I'm talking about this to you. That after the synchronization of the idea and the gradle sourceSets created of your plugin are now incorrectly determined by the idea. I repeat once again, everything works fine and synchronizes without any problems in the idea of 2018.X, the problem appeared today after I updated myself on the idea of 2019.1. Apparently, they changed something in sync and your plugin does not put some flag in the sourceSets, which would tell the idea that this directory with test classes.
Nobody talks about manual changes, but it’s about the synchronization of the Gradle project and the project in IDEA.
About dirName - thanks, i'll fix it :-)
Hah! I need to always specify the directory name. If I do not do this, then the idea refers to the directory:
.../build/generated/sources/annotationProcessor/java/inttest
I think that is second bug ;-)
I understood what the problem is: after synchronization of the gradle project and IDEA, the Web facet is automatically used in the io.klira.integration.optin-no.inttest.iml module and put the wrong path to the directory:
...
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
<sourceRoots>
<!-- that is wrong -->
<root url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/inttest" />
</sourceRoots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output-test url="file://$MODULE_DIR$/../../build/classes/java/inttest" />
<exclude-output />
<!-- That's wrong block -->
<content url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/inttest">
<sourceFolder url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/inttest" isTestSource="false" generated="true" />
</content>
<content url="file://$MODULE_DIR$/../../src/inttest">
<sourceFolder url="file://$MODULE_DIR$/../../src/inttest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/../../src/inttest/resources" type="java-test-resource" />
</content>
...
Oh, I decided to check everything in the morning: I can say that there is no serious error and everything works, what I mentioned above, perhaps, the consequence of not quite correct project update from IDEA 2018 to IDEA 2019. I mean, project files creates the idea itself.
I recreated the whole project and (oh, a miracle!) It all worked. But! Look at the screen, how the inttest module is displayed in the Project Settings. This is not critical, but there is clearly some kind of bug.
As you can see, when creating a module, the idea puts down 2 different Content Roots - one of them is correct and refers to the inttest directory, and the second to ...\build\generated\sources\annotationProcessor\java\inttest
Could you elaborate where your generated code comes from? Is it from another Gradle plugin? From an annotation processor?
That's my plugins block from build.gradle:
plugins {
id 'java'
id 'idea'
id 'jacoco'
id 'com.google.cloud.tools.jib' version '1.0.2'
id 'org.unbroken-dome.test-sets' version '2.1.1'
}
and dependencies block:
dependencies {
annotationProcessor(
platform("org.springframework.boot:spring-boot-dependencies:$ver.springBoot"),
"org.springframework.boot:spring-boot-configuration-processor",
"org.projectlombok:lombok",
)
....
testAnnotationProcessor(
platform("org.springframework.boot:spring-boot-dependencies:$ver.springBoot"),
"org.projectlombok:lombok",
)
testCompileOnly(
"org.projectlombok:lombok",
)
testImplementation(
"org.springframework.boot:spring-boot-starter-test",
"org.springframework.security:spring-security-test",
"org.junit.jupiter:junit-jupiter-api",
"org.junit.jupiter:junit-jupiter-params",
"io.projectreactor:reactor-test",
"com.squareup.okhttp3:mockwebserver:$ver.okHttp",
"io.grpc:grpc-testing:$ver.grpcTesting",
"org.apache.commons:commons-lang3",
)
testRuntimeOnly(
"org.junit.vintage:junit-vintage-engine",
"org.junit.jupiter:junit-jupiter-engine",
)
inttest sources set has same dependencies as test sources set
testSets {
inttest
}
configurations {
inttestCompileOnly.extendsFrom testCompileOnly
inttestRuntimeOnly.extendsFrom testRuntimeOnly
}
That's all. I tell, all works fine, in idea 2018.3. Problems started after upgrading to Idea 2019.1
Still can't really see the problem... you are aware that those generated
folders are there because you're using annotation processors, right? After all, most annotation processors are code generators, and they have to place the generated code somewhere so it can be included in the compilation. (Lombok is a bit of a special case since it modifies the classes in-place instead of generating additional classes, but I won't delve too deep into that). You don't want generated files in your src
directory (you would see them as added files Git), that's why Gradle places generated files somewhere under build
by default. IDEA recognizes this and makes those build/generated
folders additional source folders for your source sets.
But probably you have a point about the dirName
, that setting doesn't take generated sources into account. Shouldn't matter much though, you shouldn't have to care too much about the name of your generated sources folder.
I completely understood the problem. I tried to create my sourceSet without your plugin, and got the same problem. The problem is not that the build\generated\sources\annotationProcessor\java\inttest
directory is automatically connected, but that it is labeled as Source, and not as Test.
Since this directory is added automatically when synchronizing an idea with a gradle, this is an idea problem.
I have not found a way to indicate that the custom sourceSet is a test one and that the idea marks the build\generated\sources\annotationProcessor\java\inttest
directory as a test one. I'll have to write an issue in JetBrains.
I'm sorry to trouble you :-). Issue can be closed.
My configuration is very simple:
All works fine in IDEA 2018.X, but after update to version IDEA 2019.1 i have a problem with synchronization between IDEA and gradle (screens):
https://ibb.co/ncxYttY As you see on screen 1, now source set, created by your plugin understanding by IDEA only how sources folder, not test folder
But in Paths settings IDEA set "Test ouput path" (see screen 2) https://ibb.co/g3zdM6m
Trying to Rebuild project and we have an error:
https://ibb.co/2tTnQtR