MC - MediaCollector. A WebApplication for managing Records and CDs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

268 lines
5.3 KiB

//
// build file for MC
//
// @version 2022-01-04
// @author pilgrim.lutz@imail.de
//
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.owasp:dependency-check-gradle:6.2.2'
}
}
apply plugin: 'org.owasp.dependencycheck'
dependencyCheck {
suppressionFile="${project.rootDir}/dependencyCheck.xml"
failOnError=true
failBuildOnCVSS=0
}
// Settings.
def title = findProperty("mctitle")
def vendor = findProperty("mcvendor")
def version = findProperty("mcversion")
ext {
// Output directory for war file content.
warDir = "${buildDir}/tmp/MC"
}
// Load private settings
def stage = getStage()
allprojects {
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.9
compileJava {
options.compilerArgs << '-Xlint:deprecation'
options.compilerArgs << '-Xlint:unchecked'
}
compileTestJava {
options.compilerArgs << '-Xlint:deprecation'
options.compilerArgs << '-Xlint:unchecked'
}
repositories {
mavenCentral()
}
configurations {
tomcatEmbed
compileClasspath.extendsFrom(tomcatEmbed)
}
configurations.all {
// Because liquibase brings along old jars. And we have already an logger binding in log4j-slf4j-core.
exclude group: "ch.qos.logback", module: "logback-classic"
}
dependencies {
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.1'
compile 'org.apache.logging.log4j:log4j-core:2.17.1'
compile 'org.bouncycastle:bcprov-jdk15on:1.67'
compile 'org.liquibase:liquibase-core:3.10.3'
runtime 'org.yaml:snakeyaml:1.29'
compile 'org.apache.velocity:velocity:1.6.4'
compile 'velocity-tools:velocity-tools-view:1.4'
implementation ('commons-beanutils:commons-beanutils:1.9.4') {
force = true
}
compile 'commons-digester:commons-digester:2.1'
compile 'org.postgresql:postgresql:42.2.23'
compile 'org.apache.tomcat:tomcat-servlet-api:9.0.54'
compile 'com.github.seancfoley:ipaddress:5.2.0'
compile 'io.micrometer:micrometer-registry-prometheus:1.5.1'
compile 'org.quartz-scheduler:quartz:2.3.2'
compile 'com.fasterxml.jackson.core:jackson-core:2.13.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.13.1'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.13.1'
tomcatEmbed 'org.apache.tomcat.embed:tomcat-embed-core:9.0.54'
tomcatEmbed 'org.apache.tomcat.embed:tomcat-embed-jasper:9.0.54'
tomcatEmbed 'org.apache.tomcat:tomcat-catalina-ha:9.0.54'
runtime 'commons-collections:commons-collections:3.2.2'
}
}
sourceSets {
dockerresources {
resources {
srcDir file("${project.projectDir}/docker")
output.resourcesDir = file("${project.projectDir}/build/libs/")
}
}
}
//
// Task: copyLibs
//
// Copies all JARs to the war directory.
//
task copyLibs(type: Copy) {
from configurations.compile
from configurations.runtime
// Because liquibase brings along old jars. And we have already an logger binding in log4j-slf4j-core.
exclude "**/logback-classic-1.2.3.jar"
into "${warDir}/WEB-INF/lib"
}
// Assemble depends on copyLibs
assemble.dependsOn('copyLibs')
// Cleanup
clean {
doFirst {
delete "${warDir}/WEB-INF/lib"
delete "${warDir}/org"
delete "${warDir}/javax"
}
}
def getStage() {
def stage = findProperty("mcstage")
if (stage == null || stage == "") {
stage = "local"
}
return stage
}
// Build the war file.
jar {
dependsOn "core:build"
dependsOn "application:build"
dependsOn "applicationBeans:build"
dependsOn "copyLibs"
dependsOn "core:compileLaunchersJava"
dependsOn "prepareEmbedTomcat"
manifest {
attributes(
'Specification-Title': "${title}",
'Specification-Version': "${version}",
'Specification-Vendor': "${vendor}",
'Implementation-Title': "${title}",
'Implementation-Version': "${version}",
'Implementation-Vendor': "${vendor}",
'Main-Class': "core.launchers.StartMeUp",
)
}
from "${warDir}"
archiveExtension = "war"
archiveBaseName = "MC"
def sd = getStage()
if (sd != null) {
archiveClassifier = "${sd}"
}
}
// Unzips all the Jars necessary for embedded Tomcat.
// This makes core.launchers.StartMeUp work!
task prepareEmbedTomcat(type: Copy) {
from {configurations.tomcatEmbed.collect{zipTree(it)}}
exclude "about.html"
exclude "ecj.1"
exclude "META-INF/LICENSE"
exclude "META-INF/NOTICE"
exclude "META-INF/web-fragment.xml"
exclude "META-INF/eclipse.inf"
exclude "META-INF/services"
exclude "META-INF/services/*"
into "${warDir}"
}
processDockerresourcesResources {
filesMatching("**/*") {
expand project.properties
}
}
def makeWorkdir() {
return "${project.projectDir}/build/libs/";
}
def makeImagename() {
return "${mcvendor.toLowerCase()}/mc-${mcstage}:${mcversion}";
}
// Make Docker image
task makeDockerImage {
dependsOn 'processDockerresourcesResources'
dependsOn 'jar'
doFirst {
def proc = "docker build -t ${makeImagename()} .".execute(null, file(makeWorkdir()))
proc.waitForProcessOutput(System.out, System.err)
}
}
// Publish docker images
task publishDockerImage {
dependsOn 'makeDockerImage'
def dockreg = System.getenv("DOCKER_REGISTRY")
doFirst {
def proc = "docker tag ${makeImagename()} ${dockreg}/${makeImagename()}".execute(null, file(makeWorkdir()))
proc.waitForProcessOutput(System.out, System.err)
def proc1 = "docker push ${dockreg}/${makeImagename()}".execute(null, file(makeWorkdir()))
proc1.waitForProcessOutput(System.out, System.err)
}
}