Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Gradle handle a build directory structure that does not conform default conventions?

Tags:

I am working on a java ant+ivy based project that has the following directory structure:

projectRoot/src projectRoot/classes projectRoot/conf projectRoot/webservices 

this works perfectly well in ant but I am looking to migrate to gradle.

Is there a way to define a non-maven directory structure in Gradle or should I be looking to mavenize?

like image 219
liam.j.bennett Avatar asked Mar 31 '10 08:03

liam.j.bennett


People also ask

Why is Gradle build failing?

When Gradle is unable to communicate with the Gradle daemon process, the build will immediately fail with a message similar to this: $ gradle help Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details FAILURE: Build failed with an exception.

What is buildSrc in gradle?

buildSrc is a separate build whose purpose is to build any tasks, plugins, or other classes which are intended to be used in build scripts of the main build, but don't have to be shared across builds.

What is testImplementation in gradle?

Configuration inheritance and composition For example the testImplementation configuration extends the implementation configuration. The configuration hierarchy has a practical purpose: compiling tests requires the dependencies of the source code under test on top of the dependencies needed write the test class.

Where does gradle store dependencies locally?

The Gradle dependency cache consists of two storage types located under GRADLE_USER_HOME/caches : A file-based store of downloaded artifacts, including binaries like jars as well as raw downloaded meta-data like POM files and Ivy files.


2 Answers

It is very easy with Gradle to adapt to any directory structure. See the Working with source sets section of the Gradle User Guide.

like image 142
Hans Dockter Avatar answered Sep 18 '22 17:09

Hans Dockter


Example with non-standard project directory structure (custom layout):

sourceSets {     main {         java {             srcDir 'sources/main/java'         }         outputDir = file("$workDir/client/program")         // For older version (now deprecated):         //output.classesDir = "$workDir/client/program"     }     test {         java {             srcDir 'sources/test/java'         }         outputDir = file("$workDir/client/tests")         // For older versions (now deprecated):         //output.classesDir = "$workDir/client/tests"         //output.resourcesDir = "$workDir/client/tests"     }     resources {         srcDirs 'sources/test/res'     } } 
like image 30
Dimitar II Avatar answered Sep 22 '22 17:09

Dimitar II