More Related Content More from Igor Khotin (7) Gradle - next generation of build tools1. Gradle next generation of build tools E-mail: khotin@gmx.com Игорь Хотинь Gradle next generation of build tools 24. m a ven тяжёлые pom.xml convention over configuration dependency management Сложно переопределить поведение по-умолчанию lost of control 34. Gradle in the wild Carrier Hibernate Grails Groovy Spring-Security Spring-Integration EADS Griffon Gaelyk Qi4j Canoo FCC Zeppelin GmhH Spock Aluminum Gant GPars 53. Groovy в Gradle build.gradle task count << { 4.times { print "$it " } } > gradle -q count 0 1 2 3 54. Dependencies build.gradle task hello << { println 'Hello world!' } task count(dependsOn: hello) << { 4.times { print "$it " } } > gradle -q count Hello world! 0 1 2 3 55. Lazy dependencies build.gradle task hello(dependsOn: 'lazy') << { println 'Hello world!' } task lazy << { println 'so lazy...' } > gradle -q hello so lazy... Hello world! 57. Java build-cycle customization build.gradle apply plugin: 'java' test.doFirst { println 'Before testing...' } test.doLast { println '...after testing.' } 58. Repos build.gradle apply plugin: 'java' repositories { mavenCentral() } dependencies { compile group: 'commons-collections', name: 'commons-collections', version: '3.2' testCompile group: 'junit', name: 'junit', version: '4.+' } 59. Ant build.gradle ant.importBuild 'build.xml' task ant << { ant.echo(message: 'hello from Ant') ant.zip(destfile: 'archive.zip') { fileset(dir: 'src') { include(name: '**.xml') exclude(name: '**.java') } } } 61. ant <?xml version="1.0"?> <project name="simple" default="dist" basedir="."> <property name="src" location="src/main/java"/> <property name="srcTest" location="src/test/java"/> <property name="build" location="build"/> <property name="dist" location="${build}/lib"/> <property name="version" value="1.0-SNAPSHOT" /> <path id="classpath.compile"> <pathelement location="libs/commons-lang-2.5.jar"/> </path> <path id="classpath.test"> <pathelement location="libs/junit-4.8.2.jar"/> <pathelement location="libs/commons-lang-2.5.jar"/> <pathelement location="${srcTest}"/> <pathelement location="${build}/classes"/> <pathelement location="${build}/test-classes"/> </path> ... 62. ... <target name="init"> <mkdir dir="${build}/classes"/> <mkdir dir="${build}/test-classes"/> </target> <target name="compile" depends="init"> <javac srcdir="${src}" destdir="${build}/classes"> <classpath refid="classpath.compile"/> </javac> </target> <target name="testCompile" depends="compile"> <javac srcdir="${srcTest}" destdir="${build}/test-classes"> <classpath refid="classpath.test"/> </javac> </target> ... ant 63. ... <target name="test" depends="testCompile"> <junit fork="yes" haltonfailure="yes"> <batchtest fork="yes"> <fileset dir="${srcTest}"> <include name="**/*Test.java"/> </fileset> </batchtest> <classpath refid="classpath.test"/> <formatter type="plain"/> </junit> </target> <target name="dist" depends="test"> <mkdir dir="${dist}"/> <jar jarfile="${dist}/coc-comparison-${version}.jar" basedir="${build}/classes"/> </target> <target name="clean"><delete dir="${build}"/></target> </project> ant 64. m a ven <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>grId</groupId> <artifactId>coc-comparison</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> ... 65. m a ven ... <dependencies> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> 66. gradle apply plugin: 'java' version="1.0-SNAPSHOT" group="grId" archivesBaseName="coc-comparison" repositories { mavenCentral() } dependencies { compile 'commons-lang:commons-lang:2.5' testCompile 'junit:junit:4.8.1' } 71. Контакты E-mail: [email_address] Blog: www.ikhotin.com Twitter: chaostarter linkedin .com/pub/igor-khotin/5/193/257