This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'eclipse' | |
apply plugin: 'maven' | |
configurations { taskdef } | |
repositories { mavenCentral() } | |
dependencies { taskdef 'java2html:j2h:1.3.1' } | |
task java2html << { | |
def basedir = '.' | |
ant.taskdef(name:'java2html' | |
,classpath:configurations.taskdef.asPath | |
, classname:"com.java2html.Java2HTMLTask" | |
) | |
ant.java2html{ | |
fileset(dir: 'src/main/java'){ | |
include (name: '*.java') | |
} | |
} | |
} | |
configurationsプロパティにconifgurationを独自に定義するのがミソ。ここでは、taskdefという名前のconfigurationを作成している。
dependenciesプロパティにカスタムAntタスクが依存するモジュール(ここではJava2HTML Toolのjava2htmlタスク)を記述する際に、このtaskdefというconfigurationを使用する。
ant.taskdefでカスタムAntタスクを定義する方法は、GroovyでAntBuilderを使用する場合と同じ(というか、AntBuilderそのもの)だが、classpathを指定する際に、conifgurationのasPathプロパティを使用する。
関連リンク
- Gradle本家ユーザガイド
- Chapter 17. Using Ant from Gradle
- 17.1.1. Using custom Ant tasks in your build を参照
- Chapter 17. Using Ant from Gradle
0 件のコメント:
コメントを投稿