Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sourceJar task dependencies #28900

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2395,7 +2395,20 @@ class BeamModulePlugin implements Plugin<Project> {

// TODO: Decide whether this should be inlined into the one project that relies on it
// or be left here.
project.ext.applyAvroNature = { project.apply plugin: "com.commercehub.gradle.plugin.avro" }
project.ext.applyAvroNature = {
project.apply plugin: "com.commercehub.gradle.plugin.avro"

// add dependency BeamModulePlugin defined custom tasks
// they are defined only when certain flags are provided (e.g. -Prelease; -Ppublishing, etc)
def sourcesJar = project.tasks.findByName('sourcesJar')
if (sourcesJar != null) {
sourcesJar.dependsOn project.tasks.getByName('generateAvroJava')
}
def testSourcesJar = project.tasks.findByName('testSourcesJar')
if (testSourcesJar != null) {
testSourcesJar.dependsOn project.tasks.getByName('generateTestAvroJava')
}
}

project.ext.applyAntlrNature = {
project.apply plugin: 'antlr'
Expand All @@ -2406,6 +2419,17 @@ class BeamModulePlugin implements Plugin<Project> {
generatedSourceDirs += project.generateTestGrammarSource.outputDirectory
}
}

// add dependency BeamModulePlugin defined custom tasks
// they are defined only when certain flags are provided (e.g. -Prelease; -Ppublishing, etc)
def sourcesJar = project.tasks.findByName('sourcesJar')
if (sourcesJar != null) {
sourcesJar.mustRunAfter project.tasks.getByName('generateGrammarSource')
}
def testSourcesJar = project.tasks.findByName('testSourcesJar')
if (testSourcesJar != null) {
testSourcesJar.dependsOn project.tasks.getByName('generateTestGrammarSource')
}
}

// Creates a task to run the quickstart for a runner.
Expand Down
23 changes: 19 additions & 4 deletions runners/flink/flink_runner.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,51 @@ evaluationDependsOn(":examples:java")
/*
* Copy & merge source overrides into build directory.
*/
def sourceOverridesBase = "${project.buildDir}/source-overrides/src"
def sourceOverridesBase = project.layout.buildDirectory.dir('source-overrides/src')

def copySourceOverrides = tasks.register('copySourceOverrides', Copy) {
it.from main_source_overrides
it.into "${sourceOverridesBase}/main/java"
it.duplicatesStrategy DuplicatesStrategy.INCLUDE
}
compileJava.dependsOn copySourceOverrides

def copyResourcesOverrides = tasks.register('copyResourcesOverrides', Copy) {
it.from main_resources_overrides
it.into "${sourceOverridesBase}/main/resources"
it.duplicatesStrategy DuplicatesStrategy.INCLUDE
}
processResources.dependsOn copyResourcesOverrides

def copyTestSourceOverrides = tasks.register('copyTestSourceOverrides', Copy) {
it.from test_source_overrides
it.into "${sourceOverridesBase}/test/java"
it.duplicatesStrategy DuplicatesStrategy.INCLUDE
}
compileTestJava.dependsOn copyTestSourceOverrides

def copyTestResourcesOverrides = tasks.register('copyTestResourcesOverrides', Copy) {
it.from test_resources_overrides
it.into "${sourceOverridesBase}/test/resources"
it.duplicatesStrategy DuplicatesStrategy.INCLUDE
}

// add dependency to gradle Java plugin defined tasks
compileJava.dependsOn copySourceOverrides
processResources.dependsOn copyResourcesOverrides
compileTestJava.dependsOn copyTestSourceOverrides
processTestResources.dependsOn copyTestResourcesOverrides

// add dependency BeamModulePlugin defined custom tasks
// they are defined only when certain flags are provided (e.g. -Prelease; -Ppublishing, etc)
def sourcesJar = project.tasks.findByName('sourcesJar')
if (sourcesJar != null) {
sourcesJar.dependsOn copySourceOverrides
sourcesJar.dependsOn copyResourcesOverrides
}
def testSourcesJar = project.tasks.findByName('testSourcesJar')
if (testSourcesJar != null) {
testSourcesJar.dependsOn copyTestSourceOverrides
testSourcesJar.dependsOn copyTestResourcesOverrides
}

/*
* We have to explicitly set all directories here to make sure each
* version of Flink has the correct overrides set.
Expand Down
7 changes: 7 additions & 0 deletions sdks/java/maven-archetypes/examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ task generateSources(type: Exec) {
commandLine './generate-sources.sh'
}

// add dependency BeamModulePlugin defined custom tasks
// they are defined only when certain flags are provided (e.g. -Prelease; -Ppublishing, etc)
def sourcesJar = project.tasks.findByName('sourcesJar')
if (sourcesJar != null) {
sourcesJar.dependsOn generateSources
}

sourceSets {
main {
output.dir('src', builtBy: 'generateSources')
Expand Down
6 changes: 6 additions & 0 deletions sdks/java/maven-archetypes/gcp-bom-examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ task generateSources(type: Exec) {
environment "HERE", "."
commandLine '../examples/generate-sources.sh'
}
// add dependency BeamModulePlugin defined custom tasks
// they are defined only when certain flags are provided (e.g. -Prelease; -Ppublishing, etc)
def sourcesJar = project.tasks.findByName('sourcesJar')
if (sourcesJar != null) {
sourcesJar.dependsOn generateSources
}

sourceSets {
main {
Expand Down
Loading