Search code examples
groovygradlebuild-script

Barebones Gradle build from lib dir


I'm struggling to configure a super simple (my 1st ever) Gradle buildscript, that will:

  1. Compile all the Groovy code under my src/main/groovy dir; compilation needs to include all the local (not from a repo) JARs stored in my lib/ directory
  2. Place that compiled code under /bin (or wherever, I really don't care)
  3. JAR up the compiled code into myapp.jar
  4. Somehow include the wrapper task so that the gradlew gets generated as is appropriate

My project dir structure:

myapp/
    src/main/groovy/
        <Groovy sources>
    bin/
    lib/
        <lots of JARs>
    build.gradle
    gradle.properties

So far this is what I've tried:

apply groovy
task compile {
    println "Compiling from src/main/groovy and lib/ to bin/"
    javac ???
}
task jar {
    println "JARring up the code"
    jar ???
}

Any help or nudges in the right direction would be enormously helpful for me.


Solution

  • What You need to do is just to apply plugin: 'groovy' and add the following section:

    dependencies {
        compile fileTree(dir: 'lib', include: '*.jar')
    }