Главная

Java

Gradle


Gradle . Hello World

1)создаём папку проекта
2)переходим в папку
3) gradle init --type java-application
4) добавляем в файл build.gradle строчки :

plugins {
    id 'java'
    id 'application'
}

compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.11
targetCompatibility = 1.11

mainClassName = 'ru.jf17.raritet.Main'

group 'ru.jf17.raritet'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'net.sourceforge.htmlcleaner', name: 'htmlcleaner', version: '2.24'
    testCompile group: 'junit', name: 'junit', version: '4.12'

}

jar {
    manifest {
        attributes(
                'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
                'Main-Class': 'ru.jf17.raritet.Main'
        )
    }
    // имя jar файла
    baseName = 'parser'
    version =  '0.1.0'
}
// Task "distZip" added by plugin "java-library-distribution":
distZip.shouldRunAfter(build)

5) gradle clean
6) gradle build

7) в папке my-test-java-app\build\libs\ будет лежать ваш *.jar файл .