ACLauncher/build.gradle

253 lines
8 KiB
Groovy

import java.text.SimpleDateFormat
import java.util.stream.Collectors
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.mini2Dx:gettext-gradle-plugin:1.10.1'
}
}
plugins {
id 'java'
id 'application'
id 'org.cadixdev.licenser' version '0.6.1'
id 'com.adarshr.test-logger' version '3.0.0'
id 'edu.sc.seis.macAppBundle' version '2.3.0'
id 'edu.sc.seis.launch4j' version '2.5.1'
id 'de.undercouch.download' version '4.1.2'
id 'com.github.johnrengelman.shadow' version '7.1.0'
id 'com.github.ben-manes.versions' version '0.39.0'
}
apply plugin: 'org.mini2Dx.gettext'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
group = 'com.atlauncher'
version = rootProject.file('src/main/resources/version').text.trim().replace('.Beta', '')
repositories {
mavenCentral()
gradlePluginPortal()
jcenter()
maven {
url 'https://libraries.minecraft.net'
}
maven {
url 'https://jitpack.io'
}
}
dependencies {
implementation 'net.java.dev.jna:jna:5.9.0'
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'org.tukaani:xz:1.9'
implementation 'com.mojang:authlib:1.5.21'
implementation 'net.iharder:base64:2.3.9'
implementation 'com.github.Vatuu:discord-rpc:1.6.2'
implementation 'net.sf.jopt-simple:jopt-simple:5.0.4'
implementation 'org.zeroturnaround:zt-zip:1.14'
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
implementation 'com.squareup.okhttp3:okhttp-tls:4.9.2'
implementation 'net.mikehardy:google-analytics-java:2.0.11'
implementation 'io.sentry:sentry:1.7.30'
implementation 'org.mini2Dx:gettext-lib:1.10.1'
implementation 'org.apache.logging.log4j:log4j-api:2.16.0'
implementation 'org.apache.logging.log4j:log4j-core:2.16.0'
implementation 'com.sangupta:murmur:1.0.0'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.formdev:flatlaf:1.6.1'
implementation 'com.formdev:flatlaf-extras:1.6.1'
implementation 'com.github.oshi:oshi-core:5.8.2'
implementation 'net.freeutils:jlhttp:2.6'
implementation 'joda-time:joda-time:2.10.12'
implementation 'org.apache.commons:commons-compress:1.21'
implementation 'org.commonmark:commonmark:0.18.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testImplementation 'org.assertj:assertj-swing-junit:3.17.1'
testImplementation 'org.mock-server:mockserver-netty:5.11.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.8.1'
}
application {
mainClass = 'com.atlauncher.App'
applicationDefaultJvmArgs = [
"-Djna.nosys=true",
"-Djava.net.preferIPv4Stack=true",
"-Dawt.useSystemAAFontSettings=on",
"-Dswing.aatext=true"
]
}
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
testlogger {
theme 'mocha'
}
}
jar {
manifest {
attributes(
'SplashScreen-Image': '/assets/image/splash-screen.png',
'Implementation-Title': project.name,
'Implementation-Version': archiveVersion,
'Implementation-Vender': 'ATLauncher',
'Main-Class': 'com.atlauncher.App',
'Multi-Release': 'true'
)
}
}
gettext {
translations {
srcDir = 'src'
include = 'main/java/com/atlauncher/**/*.java'
excludes = [
'main/java/com/atlauncher/adapter/**/*.java',
'main/java/com/atlauncher/annot/**/*.java',
'main/java/com/atlauncher/collection/**/*.java',
'main/java/com/atlauncher/evnt/**/*.java',
'main/java/com/atlauncher/exceptions/**/*.java',
'main/java/com/atlauncher/interfaces/**/*.java',
'main/java/com/atlauncher/listener/**/*.java',
'main/java/com/atlauncher/utils/**/*.java'
]
commentFormat = ' #. '
outputFilename = 'translations.pot'
}
}
license {
header = project.file('LICENSEHEADER')
include '**/*.java'
exclude 'de/zh32/**/*.java'
exclude 'io/github/**/*.java'
exclude 'net/minecraft/**/*.java'
exclude 'com/atlauncher/gui/layouts/WrapLayout.java'
newLine = false
properties {
year = currentYear()
}
}
shadowJar {
classifier = null
minimize {
exclude(dependency('org.apache.logging.log4j:.*:.*'))
exclude(dependency('com.formdev:.*:.*'))
exclude(dependency('org.apache.commons:commons-compress:.*'))
}
classifier = ''
}
macAppBundle {
mainClassName = 'com.atlauncher.App'
appName = 'ATLauncher'
appStyle = 'universalJavaApplicationStub'
runtimeConfigurationName = 'shadow'
jarTask = 'shadowJar'
icon = 'src/main/resources/assets/image/icon.icns'
javaProperties.put('user.dir', '$APP_ROOT/Contents/Java')
javaProperties.put('apple.laf.useScreenMenuBar', 'true')
javaExtras.put("-Djna.nosys", "true")
javaExtras.put("-Djava.net.preferIPv4Stack", "true")
javaExtras.put("-Dawt.useSystemAAFontSettings", "on")
javaExtras.put("-Dswing.aatext", "true")
bundleExtras.put("JVMVersion", project.targetCompatibility.toString() + "+")
}
copyToResourcesJava {
rename("ATLauncher-${project.version}.jar", "ATLauncher.jar")
}
def currentYear() {
def df = new SimpleDateFormat("yyyy")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
launch4j {
outfile = "ATLauncher-${project.version}.exe"
jreMinVersion = "${project.targetCompatibility.toString()}"
mainClassName = 'com.atlauncher.App'
icon = "${projectDir}/src/main/resources/assets/image/icon.ico"
version = "${project.version}"
textVersion = "${project.version}"
copyright = "2013-${currentYear()} ${project.name}"
companyName = "${project.name}"
bundledJrePath = "jre/"
jvmOptions = [
"-Djna.nosys=true",
"-Djava.net.preferIPv4Stack=true",
"-Dawt.useSystemAAFontSettings=on",
"-Dswing.aatext=true"
]
}
artifacts {
archives shadowJar
archives file(project.tasks.jar.getArchivePath().getPath().replace('.jar', '.exe').replace('libs', 'launch4j'))
archives file(project.tasks.jar.getArchivePath().getPath().replace('.jar', '.zip').replace('libs', 'distributions'))
}
test {
if (JavaVersion.current().isJava9Compatible()) {
jvmArgs '--add-opens=java.base/sun.security.x509=ALL-UNNAMED'
}
}
task copyArtifacts(type: Copy) {
dependsOn build
from shadowJar
from file(project.tasks.jar.getArchivePath().getPath().replace('.jar', '.exe').replace('libs', 'launch4j'))
from file(project.tasks.jar.getArchivePath().getPath().replace('.jar', '.zip').replace('libs', 'distributions'))
into "${projectDir}/dist"
}
task downloadNewerUniversalJavaApplicationStub(type: Download) {
description 'Downloads newer universalJavaApplicationStub'
src 'https://raw.githubusercontent.com/tofi86/universalJavaApplicationStub/2dbbf92b35e61194266c985c8bc6b411053a1b4a/src/universalJavaApplicationStub'
dest file("$buildDir/macApp/${project.name}.app/Contents/MacOS/universalJavaApplicationStub")
overwrite true
}
task createTestLauncherDir {
project.file('testLauncher/dev').mkdirs()
}
task createMacApp(type: Zip) {
dependsOn createApp, shadowJar
from("$buildDir/macApp") {
include "${project.name}.app/**"
exclude "${project.name}.app/Contents/MacOS"
}
from("$buildDir/macApp") {
include "${project.name}.app/Contents/MacOS/**"
fileMode 0777
}
archiveName = "${project.name}-${project.version}.zip"
}
copyArtifacts.finalizedBy {
println 'ATLauncher has been built. Distribution files are located in the dist directory.'
}
clean.doFirst {
delete "${projectDir}/dist"
}
build.finalizedBy copyArtifacts
shadowJar.dependsOn jar
build.dependsOn createExe, createMacApp
createApp.finalizedBy downloadNewerUniversalJavaApplicationStub