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

Error with compileTestJava task: Cannot find sources from src folder #198

Open
d-eder opened this issue Sep 18, 2024 · 0 comments
Open

Error with compileTestJava task: Cannot find sources from src folder #198

d-eder opened this issue Sep 18, 2024 · 0 comments

Comments

@d-eder
Copy link

d-eder commented Sep 18, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant