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

Migrate rest.li build to use Gradle 6.9.4 #977

Merged
merged 1 commit into from
Feb 6, 2024
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
29 changes: 9 additions & 20 deletions gradle-plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,30 @@ configurations {
}

dependencies {
implementation localGroovy()
implementation gradleApi()

testImplementation externalDependency.testng
testImplementation externalDependency.junit

integTestImplementation gradleTestKit()

dataTemplateForTesting project(':data')
pegasusPluginForTesting project(':data')
pegasusPluginForTesting project(':data-avro-generator')
pegasusPluginForTesting project(':generator')
pegasusPluginForTesting project(':restli-tools')
}

gradlePlugin {
testSourceSets sourceSets.integTest
}

// This is done so that the plugin can know which version of restli should be used when creating the pegasus configuration.
processResources {
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: ['version': project.version as String])
}

task resourcesDirWithoutPegasusVersionProperties(type: Sync) {
dependsOn processResources
description 'Creates a backup of the build/gradle-plugins/resources/main/ folder, ' +
'but excluding pegasus-version.properties. ' +
'This allows testing the version of pegasus jars in the current build.'

from(sourceSets.main.output.resourcesDir) {
exclude 'pegasus-version.properties'
}
into "$buildDir/$name"
}

tasks.pluginUnderTestMetadata {
dependsOn tasks.resourcesDirWithoutPegasusVersionProperties

// allows us to test plugin application without the unpublished version set in pegasus-version.properties
// also we add the localLibsForTesting to avoid leaking dependencies in published metadata
pluginClasspath.setFrom(files(sourceSets.main.java.outputDir, sourceSets.main.groovy.outputDir, tasks.resourcesDirWithoutPegasusVersionProperties))
}

