Building Java 11 Project using Gradle plus JavaFX and dependencies - java

I am trying to build my Java 11 project to have either an executable jar (FatJar, SuperJar, whatever its called) or an EXE or any form of runnable version even a batch file (Using Application). Everything I try I either get JavaFX is missing or my dependencies included the packages arent visible and it error's out.
Here is my build.gradle
plugins {
id 'application'
id 'java'
id 'maven-publish'
id 'org.openjfx.javafxplugin' version '0.0.8'
id 'edu.sc.seis.launch4j' version '2.4.6'
id 'org.beryx.jlink' version '2.12.0'
}
application {
mainClassName = 'sassa.sassa.Main'
}
repositories {
mavenLocal()
maven {
url = uri('https://jitpack.io')
}
maven {
url = uri('https://repo.maven.apache.org/maven2')
}
}
javafx {
version = "11.0.2"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.graphics' ]
}
jlink {
launcher {
name = 'sassa'
}
}
dependencies {
implementation 'com.github.toolbox4minecraft:amidst:v4.4-beta1'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
}
jar {
manifest {
attributes("Manifest-Version": "1.0",
"Main-Class": "sassa.main.Main");
}
}
compileJava {
doFirst {
println "CLASSPATH IS $classpath.asPath"
options.compilerArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'javafx.graphics',
'--add-modules', 'javafx.controls',
'--add-modules', 'javafx.fxml'
]
classpath = files()
}
}
task fatJar(type: Jar) {
manifest.from jar.manifest
classifier = 'all'
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
} {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
with jar
}
launch4j {
mainClassName = 'sassa.main.Main'
icon = "${projectDir}/src/main/resources/sassa/sassa.ico"
jreMinVersion = '11'
jreMaxVersion = '14'
jdkPreference = 'preferJre'
initialHeapSize = 128
maxHeapSize = 512
stayAlive = false
bundledJre64Bit = true
dontWrapJar = true
bundledJrePath = 'jre'
}
group = 'sassa'
version = '0.5.0'
sourceCompatibility = '11'
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
Also for the layout of the project it is on github (I was using maven before but figured Gradle might work better. (The maven code is still on github) https://github.com/Zodsmar/SeedSearcherStandaloneTool/tree/development
Literally I have tried everything and I just can't seem to get a buildable version to distribute...
Also I have read up about module.info files I do not have any I want to have a simple build.gradle that just includes everything I need to build an executable.

To anyone whoever comes across this and wants to know how I fixed it. I created a Gradle build task and then was able to build Jars, EXEs, Tar, and Zip this is the gradle:
plugins {
id 'application'
id 'java'
id 'maven-publish'
id 'org.openjfx.javafxplugin' version '0.0.8'
id 'edu.sc.seis.launch4j' version '2.4.6'
}
dependencies {
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
implementation ('com.github.KaptainWutax:BiomeUtils:master-SNAPSHOT') {
transitive = false;
changing = true;
}
implementation ('com.github.KaptainWutax:FeatureUtils:master-SNAPSHOT')
{
transitive = false;
changing = true;
}
implementation ('com.github.KaptainWutax:SeedUtils:master-SNAPSHOT')
{
transitive = false;
changing = true;
}
}
group = 'sassa'
version = 'v0.6.0'
sourceCompatibility = '1.8'
String stringVersion = version
javafx {
version = "11.0.2"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.graphics' ]
}
application {
mainClassName = 'sassa.main.Main'
}
jar {
manifest {
attributes 'Main-Class': 'sassa.main.Main'
}
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
launch4j {
mainClassName = 'sassa.main.Main'
outfile = group + "-" + stringVersion + ".exe"
icon = "${projectDir}/src/main/resources/sassa/sassa.ico"
}
repositories {
mavenLocal()
maven {
url = uri('https://jitpack.io')
}
maven {
url = uri('https://repo.maven.apache.org/maven2')
}
}
task buildAll(type: GradleBuild) {
tasks = ['jar', 'createExe', 'assemble']
}
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}

Related

Web3j plugin for gradle task not found

I am beating against a wall for a whole week. I can't really see the reason why it doesn't work. I have a project where I want to run my Java project with the following build.gradle config:
plugins {
id 'java'
id 'org.springframework.boot' version '2.6.3'
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id 'org.web3j' version "4.8.4"
}
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
jcenter()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'com.suplab'
sourceSets {
main {
solidity {
srcDir "contracts"
}
}
test {
solidity {
srcDir "contracts"
}
}
}
ext {
web3jVersion = '4.8.4'
}
npmInstall {
enabled false
}
dependencies {
implementation "org.web3j:core:$web3jVersion"
implementation "org.web3j:web3j-evm:$web3jVersion"
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.hibernate:hibernate-core:5.6.5.Final'
}
I use gradle version 6.8, since it was specified by developer of the plugin. When I try to build this project from the parent, root folder that is the root of the project, it fails with following error:
A problem occurred configuring project ':api'.
> Failed to notify project evaluation listener.
> Task with name 'resolveSolidity' not found in project ':api'.
> Could not create task ':api:generateTestContractWrappers'.
> Task with name 'compileTestSolidity' not found in project ':api'.
I can't figure it out. I checked it against the build that being generated with web3j-cli, and it's the same for the configuration property (both configs have it blank). So, I don't see any reason WHY it fails. Here's the webj3-cli generated build file:
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.61'
id 'application'
id "com.github.johnrengelman.shadow" version "5.2.0"
id 'org.web3j' version '4.8.4'
}
group 'org.web3j'
version '0.1.0'
sourceCompatibility = 1.8
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
jcenter()
}
web3j {
generatedPackageName = 'org.web3j.generated.contracts'
excludedContracts = ['Mortal']
}
ext {
web3jVersion = '4.8.4'
logbackVersion = '1.2.3'
}
dependencies {
implementation "org.web3j:core:$web3jVersion",
"ch.qos.logback:logback-core:$logbackVersion",
"ch.qos.logback:logback-classic:$logbackVersion"
implementation "org.web3j:web3j-unit:$web3jVersion"
implementation "org.web3j:web3j-evm:$web3jVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
}
jar {
manifest {
attributes(
'Main-Class': 'org.web3j.Web3App',
'Multi-Release':'true'
)
}
}
application {
mainClassName = 'org.web3j.Web3App'
}
test {
useJUnitPlatform()
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

Artifactory publish with multi-module gradle

Hope all doing well.
Today I was working on multi-module gradle project, and trying to publish one of it's dependency to artifactory as well.
my project structure are:
build.gradle (main)
buildscript {
ext {
appVersion = "0.0.2-RC3"
appBuildCode = 2
// dependencies version
springVersion = "2.6.0"
swaggerApiVersion = "1.5.12"
jjwtVersion = "0.11.2"
lombokVersion = "1.18.22"
// firebase versions
firebaseAdminVersion = "8.1.0"
}
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:$springVersion")
classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.2.0")
classpath("io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE")
classpath("org.jfrog.buildinfo:build-info-extractor-gradle:latest.release")
}
}
apply(plugin: "org.sonarqube")
apply(plugin: "jacoco")
allprojects {
apply(plugin: 'java')
apply(plugin: 'org.springframework.boot')
apply(plugin: 'io.spring.dependency-management')
group 'com.example'
repositories {
mavenCentral()
maven {
url "${artifactory_contextUrl}/libs-release/"
allowInsecureProtocol true
}
}
configurations {
all*.exclude module: 'spring-boot-starter-logging'
}
dependencies {
....
}
}
build.gradle (api)
plugins {
id 'java-library'
id 'maven-publish'
id 'com.jfrog.artifactory'
}
version "${appVersion}"
artifactory {
contextUrl = artifactory_contextUrl
publish {
contextUrl = artifactory_contextUrl
repository {
repoKey = artifactory_repoKey
username = artifactory_user
password = artifactory_password
}
defaults {
publishConfigs('published')
publishIvy = false
publications("mavenJava")
}
}
}
//jar {
////// archiveName 'admin-api.jar'
////// manifest{
////// attributes ("Fw-Version" : "2.50.00", "${parent.manifestSectionName}")
////// }
////// baseName 'admin-api'
//// archivesBaseName = "$archivesBaseName"
//
// from {
// configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
// }
//}
task sourcesJar(type: Jar, dependsOn: classes) {
// classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
// artifactId = 'admin-api'
artifact(sourcesJar) {
classifier 'sources'
}
}
}
}
task dist(type: Zip, dependsOn: build) {
classifier = 'buildreport'
from('build/test-results') {
include '*.xml'
into 'tests'
}
from('build/reports/codenarc') {
into 'reports'
}
from('build/docs') {
into 'api'
}
from(sourcesJar) {
into 'source'
}
from('build/libs') {
exclude '*-sources.jar'
into 'bin'
}
}
//artifactoryPublish.dependsOn('clean', 'build', 'groovydoc', 'sourcesJar', 'dist')
//publish.dependsOn(artifactoryPublish)
and the task artifactoryPublish produces:
> Task :admin-api:extractModuleInfo
[pool-7-thread-1] Deploying artifact: http://10.0.0.3:8081/artifactory/libs-release-local/com/example/admin-api/0.0.2-RC3/admin-api-0.0.2-RC3-plain.jar
[pool-7-thread-1] Deploying artifact: http://10.0.0.3:8081/artifactory/libs-release-local/com/example/admin-api/0.0.2-RC3/admin-api-0.0.2-RC3.module
[pool-7-thread-1] Deploying artifact: http://10.0.0.3:8081/artifactory/libs-release-local/com/example/admin-api/0.0.2-RC3/admin-api-0.0.2-RC3.pom
> Task :artifactoryDeploy
Now the issue is that,
the modules, like admin-api builds with the name admin-api-0.0.2-RC3-plain.jar, and the resolution of dependency fails in another project, from which this API needs to be used by reporting following issue:
Could not resolve com.example.admin-api:0.0.2-RC3.
Required by:
project :admin-api
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
gradle dependency statement:
dependencies {
compileOnly('com.example:admin-api:0.0.2-RC3')
}
Please assist me on what is going wrong here.
Also, is their any way so that the modules jar builds without the suffix -plain?
Thanks in advance:)
Hi finally I've achieved this using the following configurations:
allprojects {
....
bootJar {
enabled = false
}
jar {
archiveClassifier.convention('')
archiveClassifier.set('')
}
....
}

ClassNotFoundException When running jar file but runs fine in Intellij

I created a small mqtt application using eclipse paho mqtt library in kotlin with Gradle in Intellij IDE. it runs fine when running it through Intellij but when I build it and run the jar file that gets created I get a NoClassDefFoundError error.
From other questions I have seen about this it looks like it has something to do with the class path but I am not sure what needs to be done if that is indeed the issue because I am using gradle and not jar files for libraries.
I was following this tutorial
Here is my gradle file
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.4.31'
id 'application'
}
group = 'me.package'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url "https://repo.eclipse.org/content/repositories/paho-snapshots/"
}
}
dependencies {
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
test {
useJUnit()
}
compileKotlin {
kotlinOptions.jvmTarget = '1.8'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '1.8'
}
application {
mainClassName = 'com.publisher.MainKt'
}
tasks.jar {
manifest {
attributes 'Main-Class': 'com.publisher.MainKt'
}
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
And my MainKt file
package com.publisher
import org.eclipse.paho.client.mqttv3.*
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence
import java.io.File
fun main(args: Array<String>) {
val client = MqttClient("tcp://192.168.0.55:1883","publisher", MemoryPersistence())
val connOpts = MqttConnectOptions()
connOpts.isCleanSession = false
connOpts.isAutomaticReconnect = true
client.setCallback(object: MqttCallback {
override fun connectionLost(cause: Throwable?) {
println("Connection lost")
println(cause!!.message)
}
override fun messageArrived(topic: String?, message: MqttMessage?) {
println("Message Received for topic: $topic")
println("Message: ${message!!.payload}")
}
override fun deliveryComplete(token: IMqttDeliveryToken?) {
println("Message delivered")
}
})
try{
client.connect(connOpts)
println("Connected")
client.subscribe("config/+", 1) { topic, message ->
println("Getting configuration for $message")
val path = System.getProperty("user.dir")
val file = File("$path/${message}.json")
if(file.exists()){
client.publish("/devices/ + $message + /config", MqttMessage(file.readBytes()))
}
}
}catch (e: MqttException){
println("Error: ${e.localizedMessage}")
e.printStackTrace()
}
}
The way you start your application does not include the dependencies, meaning your MQTT driver and the Kotlin dependencies are not included.
Do the following:
gradle distZip
# alternatively
gradle distTar
This will create a zip/tar file containing all the dependencies and a start script. Use that to start your application.
You could consider the Shadow plugin, as it is straightforward to use. Your build.gradle would look something like this:
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.4.31'
// Shadow plugin
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'java'
}
group = 'me.package'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url "https://repo.eclipse.org/content/repositories/paho-snapshots/"
}
}
dependencies {
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
test {
useJUnit()
}
compileKotlin {
kotlinOptions.jvmTarget = '1.8'
}
compileTestKotlin {
kotlinOptions.jvmTarget = '1.8'
}
application {
mainClassName = 'com.publisher.MainKt'
}
tasks.jar {
manifest {
attributes 'Main-Class': 'com.publisher.MainKt'
}
}
So your fat JAR is generated in the /build/libs directory with all the dependencies included.

JNI Error - libGDX ApplicationListener not found

So I've just exported my project as a JAR-file. I'm only making a desktop application. When trying to run the program i get
"A JNI error has occurred.." Not much else there. However, in the command prompt it is revealed that
"Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/ApplicationListener"
So the libGDX ApplicationListener can't be found? It works perfectly when compiling/running in Eclipse.
I'm using:
Windows 7 Ultimate
Eclipse Oxygen.3a
Gradle 4.4.1
java JRE version 1.8.0_241
java JDK version 1.8.0_241
Environment variables:
PATH_HOME: "C:\Program Files\Java\jdk1.8.0_241"
var: "C:\Program Files\Java\jdk1.8.0_241\bin"
Path: "C:\Program Files (x86)\Common Files\Oracle\Java\javapath; C:\ProgramData\Oracle\Java\javapath; C:\Windows\system32; C:\Windows; C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0\; C:\Gradle\gradle-4.4.1\bin"
Main class
public class DesktopLauncher
{
public static boolean rebuildAtlas = true;
public static boolean drawDebugOutline = true;
public static void main (String[] arg)
{
// Build Texture Atlases
if (rebuildAtlas) {
Settings settings = new Settings();
settings.maxWidth = 1024;
settings.maxHeight = 1024;
settings.combineSubdirectories = true;
// Pack images in "textures" folder
TexturePacker.process("assets/textures", "assets/atlas", "textures.atlas");
}
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "TI Helper";
cfg.useGL30 = false;
cfg.width = Cn.RESOLUTION_WIDTH;
cfg.height = Cn.RESOLUTION_HEIGHT;
cfg.fullscreen = true;
new LwjglApplication(new ti_app(), cfg);
}
}
Desktop build.gradle
apply plugin: "java"
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.main.resources.srcDirs = ["../core/assets"]
project.ext.mainClassName = "com.lf.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../core/assets")
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task debug(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
task dist(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
dist.dependsOn classes
Core build.gradle
apply plugin: "java"
sourceCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
Workspace build.gradle
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
}
}
allprojects {
apply plugin: "eclipse"
version = '1.0'
ext {
appName = "TIHelper"
gdxVersion = '1.9.10'
roboVMVersion = '2.3.8'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java-library"
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
}
}
project(":core") {
apply plugin: "java-library"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
api "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
api "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
api "com.badlogicgames.gdx:gdx-ai:$aiVersion"
api "net.dermetfan.libgdx-utils:libgdx-utils:0.13.4"
api "net.dermetfan.libgdx-utils:libgdx-utils-box2d:0.13.4"
api "com.badlogicgames.ashley:ashley:$ashleyVersion"
}
}
Singular unsettling tales also suggests I could be missing some sort of native JAR-file (gdx-native.jar or something like that) among my external dependencies
But those topics where years of age so I guess I have it, it's just named "gdx-platform-1.9.10-natives-desktop.jar" nowadays. Or is the problem related to the fact that the project says Native library location: (none)? I'm kinda lost here I must say. Are the libGDX jars not exported?

