사용자 도구

사이트 도구


gradle:java

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
gradle:java [2017/01/03 17:46]
kwon37xi [JavaExec]
gradle:java [2018/11/15 14:26]
kwon37xi [Java 9 HTML5 javadoc]
줄 39: 줄 39:
  
 // 소스 인코딩 지정방법 1 // 소스 인코딩 지정방법 1
-[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'+[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
 // 소스 인코딩 지정밥법 2 // 소스 인코딩 지정밥법 2
 tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
 +    options.encoding = 'UTF-8'
 +}
 +javadoc {
     options.encoding = 'UTF-8'     options.encoding = 'UTF-8'
 } }
줄 269: 줄 272:
 |title | String | 프로젝트 이름과 버전 | |title | String | 프로젝트 이름과 버전 |
   * [[http://www.gradle.org/docs/current/javadoc/org/gradle/external/javadoc/StandardJavadocDocletOptions.html|StandardJavadocDocletOptions (Gradle API 1.10)]] 참조하여 javadoc 옵션들 지정.   * [[http://www.gradle.org/docs/current/javadoc/org/gradle/external/javadoc/StandardJavadocDocletOptions.html|StandardJavadocDocletOptions (Gradle API 1.10)]] 참조하여 javadoc 옵션들 지정.
 +
 +==== Java 9 HTML5 javadoc ====
 +  * [[java:9|Java 9]]부터 HTML5 Javadoc 생성가능함.
 +  * [[http://mrhaki.blogspot.com/2018/11/gradle-goodness-generate-javadoc-in.html|Gradle Goodness: Generate Javadoc In HTML5]]
 +<code>
 +javadoc {
 +    options.addBooleanOption('html5', true)
 +}
 +</code>
 +
  
 ==== 멀티 모듈의 소스를 합쳐 Javadoc 생성 ==== ==== 멀티 모듈의 소스를 합쳐 Javadoc 생성 ====
줄 466: 줄 479:
   * ''@Test'' 어노테이션을 가진 메소드가 있는 클래스   * ''@Test'' 어노테이션을 가진 메소드가 있는 클래스
  
-==== 테스트의 분리 ====+==== 테스트의 분리 - 소스셋이 동일하고 이름으로 구분 - 더이상 사용하지 말 것 ====
   * ''*Test'' 와 ''*IntegrationTest''를 분리해서 실행하고자 하는 경우가 있을 수 있다.   * ''*Test'' 와 ''*IntegrationTest''를 분리해서 실행하고자 하는 경우가 있을 수 있다.
   * [[http://java.dzone.com/articles/gradle-goodness-running-single|Gradle goodness - Running Single Test 참조]]   * [[http://java.dzone.com/articles/gradle-goodness-running-single|Gradle goodness - Running Single Test 참조]]
줄 494: 줄 507:
 } }
 </code> </code>
 +
 +==== 테스트의 분리 - 소스셋 분리 - 권장 ====
 +  * [[https://www.petrikainulainen.net/programming/gradle/getting-started-with-gradle-integration-testing/|Getting Started With Gradle: Integration Testing]] 참조. 단, Gradle 버전업에 따른 변경 필요.
 +
 +<code groovy>
 +// 별도 소스셋 구성
 +sourceSets {
 +    integrationTest {
 +        java {
 +            compileClasspath += main.output + test.output
 +            runtimeClasspath += main.output + test.output
 +            srcDir file('src/integration-test/java')
 +        }
 +        groovy { // for Spock
 +            compileClasspath += main.output + test.output
 +             runtimeClasspath += main.output + test.output
 +            srcDir file('src/integration-test/groovy')
 +        }
 +        resources.srcDir file('src/integration-test/resources')
 +    }
 +}
 +
 +// integrationTest 전용 configuration 지정.
 +// integrationTest에만 필요한 의존성 지정 가능.
 +
 +configurations {
 +    integrationTestCompile.extendsFrom testCompile
 +    integrationTestRuntime.extendsFrom testRuntime
 +}
 +
 +// Task 생성
 +task integrationTest(type: Test) {
 +    testClassesDirs = sourceSets.integrationTest.output.classesDirs // 구버전에서는 Dir 단수형으로만 지정됨.
 +    classpath = sourceSets.integrationTest.runtimeClasspath
 +    reports { // reports 는 원하는대로만.
 +        junitXml.enabled = true
 +        html.enabled = true
 +        ignoreFailures = true
 +    }
 +}
 +
 +// 의존성 지정으로 check 실행시 자동 테스트
 +check.dependsOn integrationTest
 +</code>
 +
 +==== TestSets Plugin 사용 ====
 +  * [[https://www.petrikainulainen.net/programming/gradle/getting-started-with-gradle-integration-testing-with-the-testsets-plugin/|Getting Started With Gradle: Integration Testing With the TestSets Plugin]]
 +  * [[https://www.testwithspring.com/lesson/running-integration-tests-with-gradle-spock-edition/|Running Integration Tests With Gradle – Spock Edition]]
 +  * TBD
  
 ==== Convention Values ==== ==== Convention Values ====
gradle/java.txt · 마지막으로 수정됨: 2022/06/30 16:36 저자 kwon37xi