Skip to content

Commit

Permalink
Start publishing proper artifacts. (airbytehq#13484)
Browse files Browse the repository at this point in the history
## What
Finale of airbytehq#13122.

We've renamed all directories in previous PRs. Here we remove the fat jar configuration and add publishing to all subprojects.

Explanation for what is happening:

Identically named subprojects have the following issues:
* publishing as is leads to classpath confusion when the jars with the same names are placed in the Java distribution. This leads to NoClassDefFound errors on runtime.
* deconflicting the jar names without changing directory names leads to dependency errors as the OSS jar pom files are generated using project dependencies (suggesting a dependency a sibling subproject in the same repo) that use subprojects group and name as a reference. This means the generated jars look for Jars that do not exists (as their names have been changed) and cannot compile.
* the workaround to changing a subproject's name involves resetting the subproject's name in the settings.gradle and depending on the new name in each build.gradle. This increases configuration burden and decreases the ease of reading, since one will have to check the settings.gradle to know what the right subproject name is. See gradle/gradle#847 for more info.
* given that Gradle itself doesn't have support for identically named subprojects (see the linked issue), the simplest solution is to not allow duplicated directories. I've only renamed conflicting directories here to keep things simple. I will create a follow up issues to enforce non-identical subproject names in our builds.

## How
* Remove fat jar configuration.
* Add publishing to all subprojects.
  • Loading branch information
davinchia authored Jun 6, 2022
1 parent e9a9439 commit 7788594
Show file tree
Hide file tree
Showing 23 changed files with 61 additions and 112 deletions.
2 changes: 2 additions & 0 deletions airbyte-analytics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ dependencies {
implementation project(':airbyte-config:config-persistence')
implementation project(':airbyte-json-validation')
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
1 change: 1 addition & 0 deletions airbyte-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,4 @@ sourceSets {
}
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
48 changes: 2 additions & 46 deletions airbyte-bootloader/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
plugins {
id 'application'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.1.0'
}

dependencies {
Expand All @@ -26,50 +24,6 @@ application {
applicationDefaultJvmArgs = ['-XX:+ExitOnOutOfMemoryError', '-XX:MaxRAMPercentage=75.0']
}

// Publish this so Airbyte Cloud can consume and extend the classes within this jar.
// This needs to be a shadow jar as none of the other modules are published.
shadowJar {
preserveFileTimestamps = false
reproducibleFileOrder = true
zip64 true
mergeServiceFiles()
exclude 'META-INF/*.RSA'
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
// Not stubbing this out adds 'all' to the end of the jar's name.
classifier = ''
}

publishing {
publications {
shadow(MavenPublication) { publication ->
project.shadow.component(publication)
}
}

repositories {
publications {
// This block is present so Gradle knows to publish a Maven jar.
maven(MavenPublication) {
from components.java
// Gradle will by default use the subproject path as the group id and the subproject name as the artifact id.
// e.g. the subproject :airbyte-scheduler:scheduler-models is imported at io.airbyte.airbyte-config:config-persistence:<version-number>.
}
}

maven {
credentials {
name 'cloudrepo'
username System.getenv('CLOUDREPO_USER')
password System.getenv('CLOUDREPO_PASSWORD')
}
url 'https://airbyte.mycloudrepo.io/repositories/airbyte-public-jars'
}

mavenLocal()
}
}

task copyGeneratedTar(type: Copy) {
dependsOn copyDocker
dependsOn distTar
Expand All @@ -90,3 +44,5 @@ tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-commons-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ plugins {
dependencies {
implementation 'commons-cli:commons-cli:1.4'
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-commons-docker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ dependencies {

testImplementation 'org.apache.commons:commons-lang3:3.11'
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-commons/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ dependencies {
// this dependency is an exception to the above rule because it is only used INTERNALLY to the commons library.
implementation 'com.jayway.jsonpath:json-path:2.7.0'
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-config/config-models/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ task logClientsIntegrationTest(type: Test) {
events "passed", "skipped", "failed"
}
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-config/config-persistence/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ dependencies {
testImplementation project(':airbyte-test-utils')
integrationTestJavaImplementation project(':airbyte-config:config-persistence')
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-config/init/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ task copyScripts(type: Copy) {
Task dockerBuildTask = getDockerBuildTask("init", "$project.projectDir", "$rootProject.ext.version", "$rootProject.ext.image_tag")
dockerBuildTask.dependsOn(copyScripts)
assemble.dependsOn(dockerBuildTask)

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-config/specs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ task generateSeedConnectorSpecs(type: JavaExec, dependsOn: compileJava) {
}

project(":airbyte-config:init").tasks.processResources.dependsOn(generateSeedConnectorSpecs)

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-db/db-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,5 @@ task copyInitSql(type: Copy) {
Task dockerBuildTask = getDockerBuildTask("db", "$project.projectDir", "$rootProject.ext.version", "$rootProject.ext.image_tag")
dockerBuildTask.dependsOn(copyInitSql)
assemble.dependsOn(dockerBuildTask)

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-db/jooq/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ tasks.named('generateJobsDatabaseJooq').configure {
allInputsDeclared = true
outputs.cacheIf { true }
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-json-validation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ dependencies {
// needed so that we can follow $ref when parsing json. jackson does not support this natively.
implementation 'me.andrz.jackson:jackson-json-reference-core:0.3.2'
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-metrics/metrics-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ dependencies {
testImplementation project(':airbyte-test-utils')
testImplementation libs.testcontainers.postgresql
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-notification/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ dependencies {
implementation project(':airbyte-config:config-models')
implementation project(':airbyte-json-validation')
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-oauth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ dependencies {
implementation project(':airbyte-protocol:protocol-models')
testImplementation project(':airbyte-oauth')
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-protocol/protocol-models/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ jsonSchema2Pojo {
includeConstructors = false
includeSetters = true
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-scheduler/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ task copyGeneratedTar(type: Copy) {
Task dockerBuildTask = getDockerBuildTask("scheduler", "$project.projectDir", "$rootProject.ext.version", "$rootProject.ext.image_tag")
dockerBuildTask.dependsOn(copyGeneratedTar)
assemble.dependsOn(dockerBuildTask)

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-scheduler/client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ dependencies {
implementation 'com.google.cloud:google-cloud-storage:2.2.2'

}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-scheduler/scheduler-models/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ dependencies {
implementation project(':airbyte-config:config-models')
implementation project(':airbyte-protocol:protocol-models')
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-scheduler/scheduler-persistence/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ dependencies {
testImplementation libs.testcontainers.postgresql
testImplementation project(':airbyte-test-utils')
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
84 changes: 18 additions & 66 deletions airbyte-server/build.gradle
Original file line number Diff line number Diff line change
@@ -1,72 +1,8 @@
plugins {
id 'application'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.1.0'
}

// This is published as a shadow jar as the Airbyte Server jar is currently used
// as a delivery mechanism for the common Airbyte libraries and clients. Proper
// publishing is blocked on some gradle work.
shadowJar {
// following properties need to be set here to have reproducible shadow archives, doesn't seem to inherit from AbstractArchiveTask
preserveFileTimestamps = false
reproducibleFileOrder = true

zip64 true
mergeServiceFiles()
exclude 'META-INF/*.RSA'
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
// Not stubbing this out adds 'all' to the end of the jar's name.
classifier = ''
}

publishing {
publications {
shadow(MavenPublication) { publication ->
project.shadow.component(publication)
}
}
repositories {
publications {
// This block is present so Gradle knows to publish a Maven jar.
maven(MavenPublication) {
from components.java
// Gradle will by default use the subproject path as the group id and the subproject name as the artifact id.
// e.g. the subproject :airbyte-scheduler:scheduler-models is imported at io.airbyte.airbyte-config:config-persistence:<version-number>.
}
}

maven {
credentials {
name 'cloudrepo'
username System.getenv('CLOUDREPO_USER')
password System.getenv('CLOUDREPO_PASSWORD')
}
url 'https://airbyte.mycloudrepo.io/repositories/airbyte-public-jars'
}

mavenLocal()
}
}

dependencies {
implementation 'io.temporal:temporal-sdk:1.8.1'

implementation 'org.apache.cxf:cxf-core:3.4.2'

implementation 'commons-cli:commons-cli:1.4'
implementation 'org.eclipse.jetty:jetty-server:9.4.31.v20200723'
implementation 'org.eclipse.jetty:jetty-servlet:9.4.31.v20200723'
implementation 'org.glassfish.jaxb:jaxb-runtime:3.0.2'
implementation 'org.glassfish.jersey.containers:jersey-container-servlet'
implementation 'org.glassfish.jersey.inject:jersey-hk2'
implementation 'org.glassfish.jersey.media:jersey-media-json-jackson'
implementation 'org.glassfish.jersey.ext:jersey-bean-validation'
implementation libs.flyway.core

implementation 'com.github.slugify:slugify:2.4'

implementation project(':airbyte-analytics')
implementation project(':airbyte-api')
implementation project(':airbyte-commons-docker')
Expand All @@ -85,10 +21,24 @@ dependencies {
implementation project(':airbyte-scheduler:scheduler-persistence')
implementation project(':airbyte-workers')

implementation libs.flyway.core
implementation 'com.github.slugify:slugify:2.4'
implementation 'commons-cli:commons-cli:1.4'
implementation 'io.temporal:temporal-sdk:1.8.1'
implementation 'org.apache.cxf:cxf-core:3.4.2'
implementation 'org.eclipse.jetty:jetty-server:9.4.31.v20200723'
implementation 'org.eclipse.jetty:jetty-servlet:9.4.31.v20200723'
implementation 'org.glassfish.jaxb:jaxb-runtime:3.0.2'
implementation 'org.glassfish.jersey.containers:jersey-container-servlet'
implementation 'org.glassfish.jersey.inject:jersey-hk2'
implementation 'org.glassfish.jersey.media:jersey-media-json-jackson'
implementation 'org.glassfish.jersey.ext:jersey-bean-validation'


testImplementation project(':airbyte-test-utils')
testImplementation libs.postgresql
testImplementation 'com.squareup.okhttp3:mockwebserver:4.9.1'
testImplementation libs.testcontainers.postgresql
testImplementation project(':airbyte-test-utils')
testImplementation 'com.squareup.okhttp3:mockwebserver:4.9.1'
}

// we want to be able to access the generated db files from config/init when we build the server docker image.
Expand Down Expand Up @@ -154,3 +104,5 @@ tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
2 changes: 2 additions & 0 deletions airbyte-workers/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@ task cloudStorageIntegrationTest(type: Test) {
events "passed", "skipped", "failed"
}
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)

0 comments on commit 7788594

Please sign in to comment.