Skip to content

Instantly share code, notes, and snippets.

@Joedobo27
Last active October 25, 2018 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Joedobo27/6c516ceb8dd5303c47e69fd71d36e74f to your computer and use it in GitHub Desktop.
Save Joedobo27/6c516ceb8dd5303c47e69fd71d36e74f to your computer and use it in GitHub Desktop.
apply plugin: 'java'
apply plugin: 'distribution'
group = 'com.joedobo27'
version = '1.0.3'
sourceCompatibility = 1.8
def WUServerPath = "C:\\Users\\Jason\\Documents\\WU\\WU-Server\\"
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compileOnly files("${WUServerPath}common.jar")
compileOnly files("${WUServerPath}server.jar")
compileOnly files("${WUServerPath}modlauncher.jar")
compileOnly files("${WUServerPath}javassist.jar")
// https://mvnrepository.com/artifact/junit/junit
testCompile group: 'junit', name: 'junit', version: '4.12'
// https://mvnrepository.com/artifact/org.javassist/javassist
//compileOnly group: 'org.javassist', name: 'javassist', version: '3.20.0-GA'
// https://mvnrepository.com/artifact/com.intellij/annotations
compile group: 'com.intellij', name: 'annotations', version: '12.0'
}
jar.setArchiveName(project.name + ".jar")
distZip.doFirst {
delete (file("${distZip.destinationDir}/${project.name}-${version}.zip"))
}
distZip.dependsOn(jar)
distZip.mustRunAfter(jar)
// The distZip automatically adds a sub-folder with the same name as the zip. In order to directly unpack the
// archive into WU server folder it needs to have a folder named "mods" as its first sub-folder. After much effort I ended up with
// this weird "hack" approach to get the right directory structure.
distZip.setArchiveName("mods.zip")
distZip.doLast {
file("${distZip.destinationDir}/mods.zip").renameTo("${distZip.destinationDir}/${project.name}-${version}.zip")
}
distributions {
main {
contents {
from('src/main/resources/') {
include("*.properties")
}
from ('build/libs/') {
include("${project.name}.jar")
into(project.name+"/")
}
from ('build/libs/'){
exclude("${project.name}.jar")
include("*.jar")
into("${project.name}/libs/")
}
}
}
}
task dist(type: Copy) {
from configurations.runtime {
exclude("annotations*")
}
into "$buildDir/libs"
}
build.dependsOn(dist)
dist.mustRunAfter(jar)
distZip.dependsOn(dist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment