Monday, September 18, 2017

Descriptions of the Gradle build structure

Descriptions of the build gradle file’s parts

Build Java code

apply plugin: ‘java’
apply plugin: ‘war’

This task compiles, tests, and assembles the code into a JAR or WAR file, 
when you run - gradle build

Specify project folder structure

sourceSets{
                main.java.srcDir “src/main”
                test.java.srcDir “src/test”
}

Build with Gradle Wrapper

task wrapper(type: Wrapper) {
    gradleVersion = '2.7'
}

The Gradle Wrapper is the preferred way of starting a Gradle build. It consists of a batch 
script for Windows and a shell script for OS X and Linux. These scripts allow you to run 
a Gradle build without requiring that Gradle be installed on your system.


Specifying Java version in a Gradle build

sourceCompatibility = 1.8
targetCompatibility = 1.8

Resolve dependencies

repositories {
    mavenCentral()
}

The build should resolve its dependencies from the Maven Central repository
dependencies {
    compile "group_name.library_name.version"
    testCompile “..”
}

compile dependency, indicating that it should be available during compile-time
testCompile. Dependencies used for compiling and running tests, but not required
 for building or running the project’s run-time code.

SourceSets can be used to specify a different project structure.

Specify the name of JAR or WAR Artifact

war {
    baseName = 'gs-gradle'
    version =  '0.1.0'
}

jar {
    baseName = 'gs-gradle'
    version =  '0.1.0'
}

The jar block specifies how the JAR file will be named. In this case, 
it will render gs-gradle-0.1.0.jar

Execute Java Application

 
manifest{
        attributes "Main-class":"main_class "
    }
 

To execute Java application, the MANIFEST.MF file must be aware of the class 
with the main method

gradle , java

0 comments :

Post a Comment

 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me