Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gradle/gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
melix committed Jan 24, 2020
2 parents fad140c + ea25260 commit ad9a050
Show file tree
Hide file tree
Showing 119 changed files with 4,237 additions and 2,722 deletions.
7 changes: 7 additions & 0 deletions build.gradle.kts
Expand Up @@ -20,6 +20,7 @@ import org.gradle.gradlebuild.ProjectGroups.javaProjects
import org.gradle.gradlebuild.ProjectGroups.kotlinJsProjects
import org.gradle.gradlebuild.ProjectGroups.pluginProjects
import org.gradle.gradlebuild.ProjectGroups.publicJavaProjects
import org.gradle.gradlebuild.UpdateAgpVersions
import org.gradle.gradlebuild.UpdateBranchStatus
import org.gradle.gradlebuild.buildquality.incubation.IncubatingApiAggregateReportTask
import org.gradle.gradlebuild.buildquality.incubation.IncubatingApiReportTask
Expand Down Expand Up @@ -390,6 +391,12 @@ tasks.register<Install>("installAll") {

tasks.register<UpdateBranchStatus>("updateBranchStatus")

tasks.register<UpdateAgpVersions>("updateAgpVersions") {
comment.set(" Generated - Update by running `./gradlew updateAgpVersions`")
minimumSupportedMinor.set("3.4")
propertiesFile.set(layout.projectDirectory.file("gradle/dependency-management/agp-versions.properties"))
}

fun distributionImage(named: String) =
project(":distributions").property(named) as CopySpec

Expand Down
@@ -0,0 +1,86 @@
/*
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.gradle.gradlebuild

import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import org.gradle.build.ReproduciblePropertiesWriter
import org.w3c.dom.Element
import java.util.Properties
import javax.xml.parsers.DocumentBuilderFactory


/**
* Fetch the latest AGP versions and write a properties file.
* Never up-to-date, non-cacheable.
*/
abstract class UpdateAgpVersions : DefaultTask() {

@get:Internal
abstract val comment: Property<String>

@get:Internal
abstract val minimumSupportedMinor: Property<String>

@get:Internal
abstract val propertiesFile: RegularFileProperty

@TaskAction
fun fetch() {

val dbf = DocumentBuilderFactory.newInstance()
val latests = dbf.fetchLatests(minimumSupportedMinor.get())
val nightly = dbf.fetchNightly()
val properties = Properties().apply {
setProperty("latests", latests.joinToString(","))
setProperty("nightly", nightly)
}
ReproduciblePropertiesWriter.store(
properties,
propertiesFile.get().asFile,
comment.get()
)
}

private
fun DocumentBuilderFactory.fetchLatests(minimumSupported: String): List<String> {
var latests = fetchVersionsFromMavenMetadata("https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/maven-metadata.xml")
.groupBy { it.take(3) }
.map { (_, versions) -> versions.first() }
latests = (latests + minimumSupported).sorted()
latests = latests.subList(latests.indexOf(minimumSupported) + 1, latests.size)
return latests
}

private
fun DocumentBuilderFactory.fetchNightly(): String =
fetchVersionsFromMavenMetadata("https://repo.gradle.org/gradle/ext-snapshots-local/com/android/tools/build/gradle/maven-metadata.xml")
.first()

private
fun DocumentBuilderFactory.fetchVersionsFromMavenMetadata(url: String): List<String> =
newDocumentBuilder()
.parse(url)
.getElementsByTagName("version").let { versions ->
(0 until versions.length)
.map { idx -> (versions.item(idx) as Element).textContent }
.reversed()
}
}
3 changes: 3 additions & 0 deletions gradle/dependency-management/agp-versions.properties
@@ -0,0 +1,3 @@
# Generated - Update by running `./gradlew updateAgpVersions`
latests=3.4.2,3.5.3,3.6.0-rc01,4.0.0-alpha09
nightly=4.0.0-20200121203636+0000
4 changes: 2 additions & 2 deletions released-versions.json
@@ -1,7 +1,7 @@
{
"latestReleaseSnapshot": {
"version": "6.1.1-20200122000153+0000",
"buildTime": "20200122000153+0000"
"version": "6.1.1-20200124000049+0000",
"buildTime": "20200124000049+0000"
},
"latestRc": {
"version": "6.1-rc-3",
Expand Down
Expand Up @@ -83,12 +83,12 @@ public interface Property<T> extends Provider<T>, HasConfigurableValue {
/**
* Specifies the value to use as the convention for this property. The convention is used when no value has been set for this property.
*
* @param value The value.
* @param value The value, or null if the convention is that the property should have no value.
* @return this
* @since 5.1
*/
@Incubating
Property<T> convention(T value);
Property<T> convention(@Nullable T value);

/**
* Specifies the provider of the value to use as the convention for this property. The convention is used when no value has been set for this property.
Expand Down
Expand Up @@ -1392,7 +1392,6 @@ task generate(type: TransformerTask) {
outputFile.text == 'second'
}

@ToBeImplemented
@Issue("https://github.com/gradle/gradle/issues/11805")
def "Groovy property annotated as @Internal with differently annotated getter emits warning about conflicting annotations"() {
def inputFile = file("input.txt")
Expand Down Expand Up @@ -1425,21 +1424,24 @@ task generate(type: TransformerTask) {
"""

when:
executer.expectDeprecationWarning()
run "custom"
then:
executedAndNotSkipped ":custom"
outputContains("Property 'classpath' annotated with @Internal should not be also annotated with @InputFiles, @Classpath. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0.")

when:
executer.expectDeprecationWarning()
run "custom"
then:
skipped ":custom"

when:
executer.expectDeprecationWarning()
inputFile.text = "changed"
run "custom"

then:
// FIXME This should execute instead of being skipped, or emit a warning
skipped ":custom"
}
}
Expand Up @@ -113,7 +113,7 @@ class TaskDependencyInferenceIntegrationTest extends AbstractIntegrationSpec imp
buildFile << """
def task = tasks.create("a", FileProducer) {
output = file("a.txt")
}
}
tasks.register("b") {
dependsOn task.output.map { throw new RuntimeException() }
}
Expand Down Expand Up @@ -488,7 +488,7 @@ The following types/formats are supported:

then:
failure.assertHasDescription("Could not determine the dependencies of task ':a'.")
failure.assertHasCause("No value has been specified for this property.")
failure.assertHasCause("Cannot query the value of this property because it has no value available.")
}

def "input file collection containing task provider implies dependency on all outputs of the task"() {
Expand Down Expand Up @@ -563,7 +563,7 @@ The following types/formats are supported:
buildFile << """
def taskA = tasks.create("a", FileProducer) {
output = file("a.txt")
content = "a"
content = "a"
}
def taskB = tasks.create("b", FileProducer) {
output = file("b.txt")
Expand All @@ -589,7 +589,7 @@ The following types/formats are supported:
buildFile << """
def taskA = tasks.create("a", FileProducer) {
output = file("a.txt")
content = "a"
content = "a"
}
tasks.register("c", InputFileTask) {
inFile = taskA.output.orElse(file("b.txt"))
Expand Down Expand Up @@ -779,7 +779,7 @@ The following types/formats are supported:
}
configurations { thing }
dependencies { thing a.outputs.files }
tasks.register("b", InputFilesTask) {
inFiles.from configurations.named('thing')
outFile = file("out.txt")
Expand Down

0 comments on commit ad9a050

Please sign in to comment.