I don't use any repositories. All the jar files required for compiling the project are contained within a sub-directory of the project. I use TestNG for unit testing.
Ive found Gradle easier to use than Maven, not least because the documentation is clearer with examples all the way through. In addition, setting up Gradle for small projects seems to require a lot less effort.
This is the contents of build.gradle, which is placed in the root directory of the project. ./lib contains all the required jar files for the source, which is in ./src. Likewise, the test code is in ./test/src, and associated libraries (I.e TestNG's libraries) are in ./test/lib.
You don't need to include the "jar" section unless your planning on deploying the project as a jar file.
apply plugin: 'java'
sourceCompatibility = 1.6
version = '1.0'
dependencies {
compile files(fileTree(dir: 'lib', includes: ['*.jar']))
testCompile files(fileTree(dir: 'test/lib', includes: ['*.jar']))
}
sourceSets {
main {
java {
srcDir 'src'
}
}
test {
java {
srcDir 'test/src'
}
}
}
jar {
manifest {
attributes 'Implementation-Title': 'My Project',
'Implementation-Version': version,
'Main-Class': 'package.Main'
}
}
test {
useTestNG()
}
0 comments:
Post a Comment