define compile/run dependency downloaded in the lib project path
dependencies { compile files('lib/beanstalk.jar') compile files('lib/json-simple-1.1.1.jar') compile files('lib/log4j-1.2.15.jar') // ... }
// https://mvnrepository.com/artifact/mysql/mysql-connector-java compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'
gradle –v
nano build.gradle
apply plugin: 'java' repositories { mavenCentral() } dependencies { compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final' testCompile group: 'junit', name: 'junit', version: '4.+' }
as a software builder/script(based on Groovy)
task hello { doLast { println 'tutorialspoint' } } task taskX << { println 'taskX' } task taskY(dependsOn: 'taskX') << { println "taskY" } # gradle –q taskY task copy(type: Copy) { description 'Copies the resource directory to the target directory.' from 'resources' into 'target' include('**/*.txt', '**/*.xml', '**/*.properties') println("description applied") }
gradle build apply plugin: 'java' sourceSets { main { java { srcDir 'src' } } test { java { srcDir 'test' } } }
apply plugin: 'java' repositories { jcenter() } dependencies { compile 'org.slf4j:slf4j-api:1.7.12' testCompile 'junit:junit:4.12' } jar { manifest { attributes 'Main-Class': 'com.example.main.Application' } } gradle tasks gradle assemble gradle build
mvn -B archetype:generate \ -DarchetypeGroupId=org.apache.maven.archetypes \ -DgroupId=com.mycompany.app \ -DartifactId=my-app mvn archetype:generate \ -DarchetypeGroupId=org.apache.maven.archetypes \ -DarchetypeArtifactId=maven-archetype-webapp \ -DgroupId=com.mycompany.app \ -DartifactId=my-webapp mvn compile mvn test mvn package # create jar mvn install mvn clean
ant build.xml
<?xml version="1.0"?> <project name="PrjName" default="compile"> <target name="clean" description="remove intermediate files"> <delete dir="classes"/> </target> <target name="cleanall" depends="clean" description="remove all artifact files"> <delete file="app.jar"/> </target> <target name="compile" description="compile to class files"> <mkdir dir="classes"/> <javac srcdir="." destdir="classes"/> </target> <target name="jar" depends="compile" description="create Jar of the application"> <jar destfile="app.jar"> <fileset dir="classes" includes="**/*.class"/> <manifest> <attribute name="Main-Class" value="MyClass"/> </manifest> </jar> </target> </project>