Gradle multimodule

I have one modular project, I decided to distribute it to modules. Server and client.
There was a question now. How to call a dependent task from another module?
parent build.gradle
plugins {
id "net.ltgt.apt" version "0.14"
}
apply from: "$rootDir/gradle/idea.gradle"
group 'com.test.portal'
version '1.0-SNAPSHOT'
allprojects {
apply plugin: 'net.ltgt.apt'
}
subprojects {
apply from: "$rootDir/gradle/versions.gradle"
apply from: "$rootDir/gradle/java.gradle"
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
}
java.gradle
def generatedDir = new File("$projectDir", "src/generated")
apply plugin: 'java'
sourceSets {
generated {
java.srcDir "src/generated/java"
}
main.java.srcDirs = ['src/main/java', "src/generated/java"]
main.resources.srcDir "src/main/resources"
test.java.srcDir "src/test/java"
test.resources.srcDir "src/test/resources"
}
// deletes generated classes before new compilation
task deleteGenerated(type: Delete) {
generatedDir.deleteDir()
}
compileGeneratedJava {
dependsOn('deleteGenerated')
}
compileJava {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
options.encoding = 'UTF-8'
options.compilerArgs = ['-Xlint:unchecked'] // Just a smoke test that using this option does not lead to any
options.annotationProcessorGeneratedSourcesDirectory = new File("$generatedDir", "java")
dependsOn(processResources, compileGeneratedJava)
source += sourceSets.generated.java
source += sourceSets.generated.output
}
test {
systemProperties = System.properties
}
And I have 2 child-modules
GWT
build.gradle
apply from: "$rootDir/gradle/gwt.gradle"
dependencies {
...
}
compileGwt {
classpath {
[
sourceSets.main.java.srcDirs, // Java source
sourceSets.main.output.resourcesDir, // Generated resources
sourceSets.main.output.classesDir, // Generated classes
sourceSets.main.compileClasspath, // Deps
]
}
}
gwt.gradle
task compileGwt(dependsOn: classes, type: JavaExec) {
ext.buildDir = "${project.buildDir}/gwt"
ext.extraDir = "${project.buildDir}/extra"
inputs.file sourceSets.main.java.srcDirs
inputs.dir sourceSets.main.output.resourcesDir
outputs.dir buildDir
doFirst {
file(buildDir).mkdirs()
}
main = "com.google.gwt.dev.Compiler"
classpath {
[
sourceSets.main.java.srcDirs, // Java source
sourceSets.main.output.resourcesDir, // Generated resources
sourceSets.main.output.classesDir, // Generated classes
sourceSets.main.compileClasspath, // Deps
]
}
if (project.hasProperty('dev')) {
println "Run developer mode"
args = [
"com.test.portal.AppClientModule",
"-war", buildDir,
"-logLevel", "INFO",
"-localWorkers", "4",
"-compileReport",
"-extra", extraDir,
"-style", "OBF",
"-optimize", "9" // 0=none, 9=max
]
} else {
println "Run production mode"
args = [
"com.test.portal.AppClientModule",
"-war", buildDir,
"-logLevel", "INFO",
"-localWorkers", "4",
"-compileReport",
"-extra", extraDir,
"-style", "OBF",
"-optimize", "9" // 0=none, 9=max
]
}
maxHeapSize = "4G"
}
Server
gradle.build
plugins {
id "org.springframework.boot" version "1.5.10.RELEASE"
}
dependencies {
...
}
jar.dependsOn compileGwt
jar {
into("static") {
from compileGwt.buildDir
}
}
Questions:
How properly call jar.dependsOn compileGwt from one module, a task from another module
Script java.gradle Can I optimize it? Is there any duplication of code?

Categories

Resources