Hannes
Hannes

Reputation: 5232

Gradle: Accept resource files in src/main/java folder

Is there a way to convince Gradle to accept resource files (like XML files) as well in the src/main/java folder?

This would be great since I need to put my JavaFX XML files there ...

Upvotes: 4

Views: 1754

Answers (3)

checketts
checketts

Reputation: 14943

The equivalent Kotlin DSL would be:

sourceSets {
    main {
        resources {
            srcDirs("src/main/java")
            include("**/*.fxml")
        }
    }
}

Upvotes: 0

lance-java
lance-java

Reputation: 27952

As the name suggests src/main/java is for JAVA files. Whilst it's possible to tweak gradle's defaults to allow resources in this folder, you shouldn't (in my opinionated view).

I suggest you stick to the sensible conventions and put your xml etc in src/main/resources. This convention is followed by both Maven and Gradle.

Upvotes: -2

RaGe
RaGe

Reputation: 23637

You could define where gradle looks for resource files by doing something like this:

sourceSets {
    main {
        resources {
            srcDirs = ["src/main/java"]
            includes = ["**/*.fxml"]
        }
    }
}

Upvotes: 8

Related Questions