Skip to content

Instantly share code, notes, and snippets.

@aadrian
Created May 19, 2019 21:06
Show Gist options
  • Save aadrian/f072d02c86200aea3085e0faafd09949 to your computer and use it in GitHub Desktop.
Save aadrian/f072d02c86200aea3085e0faafd09949 to your computer and use it in GitHub Desktop.
Gradle snippets for tools
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
compileJava.options.encoding = 'UTF-8'
jar {
manifest {
attributes 'Main-Class': mainClassName,
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Implementation-Version': version
}
}
// cleanup dist extra files
clean.doFirst {
// cleanup everything.
delete fileTree(dir: '/src/dist', include: ['**/*'])
// delete fileTree(dir: '/src/dist/conf', include: ['*.ddl']) // selective cleanup, in case some file need to be present in the distribution.
// delete fileTree(dir: '/src/dist/conf', include: ['*.yml'])
}
// startScripts are called before buildZip and buildTar
startScripts {
doLast {
println "Executing after startScripts"
// copy the start shell script
copy {
from './'
include '*.sh'
into '/src/dist'
}
// copy readme
copy {
from './'
include 'README.md'
into '/src/dist'
}
// copy changelog
copy {
from './'
include 'changelog.txt'
into '/src/dist'
}
// copy ddls (to the conf) to have them on the server too
copy {
from './'
include '*.ddl'
into '/src/dist/conf/'
}
// copy some initial SQL files to have them on the server too
copy {
from './'
include '*.sql'
into '/src/dist/conf/'
}
// copy some initial CSV files (if any)
copy {
from 'data/'
include '**/*.csv'
into '/src/dist/data/'
}
// copy the empty cache DB (you need to make sure that locally this is clean
copy {
from 'data/in/'
include 'h2_cache.mv.db'
into '/src/dist/data/in/'
}
// copy the config file
// NOTE: when the build will be automatic, this needs to be removed, since the config file does not belong in a repo
copy {
from './'
include 'conf*.yml'
into '/src/dist/conf/'
}
}
}
/// -----------NOTE------------------------------------------------------
// Build distributions without version in name (until we use the UI)
/*
distZip {
archiveName "${baseName}.zip"
doLast {
file("$destinationDir/$archiveName").renameTo("$destinationDir/"+baseName+'-'+version+'.zip')
}
}
distTar {
archiveName "${baseName}.tar"
doLast {
file("$destinationDir/$archiveName").renameTo("$destinationDir/"+baseName+'-'+version+'.tar')
}
}
*/
/// -----------END---------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment