Fixed first-time packaging issue in build script
This commit is contained in:
parent
162b2249b1
commit
fe01e1b81c
62
build.gradle
62
build.gradle
@ -267,64 +267,40 @@ apply from: 'build_logic/lwjgl.gradle'
|
|||||||
import java.nio.file.*
|
import java.nio.file.*
|
||||||
import java.nio.file.attribute.*
|
import java.nio.file.attribute.*
|
||||||
|
|
||||||
task createPackagingDirs() {
|
task deletePackagingDirs(type: Delete) {
|
||||||
description 'Resets build/tmp/packaging directory.'
|
description 'Deletes build/tmp/packaging directory.'
|
||||||
|
followSymlinks = false
|
||||||
doLast {
|
delete 'build/tmp/packaging'
|
||||||
def tmpDir = buildDir.toPath().resolve 'tmp/packaging'
|
|
||||||
|
|
||||||
def nuke = new SimpleFileVisitor<Path>() {
|
|
||||||
@Override
|
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
|
||||||
Files.delete(file);
|
|
||||||
return FileVisitResult.CONTINUE;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException {
|
|
||||||
if (e == null) {
|
|
||||||
Files.delete(dir);
|
|
||||||
return FileVisitResult.CONTINUE;
|
|
||||||
} else {
|
|
||||||
// directory iteration failed
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fckn nuke tmpDir from orbit
|
task linkBuildOutputForPackaging {
|
||||||
// I'm so done with deleting file trees in Java/Groovy/whatever
|
|
||||||
// ...Not using File.deleteDir() because the latter recurses into symlinks, and we don't want to wipe build/libs/lib
|
|
||||||
if (Files.exists(tmpDir)) {
|
|
||||||
Files.walkFileTree tmpDir, nuke
|
|
||||||
}
|
|
||||||
|
|
||||||
Files.createDirectories tmpDir.resolve('workingDir')
|
|
||||||
Files.createDirectories buildDir.toPath().resolve('packages')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task linkBuildOutputForPackaging() {
|
|
||||||
description 'Symlinks the contents of build/libs into packaging working directory.'
|
description 'Symlinks the contents of build/libs into packaging working directory.'
|
||||||
|
|
||||||
dependsOn build
|
dependsOn build
|
||||||
dependsOn createPackagingDirs
|
mustRunAfter deletePackagingDirs
|
||||||
|
|
||||||
onlyIf { preparePackaging.ext.mode == 'symlink' }
|
onlyIf { preparePackaging.ext.mode == 'symlink' }
|
||||||
|
|
||||||
|
ext.from = 'build/libs'
|
||||||
|
ext.into = "build/tmp/packaging/workingDir/${ -> preparePackaging.ext.buildDest}"
|
||||||
|
|
||||||
|
inputs.dir from
|
||||||
|
outputs.dir into
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
def from = buildDir.toPath().resolve 'libs'
|
def fromPath = Paths.get from
|
||||||
def into = buildDir.toPath().resolve "tmp/packaging/workingDir/${preparePackaging.ext.buildDest}"
|
def intoPath = Paths.get into
|
||||||
|
|
||||||
Files.createDirectories into
|
Files.createDirectories intoPath
|
||||||
|
|
||||||
Files.list(from).each {
|
Files.list(fromPath).each {
|
||||||
def fileName = it.fileName.toString()
|
def fileName = it.fileName.toString()
|
||||||
|
|
||||||
// Exclude all JARs except the current one
|
// Exclude all JARs except the current one
|
||||||
if (fileName ==~ "${project.name}.*\\.jar" && fileName != tasks.jar.archiveFileName.get())
|
if (fileName ==~ "${project.name}.*\\.jar" && fileName != tasks.jar.archiveFileName.get())
|
||||||
return
|
return
|
||||||
|
|
||||||
Files.createSymbolicLink into.resolve(it.fileName), it
|
Files.createSymbolicLink intoPath.resolve(it.fileName), intoPath.relativize(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,7 +309,7 @@ task copyBuildOutputForPackaging(type: Copy) {
|
|||||||
description 'Copies the contents of build/libs into packaging working directory.'
|
description 'Copies the contents of build/libs into packaging working directory.'
|
||||||
|
|
||||||
dependsOn build
|
dependsOn build
|
||||||
dependsOn createPackagingDirs
|
mustRunAfter deletePackagingDirs
|
||||||
|
|
||||||
onlyIf { preparePackaging.ext.mode == 'copy' }
|
onlyIf { preparePackaging.ext.mode == 'copy' }
|
||||||
|
|
||||||
@ -348,7 +324,7 @@ task preparePackaging {
|
|||||||
preparePackaging.ext.buildDest = ''
|
preparePackaging.ext.buildDest = ''
|
||||||
preparePackaging.ext.mode = 'symlink'
|
preparePackaging.ext.mode = 'symlink'
|
||||||
|
|
||||||
dependsOn createPackagingDirs
|
dependsOn deletePackagingDirs
|
||||||
dependsOn linkBuildOutputForPackaging
|
dependsOn linkBuildOutputForPackaging
|
||||||
dependsOn copyBuildOutputForPackaging
|
dependsOn copyBuildOutputForPackaging
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ task packageDeb_configure() {
|
|||||||
preparePackaging.mustRunAfter packageDeb_configure
|
preparePackaging.mustRunAfter packageDeb_configure
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
tasks.preparePackaging.ext.buildDest = '/usr/share/progressia'
|
tasks.preparePackaging.ext.buildDest = 'usr/share/progressia'
|
||||||
tasks.preparePackaging.ext.mode = 'copy'
|
tasks.preparePackaging.ext.mode = 'copy'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,6 +31,10 @@ task packageDeb(type: Exec) {
|
|||||||
|
|
||||||
dependsOn packageDeb_processResources
|
dependsOn packageDeb_processResources
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
mkdir 'build/packages'
|
||||||
|
}
|
||||||
|
|
||||||
executable 'dpkg-deb'
|
executable 'dpkg-deb'
|
||||||
args '--root-owner-group'
|
args '--root-owner-group'
|
||||||
args '--build', 'build/tmp/packaging/workingDir'
|
args '--build', 'build/tmp/packaging/workingDir'
|
||||||
|
@ -40,6 +40,10 @@ task packageNsis(type: Exec) {
|
|||||||
dependsOn packageNsis_generateIcon
|
dependsOn packageNsis_generateIcon
|
||||||
dependsOn packageNsis_generateLeftSide
|
dependsOn packageNsis_generateLeftSide
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
mkdir 'build/packages'
|
||||||
|
}
|
||||||
|
|
||||||
executable 'makensis'
|
executable 'makensis'
|
||||||
args '-NOCONFIG'
|
args '-NOCONFIG'
|
||||||
args "-DPROJECT_NAME=${project.name}"
|
args "-DPROJECT_NAME=${project.name}"
|
||||||
|
@ -36,6 +36,10 @@ task packageZip(type: Zip) {
|
|||||||
archiveVersion = project.version
|
archiveVersion = project.version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
mkdir 'build/packages'
|
||||||
|
}
|
||||||
|
|
||||||
from 'build/tmp/packaging/workingDir'
|
from 'build/tmp/packaging/workingDir'
|
||||||
destinationDirectory = file('build/packages')
|
destinationDirectory = file('build/packages')
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user