Skip to content

Commit

Permalink
Updated gradle build tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
leifeld committed Aug 19, 2024
1 parent 5bbfb95 commit 8da39b8
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions rDNA/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,15 @@ task rDNADocument {
}
}

// Task to find the most recent JAR file in the build directory
def findLatestJarFile() {
def jarDir = file("$rootDir/build")
def jarFiles = jarDir.listFiles({ file -> file.name.endsWith('.jar') } as FileFilter)

if (jarFiles && jarFiles.size() > 0) {
return jarFiles.sort { -it.lastModified() }[0]
} else {
throw new GradleException("No jar files found in the build directory.")
}
// Task to copy R package sources to a temporary build directory
task copyRPackageSourcesToBuildDir(type: Copy, dependsOn: rDNADocument) {
from "$rootDir/rDNA/rDNA"
into "$rootDir/build/temp-rDNA"
exclude 'inst/java/**'
}

// Task to ensure the inst/java directory exists in the temporary build directory
task createJavaDirInTempBuildDir {
task createJavaDirInTempBuildDir (dependsOn: copyRPackageSourcesToBuildDir) {
doLast {
def javaDir = file("$rootDir/build/temp-rDNA/inst/java")
if (!javaDir.exists()) {
Expand All @@ -41,8 +36,20 @@ task createJavaDirInTempBuildDir {
}
}

// Task to find the most recent JAR file in the build directory
def findLatestJarFile() {
def jarDir = file("$rootDir/build")
def jarFiles = jarDir.listFiles({ file -> file.name.endsWith('.jar') } as FileFilter)

if (jarFiles && jarFiles.size() > 0) {
return jarFiles.sort { -it.lastModified() }[0]
} else {
throw new GradleException("No jar files found in the build directory.")
}
}

// Task to copy the JAR file into the inst/java directory
task copyJarIntoTempBuildDir {
task copyJarIntoTempBuildDir (dependsOn: createJavaDirInTempBuildDir) {
dependsOn ':dna:build', createJavaDirInTempBuildDir
doLast {
def latestJar = findLatestJarFile()
Expand All @@ -57,15 +64,8 @@ task copyJarIntoTempBuildDir {
}
}

// Task to copy R package sources to a temporary build directory
task copyRPackageSourcesToBuildDir(type: Copy) {
from "$rootDir/rDNA/rDNA"
into "$rootDir/build/temp-rDNA"
exclude 'inst/java/**'
}

// Task to build the R package (create a .tar.gz file) and clean up after
task rDNABuild(dependsOn: [rDNADocument, copyRPackageSourcesToBuildDir, copyJarIntoTempBuildDir]) {
task rDNABuild(dependsOn: copyJarIntoTempBuildDir) {
doLast {
// Delete old .tar.gz files in the build directory
def buildDir = file("$rootDir/build")
Expand Down

0 comments on commit 8da39b8

Please sign in to comment.