$ cat build.gradle
/*
* This build file was auto generated by running the Gradle 'buildSetup' task
* by 'mike' at '13/07/09 11:19' with Gradle 1.7-rc-1
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at http://gradle.org/docs/1.7-rc-1/userguide/tutorial_java_projects.html
*/
// Apply the java plugin to add support for Java
apply plugin: 'java'
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'maven central' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
}
// In this section you declare the dependencies for your production and test code
dependencies {
// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.5'
// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
testCompile "junit:junit:4.11"
}
作成されたbuild.gradleファイルでは
javaプラグインが適用されている
slf4jがコンパイル用のライブラリーとして登録されている
JUnitがテスト用のライブラリーとして登録されている
ようです。
また、サンプルのプロダクションコードとテストコードが生成されるということですが、
src/main/java/Library.java
src/test/java/LibraryTest.java
の二つのファイルが作成されています。
それぞれの中身は次のようになっています。
Library.java
1234567891011
/* * This Java source file was auto generated by running 'gradle buildSetup --type java-library' * by 'mike' at '13/07/09 11:19' with Gradle 1.7-rc-1 * * @author mike, @date 13/07/09 11:19 */publicclassLibrary{publicbooleansomeLibraryMethod(){returntrue;}}
LibraryTest.java
123456789101112131415
importorg.junit.Test;importstaticorg.junit.Assert.*;/* * This Java source file was auto generated by running 'gradle buildSetup --type java-library' * by 'mike' at '13/07/09 11:19' with Gradle 1.7-rc-1 * * @author mike, @date 13/07/09 11:19 */publicclassLibraryTest{@TestpublicvoidtestSomeLibraryMethod(){LibraryclassUnderTest=newLibrary();assertTrue("someLibraryMethod should return 'true'",classUnderTest.someLibraryMethod());}}