Created
March 29, 2019 04:13
-
-
Save thesurlydev/1d36b8cae2e105f164acb3d74cbfe6e7 to your computer and use it in GitHub Desktop.
Problematic build with shadowJar 4.0.2 or later
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | |
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | |
plugins { | |
kotlin("jvm") version "1.3.21" | |
id("com.github.johnrengelman.shadow") version "5.0.0" | |
id("jmfayard.github.io.gradle-kotlin-dsl-libs") version "0.2.6" // $ ./gradlew syncLibs | |
id("com.google.cloud.tools.jib") version "1.0.2" | |
id("org.springframework.boot") version "2.1.3.RELEASE" apply false | |
id("io.spring.dependency-management") version "1.0.7.RELEASE" | |
} | |
repositories { | |
jcenter() | |
mavenCentral() | |
} | |
allprojects { | |
apply { | |
plugin("kotlin") | |
} | |
dependencies { | |
compile(Libs.kotlin_stdlib_jdk8) | |
testImplementation(Libs.junit) | |
} | |
java { | |
sourceCompatibility = JavaVersion.VERSION_1_8 | |
targetCompatibility = JavaVersion.VERSION_1_8 | |
} | |
} | |
subprojects { | |
tasks.withType<KotlinCompile> { | |
kotlinOptions { | |
jvmTarget = "1.8" | |
freeCompilerArgs = listOf("-Xjsr305=strict") | |
} | |
} | |
repositories { | |
mavenLocal() | |
jcenter() | |
mavenCentral() | |
} | |
} | |
project(":function") { | |
apply { | |
plugin("com.github.johnrengelman.shadow") | |
} | |
tasks.withType<ShadowJar> { | |
this.simpleJarName("function") | |
} | |
} | |
project(":microservice") { | |
apply { | |
plugin("com.github.johnrengelman.shadow") | |
plugin("com.google.cloud.tools.jib") | |
plugin("org.springframework.boot") | |
plugin("io.spring.dependency-management") | |
} | |
dependencies { | |
implementation(Libs.spring_boot_starter_web) | |
implementation(Libs.jackson_module_kotlin) | |
implementation(Libs.kotlin_reflect) | |
testImplementation(Libs.spring_boot_starter_test) | |
} | |
jib { | |
to { | |
image = "123123.dkr.ecr.us-east-1.amazonaws.com/${project.name}:${project.version}" | |
credHelper = "ecr-login" | |
} | |
} | |
} | |
project(":task") { | |
apply { | |
plugin("com.github.johnrengelman.shadow") | |
plugin("com.google.cloud.tools.jib") | |
} | |
dependencies { | |
compile(Libs.slf4j_log4j12) | |
compile(Libs.dynamodb_tools_replication) | |
} | |
jib { | |
to { | |
image = "123123.dkr.ecr.us-east-1.amazonaws.com/${project.name}:${project.version}" | |
credHelper = "ecr-login" | |
} | |
} | |
} | |
project(":task-executor") { | |
dependencies { | |
compile(Libs.slf4j_log4j12) | |
compile(Libs.kotlin_stdlib_jdk8) | |
compile(Libs.kotlinx_coroutines_jdk8) | |
compile(Libs.software_amazon_awssdk_ecs) | |
compile(Libs.dynamodb_tools_replication) | |
} | |
} | |
project(":stack") { | |
dependencies { | |
compile(Libs.cdk) | |
compile(Libs.dynamodb) | |
compile(Libs.elasticloadbalancingv2) | |
compile(Libs.software_amazon_awscdk_ecs) | |
compile(Libs.iam) | |
compile(Libs.lambda) | |
compile(Libs.codebuild) | |
compile(Libs.codedeploy) | |
compile(Libs.codepipeline) | |
// s3 is transitive dependency of ecs | |
compile(Libs.stepfunctions) | |
} | |
} | |
project(":provision") { | |
apply { | |
plugin("com.github.johnrengelman.shadow") | |
} | |
dependencies { | |
api(project(":stack")) | |
} | |
tasks.withType<ShadowJar> { | |
isZip64 = true // required if over 64K files | |
this.simpleJarName("provision") | |
this.manifest { | |
attributes(mapOf( | |
"Main-Class" to "io.futz.MyAppKt", | |
"Implementation-Title" to project.name, | |
"Implementation-Version" to project.version | |
)) | |
} | |
} | |
} | |
fun taggedImage(): String { | |
if (!project.hasProperty("accountId")) { | |
System.err.println("Missing 'accountId' property") | |
} | |
if (!project.hasProperty("region")) { | |
System.err.println("Missing 'region' property") | |
} | |
val accountId = project.property("accountId") | |
val region = project.property("region") | |
val taggedImage = "$accountId.dkr.ecr.$region.amazonaws.com/${project.name}:${project.version}" | |
println("taggedImage=$taggedImage") | |
return taggedImage | |
} | |
fun ShadowJar.simpleJarName(name: String) { | |
this.archiveBaseName.set(name) | |
this.archiveClassifier.set("") | |
this.archiveVersion.set("") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment