Convert update_dependency procedure to use gradle proxy

Collect the set of dependencies using the gradle proxy and push to GCS using
gcs_sync.

TESTED: Verified that the script works against both unupdated and up-to-date
dependency sets, verified that the proxy server is destroyed after completion.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=241529357
This commit is contained in:
mmuller 2019-04-02 08:04:38 -07:00 committed by jianglai
parent c0f5710c31
commit 5470414e48
7 changed files with 10 additions and 92 deletions

View file

@ -13,7 +13,6 @@ buildscript {
} }
plugins { plugins {
id 'maven-publish'
id 'nebula.lint' version '10.4.2' id 'nebula.lint' version '10.4.2'
// Config helper for annotation processors such as AutoValue and Dagger. // Config helper for annotation processors such as AutoValue and Dagger.
// Ensures that source code is generated at an appropriate location. // Ensures that source code is generated at an appropriate location.
@ -73,60 +72,6 @@ task stage {
description = 'Generates application directories for all services.' description = 'Generates application directories for all services.'
} }
if (publishUrl) {
publishing {
repositories {
maven {
url publishUrl
}
}
}
}
ext.processedDependencies = [] as Set<String>
ext.processDependencies = { Set<ResolvedDependency> deps ->
if (deps.isEmpty()) {
return
}
deps.each { ResolvedDependency dep ->
if (dep.moduleGroup == "nomulus" ||
rootProject.processedDependencies.contains(dep.module.toString())) {
return
}
def name = "${dep.moduleGroup}_${dep.moduleName}_${dep.moduleVersion}"
rootProject.publishing {
publications {
"${name}"(MavenPublication) {
groupId = dep.moduleGroup
artifactId = dep.moduleName
version = dep.moduleVersion
dep.moduleArtifacts.each { moduleArtifact ->
artifact(moduleArtifact.file) {
classifier = moduleArtifact.classifier
}
}
if (!dep.children.isEmpty()) {
pom.withXml {
def dependenciesNode = asNode().appendNode("dependencies")
dep.children.each {
def dependencyNode =
dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", it.moduleGroup)
dependencyNode.appendNode("artifactId", it.moduleName)
dependencyNode.appendNode("version", it.moduleVersion)
}
}
}
}
}
}
rootProject.processedDependencies.add(dep.module.toString())
rootProject.processDependencies(dep.children)
}
}
ext.constructMavenCoordinate = { deps, distinctMetadata -> ext.constructMavenCoordinate = { deps, distinctMetadata ->
if (deps.isEmpty()) { if (deps.isEmpty()) {
return return
@ -146,31 +91,15 @@ allprojects {
if (project.name == 'services') return if (project.name == 'services') return
repositories { repositories {
if (rootProject.repositoryUrl) { if (rootProject.mavenUrl) {
maven { maven {
url rootProject.repositoryUrl url rootProject.mavenUrl
} }
} else { } else {
mavenCentral() mavenCentral()
} }
} }
ext.generateDependencyPublications = {
def allconfigs = []
allconfigs.addAll(configurations)
// This only adds buildscript dependencies declare in this project.
allconfigs.addAll(buildscript.configurations)
allconfigs.each {
if (!it.isCanBeResolved()) {
return
}
rootProject.processDependencies(
it.resolvedConfiguration.firstLevelModuleDependencies)
}
}
// This task generates a Maven coordinate for each resolved dependency and // This task generates a Maven coordinate for each resolved dependency and
// stores them in the given file. // stores them in the given file.
task generateMavenCoordinateForDependency { task generateMavenCoordinateForDependency {
@ -218,8 +147,6 @@ subprojects {
lockAllConfigurations() lockAllConfigurations()
} }
apply plugin: 'maven-publish'
def services = [':services:default', def services = [':services:default',
':services:backend', ':services:backend',
':services:tools', ':services:tools',
@ -290,7 +217,6 @@ subprojects {
appengine { appengine {
deploy { deploy {
// TODO: change this to a variable.
project = gcpProject project = gcpProject
} }
} }
@ -413,5 +339,3 @@ subprojects {
} }
} }
} }
generateDependencyPublications()

View file

@ -1,12 +1,12 @@
repositories { repositories {
if (project.ext.properties.repositoryUrl == null) { if (project.ext.properties.mavenUrl == null) {
println "Plugins: Using Maven central..." println "Plugins: Using Maven central..."
mavenCentral() mavenCentral()
} else { } else {
maven { maven {
println "Plugins: Using repo ${repositoryUrl}..." println "Plugins: Using repo ${mavenUrl}..."
url repositoryUrl url mavenUrl
} }
} }
} }

View file

@ -687,5 +687,3 @@ task nomulus(type: Jar) {
with jar with jar
dependsOn project(':third_party').jar dependsOn project(':third_party').jar
} }
generateDependencyPublications()

View file

@ -1,5 +1,5 @@
repositoryUrl= mavenUrl=
publishUrl= pluginsUrl=
uploaderDestination= uploaderDestination=
uploaderCredentialsFile= uploaderCredentialsFile=
uploaderMultithreadedUpload= uploaderMultithreadedUpload=

View file

@ -74,5 +74,3 @@ dependencies {
annotationProcessor deps['com.google.dagger:dagger-compiler'] annotationProcessor deps['com.google.dagger:dagger-compiler']
testAnnotationProcessor deps['com.google.dagger:dagger-compiler'] testAnnotationProcessor deps['com.google.dagger:dagger-compiler']
} }
generateDependencyPublications()

View file

@ -1,9 +1,9 @@
if (repositoryUrl) { if (pluginsUrl) {
println "Using repository $repositoryUrl for plugins" println "Using repository $pluginsUrl for plugins"
pluginManagement { pluginManagement {
repositories { repositories {
maven { maven {
url repositoryUrl url pluginsUrl
} }
} }
} }

View file

@ -30,5 +30,3 @@ dependencies {
testAnnotationProcessor deps['com.google.auto.value:auto-value'] testAnnotationProcessor deps['com.google.auto.value:auto-value']
testAnnotationProcessor deps['com.google.dagger:dagger-compiler'] testAnnotationProcessor deps['com.google.dagger:dagger-compiler']
} }
generateDependencyPublications()