autoconfigure-gradle-plugin
autoconfigure-gradle-plugin copied to clipboard
Error with compileTestJava task: Cannot find sources from src folder
Description
I'm currently setting up a java project with the autoconfigure-gradle-plugin.
When building the application, the gradle task compileTestJava
complains because it cannot find a class which is used in the test.
When I remove the autoconfigure-gradle-plugin, everything is working as expected
Error message
...\src\test\java\anytestpackage\DummyTest.java:4: error: package anypackage does not exist
import anypackage.DummyService;
^
Code
Test
in Folder server-app/src/test/java/anytestpackage
package anytestpackage;
import org.junit.jupiter.api.Test;
import anypackage.DummyService;
public class DummyTest {
@Test
void test(){
var x = DummyService.class;
}
}
Service
in Folder server-app/src/main/java/anypackage
package anypackage;
import org.springframework.stereotype.Service;
@Service
public class DummyService {
public void test(){
throw new RuntimeException("x");
}
}
build.gradle.kts
plugins {
java
`java-test-fixtures`
id("io.cloudflight.autoconfigure-gradle") version "1.1.1"
}
group = "at.test"
version = "0.0.1-SNAPSHOT"
autoConfigure {
java {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
allprojects {
repositories {
mavenCentral()
}
}
subprojects {
apply(plugin = "java")
apply(plugin = "java-test-fixtures")
configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}
dependencies {
implementation(platform("io.cloudflight.platform.spring:platform-spring-bom:2.4.2"))
annotationProcessor(platform("io.cloudflight.platform.spring:platform-spring-bom:2.4.2"))
testImplementation(platform("io.cloudflight.platform.spring:platform-spring-test-bom:2.4.2"))
testFixturesImplementation(platform("io.cloudflight.platform.spring:platform-spring-test-bom:2.4.2"))
implementation("org.springframework.boot:spring-boot-starter")
compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testFixturesImplementation("org.springframework.boot:spring-boot-starter-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
tasks.test {
useJUnitPlatform()
}
}
Environment
- Java 21
- Gradle 8.10.1