-
Notifications
You must be signed in to change notification settings - Fork 624
Create publishChangedToBuildDir
task.
#494
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,12 @@ | |
|
||
package com.google.firebase.gradle.plugins.publish | ||
|
||
import com.google.firebase.gradle.plugins.ci.AffectedProjectFinder | ||
import com.google.firebase.gradle.plugins.FirebaseLibraryExtension | ||
import digital.wup.android_maven_publish.AndroidMavenPublishPlugin | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.ProjectDependency | ||
import org.gradle.api.publish.maven.MavenPublication | ||
import org.gradle.api.tasks.bundling.Jar | ||
import org.gradle.api.tasks.bundling.Zip | ||
|
@@ -83,8 +85,12 @@ class PublishingPlugin implements Plugin<Project> { | |
|
||
def publishAllToLocal = project.task('publishAllToLocal') | ||
def publishAllToBuildDir = project.task('publishAllToBuildDir') | ||
def publishChangedToBuildDir = project.task('publishChangedToBuildDir') | ||
def firebasePublish = project.task('firebasePublish') | ||
|
||
def changedProjects = | ||
new AffectedProjectFinder(project, changedPaths(project.rootDir), []).find() | ||
|
||
project.getGradle().projectsEvaluated { | ||
project.subprojects { Project sub -> | ||
if (!sub.plugins.hasPlugin('firebase-library')) { | ||
|
@@ -121,10 +127,27 @@ class PublishingPlugin implements Plugin<Project> { | |
publisher.decorate(sub, it) | ||
} | ||
} | ||
|
||
// Add changed projects to publishChangedToBuildDir. | ||
if (changedProjects.contains(sub)) { | ||
publishChangedToBuildDir.dependsOn "$sub.path:publishMavenAarPublicationToBuildDirRepository" | ||
def dependencies = sub.configurations.implementation.dependencies | ||
for (def dep : dependencies) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the intent here? Why do we need to publish dependencies of the project? Also, if it is needed indeed, don't we also want to publish dependencies of dependencies recursively? |
||
if (dep instanceof ProjectDependency) { | ||
def task = dep.getDependencyProject() | ||
.tasks.findByName("publishMavenAarPublicationToBuildDirRepository") | ||
if (task != null) { | ||
publishChangedToBuildDir.dependsOn task | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not how those tasks are configured. They don't publish their dependencies. |
||
} | ||
} | ||
} | ||
} | ||
|
||
publishAllToLocal.dependsOn "$sub.path:publishMavenAarPublicationToMavenLocal" | ||
publishAllToBuildDir.dependsOn "$sub.path:publishMavenAarPublicationToBuildDirRepository" | ||
|
||
} | ||
|
||
} | ||
project.task('publishProjectsToMavenLocal') { | ||
projectsToPublish.each { projectToPublish -> | ||
|
@@ -155,6 +178,13 @@ class PublishingPlugin implements Plugin<Project> { | |
} | ||
} | ||
|
||
private static Set<String> changedPaths(File workDir) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. afaicr, we have the same git command elsewhere, can we centralize this in one place to avoid duplication? |
||
return 'git diff --name-only --submodule=diff HEAD@{0} HEAD@{1}' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to see if git can be run programmatically. But it is probably fine if you think this task will be invoked only on machines that has git available. Also, what is the intended diff range here? I think HEAD@{1} can be any commit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It diffs head and head - 1. I copied this from the checkChanged tasks. I think this is primarily intended for Prow, as it might give misleading results locally. |
||
.execute([], workDir) | ||
.text | ||
.readLines() | ||
} | ||
|
||
private static String getPublishTask(Project p, String repoName) { | ||
return "${p.path}:publishMavenAarPublicationTo$repoName" | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
s/implementation/releaseRuntimeClasspath/