Java-Installer/build.gradle

140 lines
3.6 KiB
Groovy

plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
id 'maven-publish'
}
// Set version of programm //
version = "1.1.0"
def version = "1.1.0"
group = "de.rpjosh"
// ----- //
// Set correct encoding
compileJava.options.encoding = 'UTF-8'
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
}
sourceCompatibility = 11
targetCompatibility = 11
// create a single .jar with all dependencies //
task fatJar(type: Jar) {
classifier = ''
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes( 'Implementation-Title': 'installer',
'Implementation-Version': version,
'Implementation-Group': project.group, )
}
archivesBaseName = "installer"
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
{
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
with jar
destinationDirectory.set(layout.buildDirectory.dir("dist"))
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
//sourceSets.main.resources { srcDirs = ["src/main/java"]; exclude "**/*.java" }
task javadocJar(type: Jar, dependsOn: javadoc) {
manifest {
attributes( 'Implementation-Title': 'installer',
'Implementation-Version': version,
'Implementation-Group': project.group, )
}
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives fatJar
archives sourcesJar
archives javadocJar
}
// the created jar file will be copied automatically into the release directory
task copyJar(type: Copy) {
from file("$buildDir/dist/installer-" + version + ".jar"), file("$buildDir/libs/installer-" + version + "-javadoc.jar"), file("$buildDir/libs/installer-" + version + "-sources.jar")
into file("$buildDir/../release")
}
// build the maven repo file structure -> Javadoc can be used easily in eclipse
task copyJarToMaven (type: Copy) {
from file("$buildDir/dist/installer-" + version + ".jar"), file("$buildDir/libs/installer-" + version + "-javadoc.jar"), file("$buildDir/libs/installer-" + version + "-sources.jar")
into file("$buildDir/../release/mavenRepo/de/rpjosh/installer/" + version)
}
// publish to local maven repo
java {
withJavadocJar()
withSourcesJar()
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'installer'
from components.java
pom {
name = 'Java-Installer'
description = 'A simple installation routine for your Java application'
url = 'https://git.rpjosh.de/RPJosh/Java-Installer'
licenses {
license {
name = 'The GNU AFFERO GENERAL PUBLIC LICENSE, Version 3'
url = 'https://www.gnu.org/licenses/agpl-3.0.html'
}
}
developers {
developer {
id = 'RPJosh'
name = 'RPJosh'
email = 'RPjosh@rpjosh.de'
}
}
}
}
}
}
build.finalizedBy copyJar
build.finalizedBy copyJarToMaven
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/com.github.vatbub/mslinks
api group: 'com.github.vatbub', name: 'mslinks', version: '1.0.6.2'
}
tasks.named('jar') {
manifest {
attributes( 'Implementation-Title': 'installer',
'Implementation-Version': version,
'Implementation-Group': 'de.rpjosh', )
}
}