Gradle: resources folder visible in the IDE
Published on 16 August 2019
In an application project managed by the Gradle build manager, it is more convenient to have visibility of all folders involved in the application’s development, such as resource folders that are not in the conventional paths. For example, if I want the src/jbake folder to be visible as a 'resource folder', it is possible to do so by entering the project configuration in the IDE wizards. However, this option is not saved after the next reload of the Gradle project in the IDE. To implement this configuration permanently, the solution is to override the source path configuration in the build.gradle configuration file, as seen on lines 18, 19, 20, and 21: build.gradle
plugins {
id "java"
id "groovy"
id "org.jbake.site" version "5.0.0"
id "org.ajoberstar.git-publish" version "2.1.1"
}
repositories {
mavenCentral()
jcenter()
}
group project_group
version project_version
sourceSets {
main {
java { srcDirs = [] }
groovy { srcDirs =["src/main/java", "src/main/groovy"] }
resources {
srcDirs =[
"src/main/resources",
"src/jbake"//in order to get site src content in the IDE
]
}
}
test {
java { srcDirs = [] }
groovy { srcDirs =["src/test/java", "src/test/groovy"] }
}
}
test {
useJUnitPlatform()
}
configurations {
ivy
}
dependencies {
ivy "org.apache.ivy:ivy:$ivy_version"
implementation "org.codehaus.groovy:groovy-all:$groovy_version"
implementation "org.asciidoctor:asciidoctor-java-integration:$asciidoctor_java_integration_version"
implementation "org.freemarker:freemarker:$freemarker_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5_version"
}
gitPublish {
repoUri = github_pages_blog_repository
branch = git_branch
contents {
from(file(jbake_content_from)) {
into jbake_content_to
}
}
}
tasks.withType(GroovyCompile) {
groovyClasspath += configurations.ivy
}