/java/

Gradle & JEE basic script

2015-11-11 22:05:46

group 'pl.btbw'
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'war'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}

war {
    archiveName 'gradle-test.war'
    version = '1.0.0-SNAPSHOT'
}

dependencies {
    providedCompile group: 'javax', name: 'javaee-api', version: '7.0'

    compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.10'
    compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.6.6'
    compile group: 'log4j', name: 'log4j', version: '1.2.17'

    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.5'
    testCompile group: 'org.easytesting', name: 'fest-assert', version: '1.4'
    testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
    testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
}

if you want to do the same in maven, you have to use this xml

<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>

<project http:="" maven-4.0.0.xsd&quot;="" maven.apache.org="" xmlns='"http://maven.apache.org/POM/4.0.0"' xmlns:xsi='"http://www.w3.org/2001/XMLSchema-instance"' xsd="" xsi:schemalocation='"http://maven.apache.org/POM/4.0.0'>
<modelversion>4.0.0</modelversion>
<groupid>btbw.pl</groupid>
<artifactid>gradle-test</artifactid>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupid>javax</groupid>
<artifactid>javaee-api</artifactid>
<version>7.0</version>
</dependency>
<!-- Logging -->
<dependency>
<groupid>org.slf4j</groupid>
<artifactid>slf4j-api</artifactid>
<version>1.7.10</version>
</dependency>
<dependency>
<groupid>org.slf4j</groupid>
<artifactid>slf4j-log4j12</artifactid>
<version>1.6.6</version>
</dependency>
<dependency>
<groupid>log4j</groupid>
<artifactid>log4j</artifactid>
<version>1.2.17</version>
</dependency>
<!-- TEST -->
<dependency>
<groupid>junit</groupid>
<artifactid>junit-dep</artifactid>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupid>org.mockito</groupid>
<artifactid>mockito-core</artifactid>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupid>org.easytesting</groupid>
<artifactid>fest-assert</artifactid>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupid>org.hamcrest</groupid>
<artifactid>hamcrest-core</artifactid>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupid>org.hamcrest</groupid>
<artifactid>hamcrest-library</artifactid>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalname>gradle-test</finalname>
<plugins>
<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-compiler-plugin</artifactid>
<configuration>
<source/>1.8
                    <target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactid>maven-war-plugin</artifactid>
<configuration>
<failonmissingwebxml>false</failonmissingwebxml>
</configuration>
</plugin>
</plugins>
</build>
</project>