Skip to content

Commit

Permalink
Added packaging gradle commands. Added splash.
Browse files Browse the repository at this point in the history
  • Loading branch information
raeleus committed Jan 29, 2019
1 parent 3deec8c commit b68fe6f
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/ui/
/submission/
/Particle Park Code/.nb-gradle/
Particle Park Code/.nb-gradle-properties
2 changes: 1 addition & 1 deletion Particle Park Code/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ allprojects {

version = '1.0'
ext {
appName = "my-gdx-game"
appName = "particle-park"
gdxVersion = '1.9.10-SNAPSHOT'
roboVMVersion = '2.3.3'
box2DLightsVersion = '1.4'
Expand Down
Binary file removed Particle Park Code/core/assets/icons/icon-16.png
Binary file not shown.
Binary file removed Particle Park Code/core/assets/icons/icon-32.png
Binary file not shown.
Binary file removed Particle Park Code/core/assets/icons/icon-48.png
Binary file not shown.
Binary file added Particle Park Code/core/assets/icons/icon_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Particle Park Code/core/assets/icons/icon_32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Particle Park Code/core/assets/icons/icon_48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Particle Park Code/core/assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 104 additions & 1 deletion Particle Park Code/desktop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,122 @@ task debug(dependsOn: classes, type: JavaExec) {
}

task dist(type: Jar) {
archiveName = "particle_park.jar";
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from files(project.assetsDir);
exclude("/particles/")

manifest {
attributes 'Main-Class': project.mainClassName
attributes ('Main-Class': project.mainClassName, 'SplashScreen-Image' : 'splash.png')
}
}

dist.dependsOn classes

// creates application bundle (executable + runtime)
task javaPackager(type: Exec, dependsOn: dist) {
workingDir project.projectDir
def commands = [
'javapackager',
'-deploy',
'-nosign',
'-outdir', "${buildDir}/distribution",
'-srcdir', "${buildDir}/libs",
'-native', 'image',
'-name', project.appName,
'-appclass', project.mainClassName
]

def osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
if (osName.contains('windows')) {
commands << "-Bicon=${project.projectDir}/logo.ico"
commands << "-BjvmOptions=-splash:splash.png"
} else if (osName.contains('linux')) {
commands << "-Bicon=${project.projectDir}/logo.png"
commands << "-BjvmOptions=-splash:splash.png"
} else if (osName.contains('mac')) {
commands << "-Bicon=${project.projectDir}/logo.icns"
commands << "-BjvmOptions=-XstartOnFirstThread"
}

commandLine = commands

doLast() {
copy {
from file("${project.projectDir}/splash.png");
into file("${buildDir}/distribution/${project.appName}/app");
}
}
}

// removes bloated runtime created by javapackager
task cleanPackagerRuntime(dependsOn: javaPackager) {
doLast() {
File runtimeFile = new File("${buildDir}/distribution/${project.appName}/runtime")
runtimeFile.deleteDir()
delete {
delete fileTree("${buildDir}/distribution/${project.appName}").matching {
include "api*.dll"
}
}
System.out.println("deleting bloated runtime in " + runtimeFile)
}
}

// creates a replacement runtime via jlink command (much smaller than jpackager)
task createFinalAppBundle(type: Exec, dependsOn: [cleanPackagerRuntime]) {
def jdk = System.getProperty("java.home")

workingDir project.projectDir
commandLine = [
'jlink',
'-p', "${jdk}/jmods",
'--add-modules', 'java.base,java.desktop,jdk.unsupported',
'--strip-debug',
'--no-header-files',
'--no-man-pages',
'--strip-native-commands',
"--vm=server",
"--compress=2",
'--output', "${buildDir}/distribution/${project.appName}/runtime"
]

doLast{
System.out.println("Application '${project.appName}' packaged.")
System.out.println(" -> location: ${buildDir}/distribution/${project.appName}/")
}
}

task updateAndCreateZip(type: Zip, dependsOn: [dist]) {
doFirst {
copy {
from "${buildDir}/libs"
into "${buildDir}/distribution/${project.appName}/app"
}

copy {
from '../README.md'
into "${buildDir}/distribution/${project.appName}"
}

copy {
from '../CHANGES.md'
into "${buildDir}/distribution/${project.appName}"
}

copy {
from '../core/assets/splash.png'
into "${buildDir}/distribution/${project.appName}/app"
}
}

archiveName "particle_park_${org.gradle.internal.os.OperatingSystem.current().getFamilyName()}.zip"
from "${buildDir}/distribution/${project.appName}"
destinationDir = file("${buildDir}/distribution/")
}

eclipse {
project {
name = appName + "-desktop"
Expand Down
Binary file added Particle Park Code/desktop/logo.icns
Binary file not shown.
Binary file added Particle Park Code/desktop/logo.ico
Binary file not shown.
Binary file added Particle Park Code/desktop/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class DesktopLauncher implements DesktopWorker{
public static void main(String[] arg) {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setWindowedMode(800, 800);
config.setWindowIcon("icons/icon-16.png", "icons/icon-32.png", "icons/icon-48.png");
config.setWindowIcon("icons/icon_16x16.png", "icons/icon_32x32.png", "icons/icon_48x48.png");
Core core = new Core();
core.desktopWorker = new DesktopLauncher();
new Lwjgl3Application(core, config);
Expand Down
3 changes: 2 additions & 1 deletion Particle Park Code/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include 'desktop', 'core'
include 'desktop', 'core'
rootProject.name = 'ParticlePark'
Binary file modified graphics/work/Particle Park.spine
Binary file not shown.

0 comments on commit b68fe6f

Please sign in to comment.