integTest {
dependsOn configurations.dataTemplateForTesting, configurations.pegasusPluginForTesting
systemProperty 'integTest.dataTemplateCompileDependencies', "'${configurations.dataTemplateForTesting.join("', '")}'"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.linkedin.pegasus.gradle

final class IntegTestingUtil {
public static final List<String> ALL_SUPPORTED_GRADLE_VERSIONS = ['6.9.4', '7.0.2', '7.5.1']
public static final List<String> OLD_PUBLISHING_SUPPORTED_GRADLE_VERSIONS = ['6.9.4']
public static final List<String> NEW_PUBLISHING_SUPPORTED_GRADLE_VERSIONS = ['6.9.4', '7.0.2', '7.6.3']
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PegasusPluginCacheabilityTest extends Specification {
def runner = GradleRunner.create()
.withGradleVersion(gradleVersion)
.withProjectDir(tempDir.root)
.withEnvironment([PEGASUS_INTEGRATION_TESTING: 'true'])
.withPluginClasspath()
.withArguments('mainDataTemplateJar')

Expand Down Expand Up @@ -96,6 +97,6 @@ class PegasusPluginCacheabilityTest extends Specification {
preparedSchema.exists()

where:
gradleVersion << [ '5.2.1', '5.6.4', '6.9', '7.0.2' ]
gradleVersion << IntegTestingUtil.ALL_SUPPORTED_GRADLE_VERSIONS
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PegasusPluginIntegrationTest extends Specification {

when:
def result = GradleRunner.create()
.withEnvironment([PEGASUS_INTEGRATION_TESTING: 'true'])
.withGradleVersion(gradleVersion)
.withProjectDir(tempDir.root)
.withPluginClasspath()
Expand All @@ -34,7 +35,7 @@ class PegasusPluginIntegrationTest extends Specification {
result.task(':mainDataTemplateJar').outcome == SUCCESS

where:
gradleVersion << [ '5.2.1', '5.6.4', '6.9', '7.0.2', '7.5.1' ]
gradleVersion << IntegTestingUtil.ALL_SUPPORTED_GRADLE_VERSIONS
}

@Unroll
Expand Down Expand Up @@ -84,6 +85,7 @@ class PegasusPluginIntegrationTest extends Specification {

when:
def result = GradleRunner.create()
.withEnvironment([PEGASUS_INTEGRATION_TESTING: 'true'])
.withGradleVersion(gradleVersion)
.withProjectDir(tempDir.root)
.withPluginClasspath()
Expand All @@ -102,12 +104,14 @@ class PegasusPluginIntegrationTest extends Specification {
assertZipContains(dataTemplateArtifact, 'extensions/com/linkedin/LatLongExtensions.pdl')

where:
gradleVersion << [ '5.2.1', '5.6.4', '6.9', '7.0.2', '7.5.1' ]
gradleVersion << IntegTestingUtil.ALL_SUPPORTED_GRADLE_VERSIONS
}

def 'mainCopySchema task will remove stale PDSC'() {
@Unroll
def 'mainCopySchema task will remove stale PDSC with Gradle #gradleVersion'() {
setup:
def runner = GradleRunner.create()
.withEnvironment([PEGASUS_INTEGRATION_TESTING: 'true'])
.withProjectDir(tempDir.root)
.withPluginClasspath()
.withArguments('mainDataTemplateJar')
Expand Down Expand Up @@ -170,6 +174,9 @@ class PegasusPluginIntegrationTest extends Specification {
result.task(':mainCopySchemas').getOutcome() == SUCCESS
!preparedPdscFile1.exists()
preparedPdscFile2.exists()

where:
gradleVersion << IntegTestingUtil.ALL_SUPPORTED_GRADLE_VERSIONS
}

@Unroll
Expand Down Expand Up @@ -244,6 +251,7 @@ class PegasusPluginIntegrationTest extends Specification {

when:
def result = GradleRunner.create()
.withEnvironment([PEGASUS_INTEGRATION_TESTING: 'true'])
.withGradleVersion(gradleVersion)
.withProjectDir(tempDir.root)
.withPluginClasspath()
Expand All @@ -262,7 +270,7 @@ class PegasusPluginIntegrationTest extends Specification {
result.task(':impl:compileJava').outcome == SUCCESS

where:
gradleVersion << [ '5.2.1', '5.6.4', '6.9', '7.0.2', '7.5.1' ]
gradleVersion << IntegTestingUtil.ALL_SUPPORTED_GRADLE_VERSIONS
}

private static boolean assertZipContains(File zip, String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.linkedin.pegasus.gradle.publishing

import com.linkedin.pegasus.gradle.IntegTestingUtil
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.gradle.util.GradleVersion
Expand Down Expand Up @@ -119,6 +120,7 @@ class PegasusPluginIvyPublishIntegrationTest extends Specification {

when:
def grandparentRunner = GradleRunner.create()
.withEnvironment([PEGASUS_INTEGRATION_TESTING: 'true'])
.withProjectDir(grandparentProject.root)
.withGradleVersion(gradleVersion)
.withPluginClasspath()
Expand Down Expand Up @@ -206,6 +208,7 @@ class PegasusPluginIvyPublishIntegrationTest extends Specification {
|}'''.stripMargin()

def parentRunner = GradleRunner.create()
.withEnvironment([PEGASUS_INTEGRATION_TESTING: 'true'])
.withProjectDir(parentProject.root)
.withGradleVersion(gradleVersion)
.withPluginClasspath()
Expand Down Expand Up @@ -304,6 +307,7 @@ class PegasusPluginIvyPublishIntegrationTest extends Specification {
|}'''.stripMargin()

def childRunner = GradleRunner.create()
.withEnvironment([PEGASUS_INTEGRATION_TESTING: 'true'])
.withProjectDir(childProject.root)
.withGradleVersion(gradleVersion)
.withPluginClasspath()
Expand Down Expand Up @@ -334,30 +338,7 @@ class PegasusPluginIvyPublishIntegrationTest extends Specification {
assertZipContains(childProjectDataTemplateArtifact, 'pegasus/com/linkedin/child/Photo.pdl')

where:
gradleVersion << [ '6.1', '6.9', '7.0.2', '7.5.1' ]
}

def 'ivy-publish fails gracefully with Gradle 5.2.1'() {
given:
grandparentProject.newFile('build.gradle') << """
|plugins {
| id 'ivy-publish'
| id 'pegasus'
|}""".stripMargin()

when:
def grandparentRunner = GradleRunner.create()
.withProjectDir(grandparentProject.root)
.withGradleVersion('5.2.1')
.withPluginClasspath()
.withArguments('tasks')
//.forwardOutput()
//.withDebug(true)

def grandparentResult = grandparentRunner.buildAndFail()

then:
grandparentResult.output.contains 'Using the ivy-publish plugin with the pegasus plugin requires Gradle 6.1 or higher'
gradleVersion << IntegTestingUtil.NEW_PUBLISHING_SUPPORTED_GRADLE_VERSIONS
}

private static boolean assertZipContains(File zip, String path) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.linkedin.pegasus.gradle.publishing

import com.linkedin.pegasus.gradle.IntegTestingUtil
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import spock.lang.Specification
import spock.lang.Unroll

import java.util.zip.ZipFile

Expand Down Expand Up @@ -34,7 +36,8 @@ class PegasusPluginLegacyIvyPublishIntegrationTest extends Specification {
localIvyRepo = localRepo.newFolder('local-ivy-repo').toURI().toURL()
}

def 'publishes and consumes dataTemplate configurations'() {
@Unroll
def 'publishes and consumes dataTemplate configurations with Gradle #gradleVersion'() {
given:
def gradlePropertiesFile = grandparentProject.newFile('gradle.properties')
gradlePropertiesFile << '''
Expand Down Expand Up @@ -79,6 +82,8 @@ class PegasusPluginLegacyIvyPublishIntegrationTest extends Specification {

when:
def grandparentRunner = GradleRunner.create()
.withEnvironment([PEGASUS_INTEGRATION_TESTING: 'true'])
.withGradleVersion(gradleVersion)
.withProjectDir(grandparentProject.root)
.withPluginClasspath()
.withArguments('uploadDataTemplate', 'uploadTestDataTemplate', 'uploadAvroSchema', 'uploadTestAvroSchema', 'uploadArchives', '-is')
Expand Down Expand Up @@ -155,6 +160,8 @@ class PegasusPluginLegacyIvyPublishIntegrationTest extends Specification {
|}'''.stripMargin()

def parentRunner = GradleRunner.create()
.withEnvironment([PEGASUS_INTEGRATION_TESTING: 'true'])
.withGradleVersion(gradleVersion)
.withProjectDir(parentProject.root)
.withPluginClasspath()
.withArguments('uploadDataTemplate', 'uploadTestDataTemplate', 'uploadAvroSchema', 'uploadTestAvroSchema', 'uploadArchives', '-is')
Expand Down Expand Up @@ -235,6 +242,8 @@ class PegasusPluginLegacyIvyPublishIntegrationTest extends Specification {
|}'''.stripMargin()

def childRunner = GradleRunner.create()
.withEnvironment([PEGASUS_INTEGRATION_TESTING: 'true'])
.withGradleVersion(gradleVersion)
.withProjectDir(childProject.root)
.withPluginClasspath()
.withArguments('uploadDataTemplate', 'uploadTestDataTemplate', 'uploadAvroSchema', 'uploadTestAvroSchema', 'uploadArchives', '-is')
Expand All @@ -261,6 +270,9 @@ class PegasusPluginLegacyIvyPublishIntegrationTest extends Specification {

assertZipContains(childProjectDataTemplateArtifact, 'com/linkedin/child/Photo.class')
assertZipContains(childProjectDataTemplateArtifact, 'pegasus/com/linkedin/child/Photo.pdl')

where:
gradleVersion << IntegTestingUtil.OLD_PUBLISHING_SUPPORTED_GRADLE_VERSIONS
}

private static boolean assertZipContains(File zip, String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ public class PegasusPlugin implements Plugin<Project>
{
public static boolean debug = false;

private static final GradleVersion MIN_REQUIRED_VERSION = GradleVersion.version("1.0"); // Next: 5.2.1
private static final GradleVersion MIN_SUGGESTED_VERSION = GradleVersion.version("5.2.1"); // Next: 5.3
private static final GradleVersion MIN_REQUIRED_VERSION = GradleVersion.version("6.9.4");
private static final GradleVersion MIN_SUGGESTED_VERSION = GradleVersion.version("6.9.4");

//
// Constants for generating sourceSet names and corresponding directory names
Expand Down Expand Up @@ -807,7 +807,7 @@ public void apply(Project project)

Properties properties = new Properties();
InputStream inputStream = getClass().getResourceAsStream("/pegasus-version.properties");
if (inputStream != null)
if (inputStream != null && !"true".equals(System.getenv("PEGASUS_INTEGRATION_TESTING")))
{
try
{
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading