datahub/datahub-frontend/build.gradle
Hendrik Richert 966cb175f7
feat(dev): Make repositories configurable for enterprise developers (#9230)
Co-authored-by: Hendrik Richert <hendrik.richert@swisscom.com>
Co-authored-by: david-leifker <114954101+david-leifker@users.noreply.github.com>
2023-11-28 14:52:11 -06:00

124 lines
3.2 KiB
Groovy

plugins {
id "io.github.kobylynskyi.graphql.codegen" version "4.1.1"
id 'scala'
id 'com.palantir.docker'
}
apply from: "../gradle/versioning/versioning.gradle"
apply from: './play.gradle'
ext {
docker_repo = 'datahub-frontend-react'
docker_dir = 'datahub-frontend'
}
model {
// Must specify the dependency here as "stage" is added by rule based model.
tasks.myTar {
dependsOn stage
}
}
task myTar(type: Tar) {
extension = "tgz"
compression = Compression.GZIP
from("${buildDir}/stage")
into("bin") {
from("bin")
}
into("conf") {
from("conf")
fileMode = 0600
}
}
artifacts {
archives myTar
}
graphqlCodegen {
// For options: https://github.com/kobylynskyi/graphql-java-codegen/blob/master/docs/codegen-options.md
graphqlSchemaPaths = ["$projectDir/conf/datahub-frontend.graphql".toString()]
outputDir = new File("$projectDir/app/graphql")
packageName = "generated"
generateApis = true
modelValidationAnnotation = ""
customTypesMapping = [
Long: "Long",
]
}
tasks.withType(Checkstyle) {
exclude "**/generated/**"
}
checkstyleMain.source = "app/"
/*
PLAY UPGRADE NOTE
Generates the distribution jars under the expected names. The playFramework plugin only accepts certain name values
for the resulting folders and files, so some changes were made to accommodate. Default distribution is main if these are excluded
*/
distributions {
create("datahub-frontend") {
distributionBaseName = project.ext.playBinaryBaseName
}
playBinary {
distributionBaseName = project.ext.playBinaryBaseName
}
}
docker {
name "${docker_registry}/${docker_repo}:v${version}"
version "v${version}"
dockerfile file("${rootProject.projectDir}/docker/${docker_dir}/Dockerfile")
files fileTree(rootProject.projectDir) {
include '.dockerignore'
include 'docker/monitoring/*'
include "docker/${docker_dir}/*"
}.exclude {
i -> (!i.file.name.endsWith(".dockerignore") && i.file.isHidden())
}
tag("Debug", "${docker_registry}/${docker_repo}:debug")
// platform('linux/arm64', 'linux/amd64')
buildx(true)
load(true)
push(false)
// Add build args if they are defined (needed for some CI or enterprise environments)
def dockerBuildArgs = [:]
if (project.hasProperty('alpineApkRepositoryUrl')) {
dockerBuildArgs.ALPINE_REPO_URL = project.getProperty('alpineApkRepositoryUrl')
}
if (project.hasProperty('githubMirrorUrl')) {
dockerBuildArgs.GITHUB_REPO_URL = project.getProperty('githubMirrorUrl')
}
if (project.hasProperty('mavenCentralRepositoryUrl')) {
dockerBuildArgs.MAVEN_CENTRAL_REPO_URL = project.getProperty('mavenCentralRepositoryUrl')
}
if (dockerBuildArgs.size() > 0) {
buildArgs(dockerBuildArgs)
}
}
task unversionZip(type: Copy, dependsOn: [':datahub-web-react:build', dist]) {
from ("${buildDir}/distributions")
include "datahub-frontend-${version}.zip"
into "${buildDir}/docker/"
rename "datahub-frontend-${version}.zip", "datahub-frontend.zip"
}
tasks.getByPath(":datahub-frontend:docker").dependsOn(unversionZip)
task cleanLocalDockerImages {
doLast {
rootProject.ext.cleanLocalDockerImages(docker_registry, docker_repo, "${version}")
}
}
dockerClean.finalizedBy(cleanLocalDockerImages)