diff --git a/gradle-plugins/src/integTest/groovy/com/linkedin/pegasus/gradle/publishing/PegasusPluginMavenPublishIntegrationTest.groovy b/gradle-plugins/src/integTest/groovy/com/linkedin/pegasus/gradle/publishing/PegasusPluginMavenPublishIntegrationTest.groovy new file mode 100644 index 0000000000..3614525811 --- /dev/null +++ b/gradle-plugins/src/integTest/groovy/com/linkedin/pegasus/gradle/publishing/PegasusPluginMavenPublishIntegrationTest.groovy @@ -0,0 +1,338 @@ +package com.linkedin.pegasus.gradle.publishing + +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 java.util.zip.ZipFile + +/** + * Regression test to certify Maven publication behavior + * + *

Historically rest.li is tightly coupled to the features of Ivy - specifically, Ivy's ability to publish + * an alternate set of parallel dependencies for the dataTemplate configuration and its associated artifact. + * + *

The Maven POM format is incapable of representing this pattern. Therefore the only alternative to produce and + * consume Maven-style metadata is by augmenting it with Gradle Module Metadata. + * + *

NB: this test runs with Gradle 6.6, which introduces the API + * {@link org.gradle.api.publish.Publication#withoutBuildIdentifier()}. This is not strictly required but aids in test + * reproducibility, as otherwise a random UUID is persisted to the .module file. Note that the build Id will be omitted + * by default starting with Gradle 7.0. See gradle/gradle#13800. + * + *

For more about Gradle Module Metadata, see Understanding Gradle Module Metadata. + * + *

Grandparent -> parent -> child pattern certifies that the child project can transitively resolve references + * to schemas contained in grandparent's data-template jar + */ +class PegasusPluginMavenPublishIntegrationTest extends Specification { + + @Rule + TemporaryFolder grandparentProject + + @Rule + TemporaryFolder parentProject + + @Rule + TemporaryFolder childProject + + @Rule + TemporaryFolder localRepo + + URL localMavenRepo + + def setup() { + localMavenRepo = localRepo.newFolder('local-maven-repo').toURI().toURL() + } + + def 'publishes and consumes dataTemplate configurations with Gradle Module Metadata'() { + given: + def gradlePropertiesFile = grandparentProject.newFile('gradle.properties') + gradlePropertiesFile << ''' + |group=com.linkedin.pegasus-grandparent-demo + |version=1.0.0 + |'''.stripMargin() + + def settingsFile = grandparentProject.newFile('settings.gradle') + settingsFile << "rootProject.name = 'grandparent'" + + grandparentProject.newFile('build.gradle') << """ + |plugins { + | id 'maven-publish' + | id 'pegasus' + |} + | + |repositories { + | mavenCentral() + |} + | + |dependencies { + | dataTemplateCompile files(${System.getProperty('integTest.dataTemplateCompileDependencies')}) + | pegasusPlugin files(${System.getProperty('integTest.pegasusPluginDependencies')}) + |} + | + |//modern maven-publish configuration + |publishing { + | publications { + | maven(MavenPublication) { + | from components.java + | withoutBuildIdentifier() + | } + | } + | repositories { + | maven { url '$localMavenRepo' } + | } + |} + """.stripMargin() + + // Create a simple pdl schema, borrowed from restli-example-api + def schemaFilename = 'LatLong.pdl' + def grandparentPegasusDir = grandparentProject.newFolder('src', 'main', 'pegasus', 'com', 'linkedin', 'grandparent') + def grandparentPdlFile = new File("$grandparentPegasusDir.path$File.separator$schemaFilename") + grandparentPdlFile << '''namespace com.linkedin.grandparent + | + |record LatLong { + | latitude: optional float + | longitude: optional float + |}'''.stripMargin() + + when: + def grandparentRunner = GradleRunner.create() + .withProjectDir(grandparentProject.root) + .withPluginClasspath() + .withGradleVersion('6.6') // the minimum version supporting the Publication#withoutBuildIdentifier() API + .withArguments('publish', '-is') + //.forwardOutput() + //.withDebug(true) + + def grandparentResult = grandparentRunner.build() + + then: + grandparentResult.task(':compileMainGeneratedDataTemplateJava').outcome == TaskOutcome.SUCCESS + grandparentResult.task(':generatePomFileForMavenPublication').outcome == TaskOutcome.SUCCESS + + def grandparentProjectPomFile = new File(localMavenRepo.path, 'com/linkedin/pegasus-grandparent-demo/grandparent/1.0.0/grandparent-1.0.0.pom') + grandparentProjectPomFile.exists() + def grandparentProjectPomFileContents = grandparentProjectPomFile.text + def expectedGrandparentContents = new File(Thread.currentThread().contextClassLoader.getResource('maven/expectedGrandparentPomFile.pom').toURI()).text + grandparentProjectPomFileContents == expectedGrandparentContents + + def grandparentProjectModuleFile = new File(localMavenRepo.path, 'com/linkedin/pegasus-grandparent-demo/grandparent/1.0.0/grandparent-1.0.0.module') + grandparentProjectModuleFile.exists() + def grandparentProjectModuleFileContents = grandparentProjectModuleFile.text + def expectedGrandparentModuleContents = new File(Thread.currentThread().contextClassLoader.getResource('maven/expectedGrandparentModuleFile.module').toURI()).text + grandparentProjectModuleFileContents == expectedGrandparentModuleContents + + def grandparentProjectPrimaryArtifact = new File(localMavenRepo.path, 'com/linkedin/pegasus-grandparent-demo/grandparent/1.0.0/grandparent-1.0.0.jar') + grandparentProjectPrimaryArtifact.exists() + //NB note naming scheme of data-template jar changes when classifier, not appendix, is used + def grandparentProjectDataTemplateArtifact = new File(localMavenRepo.path, 'com/linkedin/pegasus-grandparent-demo/grandparent/1.0.0/grandparent-1.0.0-data-template.jar') + grandparentProjectDataTemplateArtifact.exists() + + assertZipContains(grandparentProjectDataTemplateArtifact, 'com/linkedin/grandparent/LatLong.class') + assertZipContains(grandparentProjectDataTemplateArtifact, 'pegasus/com/linkedin/grandparent/LatLong.pdl') + + when: 'a parent project consumes the grandparent project data-template jar' + + gradlePropertiesFile = parentProject.newFile('gradle.properties') + gradlePropertiesFile << ''' + |group=com.linkedin.pegasus-parent-demo + |version=1.0.0 + |'''.stripMargin() + + settingsFile = parentProject.newFile('settings.gradle') + settingsFile << "rootProject.name = 'parent'" + + parentProject.newFile('build.gradle') << """ + |plugins { + | id 'maven-publish' + | id 'pegasus' + |} + | + |repositories { + | maven { url '$localMavenRepo' } + | mavenCentral() + |} + | + |dependencies { + | dataTemplateCompile files(${System.getProperty('integTest.dataTemplateCompileDependencies')}) + | pegasusPlugin files(${System.getProperty('integTest.pegasusPluginDependencies')}) + | + | //dataModel group: 'com.linkedin.pegasus-grandparent-demo', name: 'grandparent', version: '1.0.0', configuration: 'dataTemplate' + | dataModel ('com.linkedin.pegasus-grandparent-demo:grandparent:1.0.0') { + | capabilities { + | requireCapability('com.linkedin.pegasus-grandparent-demo:grandparent-data-template:1.0.0') // TODO Gradle 6.0 requires an explicit version, 6.? does not + | } + | } + |} + | + |//modern maven-publish configuration + |publishing { + | publications { + | maven(MavenPublication) { + | from components.java + | withoutBuildIdentifier() + | } + | } + | repositories { + | maven { url '$localMavenRepo' } + | } + |} + """.stripMargin() + + // Create a simple pdl schema which references a grandparent type + schemaFilename = 'EXIF.pdl' + def parentPegasusDir = parentProject.newFolder('src', 'main', 'pegasus', 'com', 'linkedin', 'parent') + def parentPdlFile = new File("$parentPegasusDir.path$File.separator$schemaFilename") + parentPdlFile << '''namespace com.linkedin.parent + | + |import com.linkedin.grandparent.LatLong + | + |record EXIF { + | isFlash: optional boolean = true + | location: optional LatLong + |}'''.stripMargin() + + def parentRunner = GradleRunner.create() + .withProjectDir(parentProject.root) + .withPluginClasspath() + .withGradleVersion('6.6') // the minimum version supporting the Publication#withoutBuildIdentifier() API + .withArguments('publish', '-is') + //.forwardOutput() + //.withDebug(true) + + def parentResult = parentRunner.build() + + then: + parentResult.task(':compileMainGeneratedDataTemplateJava').outcome == TaskOutcome.SUCCESS + parentResult.task(':generatePomFileForMavenPublication').outcome == TaskOutcome.SUCCESS + + def parentProjectPomFile = new File(localMavenRepo.path, 'com/linkedin/pegasus-parent-demo/parent/1.0.0/parent-1.0.0.pom') + parentProjectPomFile.exists() + def parentProjectPomFileContents = parentProjectPomFile.text + def expectedParentContents = new File(Thread.currentThread().contextClassLoader.getResource('maven/expectedParentPomFile.pom').toURI()).text + parentProjectPomFileContents == expectedParentContents + + def parentProjectModuleFile = new File(localMavenRepo.path, 'com/linkedin/pegasus-parent-demo/parent/1.0.0/parent-1.0.0.module') + parentProjectModuleFile.exists() + def parentProjectModuleFileContents = parentProjectModuleFile.text + def expectedParentModuleContents = new File(Thread.currentThread().contextClassLoader.getResource('maven/expectedParentModuleFile.module').toURI()).text + parentProjectModuleFileContents == expectedParentModuleContents + + def parentProjectPrimaryArtifact = new File(localMavenRepo.path, 'com/linkedin/pegasus-parent-demo/parent/1.0.0/parent-1.0.0.jar') + parentProjectPrimaryArtifact.exists() + //NB note naming scheme of data-template jar changes when classifier, not appendix, is used + def parentProjectDataTemplateArtifact = new File(localMavenRepo.path, 'com/linkedin/pegasus-parent-demo/parent/1.0.0/parent-1.0.0-data-template.jar') + parentProjectDataTemplateArtifact.exists() + + assertZipContains(parentProjectDataTemplateArtifact, 'com/linkedin/parent/EXIF.class') + assertZipContains(parentProjectDataTemplateArtifact, 'pegasus/com/linkedin/parent/EXIF.pdl') + + when: 'a child project transitively consumes the grandparent project data-template jar' + + gradlePropertiesFile = childProject.newFile('gradle.properties') + gradlePropertiesFile << ''' + |group=com.linkedin.pegasus-child-demo + |version=1.0.0 + |'''.stripMargin() + + settingsFile = childProject.newFile('settings.gradle') + settingsFile << "rootProject.name = 'child'" + + childProject.newFile('build.gradle') << """ + |plugins { + | id 'maven-publish' + | id 'pegasus' + |} + | + |repositories { + | maven { url '$localMavenRepo' } + | mavenCentral() + |} + | + |dependencies { + | dataTemplateCompile files(${System.getProperty('integTest.dataTemplateCompileDependencies')}) + | pegasusPlugin files(${System.getProperty('integTest.pegasusPluginDependencies')}) + | + | //dataModel group: 'com.linkedin.pegasus-parent-demo', name: 'parent', version: '1.0.0', configuration: 'dataTemplate' + | dataModel ('com.linkedin.pegasus-parent-demo:parent:1.0.0') { + | capabilities { + | requireCapability('com.linkedin.pegasus-parent-demo:parent-data-template:1.0.0') // TODO Gradle 6.0 requires an explicit version, 6.? does not + | } + | } + |} + | + |//modern maven-publish configuration + |publishing { + | publications { + | maven(MavenPublication) { + | from components.java + | withoutBuildIdentifier() + | } + | } + | repositories { + | maven { url '$localMavenRepo' } + | } + |} + """.stripMargin() + + // Create a simple pdl schema which references parent and grandparent types + schemaFilename = 'Photo.pdl' + def childPegasusDir = childProject.newFolder('src', 'main', 'pegasus', 'com', 'linkedin', 'child') + def childPdlFile = new File("$childPegasusDir.path$File.separator$schemaFilename") + childPdlFile << '''namespace com.linkedin.child + | + |import com.linkedin.grandparent.LatLong + |import com.linkedin.parent.EXIF + | + |record Photo { + | id: long + | urn: string + | title: string + | exif: EXIF + | backupLocation: optional LatLong + |}'''.stripMargin() + + def childRunner = GradleRunner.create() + .withProjectDir(childProject.root) + .withPluginClasspath() + .withGradleVersion('6.6') // the minimum version supporting the Publication#withoutBuildIdentifier() API + .withArguments('publish', '-is') + //.forwardOutput() + //.withDebug(true) + + def childResult = childRunner.build() + + then: + childResult.task(':compileMainGeneratedDataTemplateJava').outcome == TaskOutcome.SUCCESS + childResult.task(':generatePomFileForMavenPublication').outcome == TaskOutcome.SUCCESS + + def childProjectPomFile = new File(localMavenRepo.path, 'com/linkedin/pegasus-child-demo/child/1.0.0/child-1.0.0.pom') + childProjectPomFile.exists() + def childProjectPomFileContents = childProjectPomFile.text + def expectedChildContents = new File(Thread.currentThread().contextClassLoader.getResource('maven/expectedChildPomFile.pom').toURI()).text + childProjectPomFileContents == expectedChildContents + + def childProjectModuleFile = new File(localMavenRepo.path, 'com/linkedin/pegasus-child-demo/child/1.0.0/child-1.0.0.module') + childProjectModuleFile.exists() + def childProjectModuleFileContents = childProjectModuleFile.text + def expectedChildModuleContents = new File(Thread.currentThread().contextClassLoader.getResource('maven/expectedChildModuleFile.module').toURI()).text + childProjectModuleFileContents == expectedChildModuleContents + + def childProjectPrimaryArtifact = new File(localMavenRepo.path, 'com/linkedin/pegasus-child-demo/child/1.0.0/child-1.0.0.jar') + childProjectPrimaryArtifact.exists() + //NB note naming scheme of data-template jar changes when classifier, not appendix, is used + def childProjectDataTemplateArtifact = new File(localMavenRepo.path, 'com/linkedin/pegasus-child-demo/child/1.0.0/child-1.0.0-data-template.jar') + childProjectDataTemplateArtifact.exists() + + assertZipContains(childProjectDataTemplateArtifact, 'com/linkedin/child/Photo.class') + assertZipContains(childProjectDataTemplateArtifact, 'pegasus/com/linkedin/child/Photo.pdl') + } + + private static boolean assertZipContains(File zip, String path) { + return new ZipFile(zip).getEntry(path) + } + +} \ No newline at end of file diff --git a/gradle-plugins/src/integTest/resources/maven/expectedChildModuleFile.module b/gradle-plugins/src/integTest/resources/maven/expectedChildModuleFile.module new file mode 100644 index 0000000000..5670a36e30 --- /dev/null +++ b/gradle-plugins/src/integTest/resources/maven/expectedChildModuleFile.module @@ -0,0 +1,418 @@ +{ + "formatVersion": "1.1", + "component": { + "group": "com.linkedin.pegasus-child-demo", + "module": "child", + "version": "1.0.0", + "attributes": { + "org.gradle.status": "release" + } + }, + "createdBy": { + "gradle": { + "version": "6.6" + } + }, + "variants": [ + { + "name": "apiElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-api" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "module": "parent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "child-1.0.0.jar", + "url": "child-1.0.0.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ] + }, + { + "name": "runtimeElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-runtime" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "module": "parent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "child-1.0.0.jar", + "url": "child-1.0.0.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateJavadocElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "javadoc", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "child-1.0.0-data-template-javadoc.jar", + "url": "child-1.0.0-data-template-javadoc.jar", + "size": 24626, + "sha512": "f200e2552cd8b12f8972201ec35a00d6d82589db33d9cc1b375a06ce2bcd98f998e1cabaf0d143e96ef5915db6514be72305dfd54114c982530e2f5daa18eadb", + "sha256": "689bce1ff8ee2866341b1ef42ed41427a7b0a029acec021434b1f6739d1e6f60", + "sha1": "2d455cb57a94608d4ecb1d02f45b8b64af188657", + "md5": "4edf48ee6294d0153fd5b97b4011c434" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-child-demo", + "name": "child-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateSourcesElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "sources", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "child-1.0.0-data-template-sources.jar", + "url": "child-1.0.0-data-template-sources.jar", + "size": 6315, + "sha512": "d519c3102519d6cba849ec0641cf36c5dcefae1d825ebf9602618f6432ce617455bf5f97d557c06a34cea8d1f691052c162b3cc7800223e3739ac0c0d6c47520", + "sha256": "532d5a6e920f80ff500dc43ee62803d00da169a558c1f5654bdadb24692a670d", + "sha1": "137105f141875fa63c0265fc4b90853602590ac9", + "md5": "ecee9fe068fe21efefe86de7d5e07bf3" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-child-demo", + "name": "child-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateApiElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-api" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "module": "parent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "child-1.0.0-data-template.jar", + "url": "child-1.0.0-data-template.jar", + "size": 9750, + "sha512": "2e0f0b7b0ef2479416c8451676eac5a02697b6523f53b30f3e109cc46e831afedb6c186541490a9283a421a5c0213496d68bae7fb113da9c0c779f40eb849011", + "sha256": "fa0a997dc6db048f9e8d9a7d96b6df9a2d9ac00dfdc4e4a497666bd4962f360a", + "sha1": "7402e1931977f3d309a93bb30db0f149de7f8f12", + "md5": "2ef44a5e7cca13e87d7a58a6d134aee4" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-child-demo", + "name": "child-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateRuntimeElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-runtime" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "module": "parent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "child-1.0.0-data-template.jar", + "url": "child-1.0.0-data-template.jar", + "size": 9750, + "sha512": "2e0f0b7b0ef2479416c8451676eac5a02697b6523f53b30f3e109cc46e831afedb6c186541490a9283a421a5c0213496d68bae7fb113da9c0c779f40eb849011", + "sha256": "fa0a997dc6db048f9e8d9a7d96b6df9a2d9ac00dfdc4e4a497666bd4962f360a", + "sha1": "7402e1931977f3d309a93bb30db0f149de7f8f12", + "md5": "2ef44a5e7cca13e87d7a58a6d134aee4" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-child-demo", + "name": "child-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateJavadocElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "javadoc", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "child-1.0.0-test-data-template-javadoc.jar", + "url": "child-1.0.0-test-data-template-javadoc.jar", + "size": 24626, + "sha512": "f200e2552cd8b12f8972201ec35a00d6d82589db33d9cc1b375a06ce2bcd98f998e1cabaf0d143e96ef5915db6514be72305dfd54114c982530e2f5daa18eadb", + "sha256": "689bce1ff8ee2866341b1ef42ed41427a7b0a029acec021434b1f6739d1e6f60", + "sha1": "2d455cb57a94608d4ecb1d02f45b8b64af188657", + "md5": "4edf48ee6294d0153fd5b97b4011c434" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-child-demo", + "name": "child-test-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateSourcesElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "sources", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "child-1.0.0-test-data-template-sources.jar", + "url": "child-1.0.0-test-data-template-sources.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-child-demo", + "name": "child-test-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateApiElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-api" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "module": "parent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "child-1.0.0-test-data-template.jar", + "url": "child-1.0.0-test-data-template.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-child-demo", + "name": "child-test-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateRuntimeElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-runtime" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "module": "parent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "child-1.0.0-test-data-template.jar", + "url": "child-1.0.0-test-data-template.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-child-demo", + "name": "child-test-data-template", + "version": "1.0.0" + } + ] + } + ] +} diff --git a/gradle-plugins/src/integTest/resources/maven/expectedChildPomFile.pom b/gradle-plugins/src/integTest/resources/maven/expectedChildPomFile.pom new file mode 100644 index 0000000000..c84587aa3c --- /dev/null +++ b/gradle-plugins/src/integTest/resources/maven/expectedChildPomFile.pom @@ -0,0 +1,27 @@ + + + + + + + + 4.0.0 + com.linkedin.pegasus-child-demo + child + 1.0.0 + + + com.linkedin.pegasus-parent-demo + parent + 1.0.0 + compile + + + com.google.code.findbugs + jsr305 + 3.0.2 + compile + + + diff --git a/gradle-plugins/src/integTest/resources/maven/expectedGrandparentModuleFile.module b/gradle-plugins/src/integTest/resources/maven/expectedGrandparentModuleFile.module new file mode 100644 index 0000000000..d8f85c35ce --- /dev/null +++ b/gradle-plugins/src/integTest/resources/maven/expectedGrandparentModuleFile.module @@ -0,0 +1,334 @@ +{ + "formatVersion": "1.1", + "component": { + "group": "com.linkedin.pegasus-grandparent-demo", + "module": "grandparent", + "version": "1.0.0", + "attributes": { + "org.gradle.status": "release" + } + }, + "createdBy": { + "gradle": { + "version": "6.6" + } + }, + "variants": [ + { + "name": "apiElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-api" + }, + "dependencies": [ + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "grandparent-1.0.0.jar", + "url": "grandparent-1.0.0.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ] + }, + { + "name": "runtimeElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-runtime" + }, + "dependencies": [ + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "grandparent-1.0.0.jar", + "url": "grandparent-1.0.0.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateJavadocElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "javadoc", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "grandparent-1.0.0-data-template-javadoc.jar", + "url": "grandparent-1.0.0-data-template-javadoc.jar", + "size": 22998, + "sha512": "557cfbe9059a07608f39e77599a5cab125b693ed20b60b89a78c6f7b8ca080c3fc80afe27b58d6be14e5582ec4b86e6bf27e328a47c1061d3ddd4a6d62aa9b3e", + "sha256": "f15351f32e58ebe3c308816888e30704250d635a8059211e48f984e92ca02aad", + "sha1": "cc7e06fcb87fd69c905b6da5f3e9401bcb100f76", + "md5": "3d403d69566567b69a526eca114d3070" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateSourcesElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "sources", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "grandparent-1.0.0-data-template-sources.jar", + "url": "grandparent-1.0.0-data-template-sources.jar", + "size": 4249, + "sha512": "35991d298e0a602b654427ebc15df262173743ca4178a5e385025d6b9d5bd4b2567d8aa5224a91232420c4063983ddf2e1c0b2a17a36dd75ba35c7688911fd39", + "sha256": "09a4a2a7696a27f5834f253d1c07ca644c803f0ef2aaecbb7b5518c2154ae4df", + "sha1": "2a76c3e15aaaad134d55633dfc4f10555fe0b1fe", + "md5": "05d1200cab0172e44b4e490b778160bf" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateApiElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-api" + }, + "dependencies": [ + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "grandparent-1.0.0-data-template.jar", + "url": "grandparent-1.0.0-data-template.jar", + "size": 7233, + "sha512": "d0819ff0aad3f2b5a492f9a5ace3ab9250b6c96690be725ab51dcbca0f1101ce8f194315845a8bd184c3ed90bc5869cf9a1dc66cef02e6d51fb02a7019e98a83", + "sha256": "6745b3a01d297d36252c24ff71c292a0a7d0d667ef08cfadcf887700577d647e", + "sha1": "6be3668aa0aaeb3be66bc093f166e8534f1a0dfe", + "md5": "2a40b4f1cdb46597708ed8026c58a884" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateRuntimeElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-runtime" + }, + "dependencies": [ + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "grandparent-1.0.0-data-template.jar", + "url": "grandparent-1.0.0-data-template.jar", + "size": 7233, + "sha512": "d0819ff0aad3f2b5a492f9a5ace3ab9250b6c96690be725ab51dcbca0f1101ce8f194315845a8bd184c3ed90bc5869cf9a1dc66cef02e6d51fb02a7019e98a83", + "sha256": "6745b3a01d297d36252c24ff71c292a0a7d0d667ef08cfadcf887700577d647e", + "sha1": "6be3668aa0aaeb3be66bc093f166e8534f1a0dfe", + "md5": "2a40b4f1cdb46597708ed8026c58a884" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateJavadocElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "javadoc", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "grandparent-1.0.0-test-data-template-javadoc.jar", + "url": "grandparent-1.0.0-test-data-template-javadoc.jar", + "size": 22998, + "sha512": "557cfbe9059a07608f39e77599a5cab125b693ed20b60b89a78c6f7b8ca080c3fc80afe27b58d6be14e5582ec4b86e6bf27e328a47c1061d3ddd4a6d62aa9b3e", + "sha256": "f15351f32e58ebe3c308816888e30704250d635a8059211e48f984e92ca02aad", + "sha1": "cc7e06fcb87fd69c905b6da5f3e9401bcb100f76", + "md5": "3d403d69566567b69a526eca114d3070" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-test-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateSourcesElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "sources", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "grandparent-1.0.0-test-data-template-sources.jar", + "url": "grandparent-1.0.0-test-data-template-sources.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-test-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateApiElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-api" + }, + "dependencies": [ + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "grandparent-1.0.0-test-data-template.jar", + "url": "grandparent-1.0.0-test-data-template.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-test-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateRuntimeElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-runtime" + }, + "dependencies": [ + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "grandparent-1.0.0-test-data-template.jar", + "url": "grandparent-1.0.0-test-data-template.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-test-data-template", + "version": "1.0.0" + } + ] + } + ] +} diff --git a/gradle-plugins/src/integTest/resources/maven/expectedGrandparentPomFile.pom b/gradle-plugins/src/integTest/resources/maven/expectedGrandparentPomFile.pom new file mode 100644 index 0000000000..9251155d97 --- /dev/null +++ b/gradle-plugins/src/integTest/resources/maven/expectedGrandparentPomFile.pom @@ -0,0 +1,21 @@ + + + + + + + + 4.0.0 + com.linkedin.pegasus-grandparent-demo + grandparent + 1.0.0 + + + com.google.code.findbugs + jsr305 + 3.0.2 + compile + + + diff --git a/gradle-plugins/src/integTest/resources/maven/expectedParentModuleFile.module b/gradle-plugins/src/integTest/resources/maven/expectedParentModuleFile.module new file mode 100644 index 0000000000..d63391568d --- /dev/null +++ b/gradle-plugins/src/integTest/resources/maven/expectedParentModuleFile.module @@ -0,0 +1,418 @@ +{ + "formatVersion": "1.1", + "component": { + "group": "com.linkedin.pegasus-parent-demo", + "module": "parent", + "version": "1.0.0", + "attributes": { + "org.gradle.status": "release" + } + }, + "createdBy": { + "gradle": { + "version": "6.6" + } + }, + "variants": [ + { + "name": "apiElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-api" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "module": "grandparent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "parent-1.0.0.jar", + "url": "parent-1.0.0.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ] + }, + { + "name": "runtimeElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-runtime" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "module": "grandparent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "parent-1.0.0.jar", + "url": "parent-1.0.0.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateJavadocElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "javadoc", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "parent-1.0.0-data-template-javadoc.jar", + "url": "parent-1.0.0-data-template-javadoc.jar", + "size": 22885, + "sha512": "39794a36c987441429cfaa38147af75d7ee783ff73dae93ef02d167e4655fc1774de85e452d8fb59d7c0715c79c00ad03891f5785852bb7d3d9ede171311ae61", + "sha256": "3ab356c7566505d71cdf20c5d00972bdb22f983ceff817a933b5499993bdd3ea", + "sha1": "3803b5417b1b2b64ea8eae48bab03d6a0c39d258", + "md5": "c779c846d42a01a4af5db6f6b12ecd46" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateSourcesElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "sources", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "parent-1.0.0-data-template-sources.jar", + "url": "parent-1.0.0-data-template-sources.jar", + "size": 4623, + "sha512": "17957c581765c377d5fa4fd63782f9bea71749171d50808b608c457dd7982278f70fff4c8c0b1661513de1430f87a0793b7e546107b97643a4f4417bb2e41000", + "sha256": "795d36e8969dab26af28d570e844f523357c28335f9a00d1406bc01639c3de34", + "sha1": "f48c1d6ad8d2518938eaee68650d7d255d89f55e", + "md5": "d3e06c6218c28e6fc96e26d62e5b84b4" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateApiElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-api" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "module": "grandparent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "parent-1.0.0-data-template.jar", + "url": "parent-1.0.0-data-template.jar", + "size": 7918, + "sha512": "8b3dfad760eda9b6398558f0733ca2ff8b5b71748b88cb0ff022c0a490ce9f2612cde94cbd54ab79e30cdd0d14a867959ee34680be4d558c9266c589367fefe9", + "sha256": "2f6a11e81ff7feaa3c3f8884f79f73419e3b53d0d2c88e7b87f90bc2c59a11a2", + "sha1": "47e1d85f4cfb2d5757faca28543feddb45092202", + "md5": "a7b75e8ed88771ba1906d408d90e0632" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "mainGeneratedDataTemplateRuntimeElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-runtime" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "module": "grandparent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "parent-1.0.0-data-template.jar", + "url": "parent-1.0.0-data-template.jar", + "size": 7918, + "sha512": "8b3dfad760eda9b6398558f0733ca2ff8b5b71748b88cb0ff022c0a490ce9f2612cde94cbd54ab79e30cdd0d14a867959ee34680be4d558c9266c589367fefe9", + "sha256": "2f6a11e81ff7feaa3c3f8884f79f73419e3b53d0d2c88e7b87f90bc2c59a11a2", + "sha1": "47e1d85f4cfb2d5757faca28543feddb45092202", + "md5": "a7b75e8ed88771ba1906d408d90e0632" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateJavadocElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "javadoc", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "parent-1.0.0-test-data-template-javadoc.jar", + "url": "parent-1.0.0-test-data-template-javadoc.jar", + "size": 22885, + "sha512": "39794a36c987441429cfaa38147af75d7ee783ff73dae93ef02d167e4655fc1774de85e452d8fb59d7c0715c79c00ad03891f5785852bb7d3d9ede171311ae61", + "sha256": "3ab356c7566505d71cdf20c5d00972bdb22f983ceff817a933b5499993bdd3ea", + "sha1": "3803b5417b1b2b64ea8eae48bab03d6a0c39d258", + "md5": "c779c846d42a01a4af5db6f6b12ecd46" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-test-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateSourcesElements", + "attributes": { + "org.gradle.category": "documentation", + "org.gradle.dependency.bundling": "external", + "org.gradle.docstype": "sources", + "org.gradle.usage": "java-runtime" + }, + "files": [ + { + "name": "parent-1.0.0-test-data-template-sources.jar", + "url": "parent-1.0.0-test-data-template-sources.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-test-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateApiElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-api" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "module": "grandparent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "parent-1.0.0-test-data-template.jar", + "url": "parent-1.0.0-test-data-template.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-test-data-template", + "version": "1.0.0" + } + ] + }, + { + "name": "testGeneratedDataTemplateRuntimeElements", + "attributes": { + "org.gradle.category": "library", + "org.gradle.dependency.bundling": "external", + "org.gradle.jvm.version": 8, + "org.gradle.libraryelements": "jar", + "org.gradle.usage": "java-runtime" + }, + "dependencies": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "module": "grandparent", + "version": { + "requires": "1.0.0" + }, + "requestedCapabilities": [ + { + "group": "com.linkedin.pegasus-grandparent-demo", + "name": "grandparent-data-template", + "version": "1.0.0" + } + ] + }, + { + "group": "com.google.code.findbugs", + "module": "jsr305", + "version": { + "requires": "3.0.2" + } + } + ], + "files": [ + { + "name": "parent-1.0.0-test-data-template.jar", + "url": "parent-1.0.0-test-data-template.jar", + "size": 261, + "sha512": "747d2f00a7f5f379582e33e452f30f3a25732a510971d9ed5161355bf7ef0fc507fef30883960dbfc780d36b6e8215fba01086b4ee053358805686e2f2c1aa85", + "sha256": "69e1a62e5752ca3f43fb1607f161379bbe88b64af89c1a543c126160adf7cc53", + "sha1": "5b8f86fea035328fc9e8c660773037a3401ce25f", + "md5": "e7e9f45eb9d74540092920528bb0abf0" + } + ], + "capabilities": [ + { + "group": "com.linkedin.pegasus-parent-demo", + "name": "parent-test-data-template", + "version": "1.0.0" + } + ] + } + ] +} diff --git a/gradle-plugins/src/integTest/resources/maven/expectedParentPomFile.pom b/gradle-plugins/src/integTest/resources/maven/expectedParentPomFile.pom new file mode 100644 index 0000000000..c6604d4f83 --- /dev/null +++ b/gradle-plugins/src/integTest/resources/maven/expectedParentPomFile.pom @@ -0,0 +1,27 @@ + + + + + + + + 4.0.0 + com.linkedin.pegasus-parent-demo + parent + 1.0.0 + + + com.linkedin.pegasus-grandparent-demo + grandparent + 1.0.0 + compile + + + com.google.code.findbugs + jsr305 + 3.0.2 + compile + + + diff --git a/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java b/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java index f2187bcefb..67d4b5e709 100644 --- a/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java +++ b/gradle-plugins/src/main/java/com/linkedin/pegasus/gradle/PegasusPlugin.java @@ -65,6 +65,7 @@ import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.publish.ivy.plugins.IvyPublishPlugin; +import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; import org.gradle.api.tasks.Copy; import org.gradle.api.tasks.Delete; import org.gradle.api.tasks.SourceSet; @@ -1870,6 +1871,39 @@ protected GenerateDataTemplateTask configureDataTemplateGeneration(Project proje project.getConfigurations().getByName("dataTemplateCompile")); }); + project.getPlugins().withType(MavenPublishPlugin.class, ivyPublish -> { + if (!isAtLeastGradle61()) { + throw new GradleException("Using the maven-publish plugin with the pegasus plugin requires Gradle 6.1 or higher " + + "at build time. Please upgrade."); + } + + JavaPluginExtension java = project.getExtensions().getByType(JavaPluginExtension.class); + // create new capabilities per source set; automatically creates api and implementation configurations + String featureName = mapSourceSetToFeatureName(targetSourceSet); + java.registerFeature(featureName, featureSpec -> { + featureSpec.usingSourceSet(targetSourceSet); + featureSpec.withJavadocJar(); + featureSpec.withSourcesJar(); + }); + + // include pegasus files in the output of this SourceSet + TaskProvider processResources = project.getTasks().named(targetSourceSet.getProcessResourcesTaskName(), ProcessResources.class); + processResources.configure(it -> { + it.from(prepareSchemasForPublishTask, copy -> copy.into("pegasus")); + it.from(prepareLegacySchemasForPublishTask, copy -> copy.into(TRANSLATED_SCHEMAS_DIR)); + Sync copyExtensionSchemasTask = project.getTasks().withType(Sync.class).findByName(targetSourceSet.getName() + "CopyExtensionSchemas"); + if (copyExtensionSchemasTask != null) { + it.from(copyExtensionSchemasTask, copy -> copy.into("extensions")); + } + }); + + // expose transitive dependencies to consumers via api configuration + Configuration mainGeneratedDataTemplateApi = project.getConfigurations().getByName(targetSourceSet.getApiConfigurationName()); + mainGeneratedDataTemplateApi.extendsFrom( + getDataModelConfig(project, targetSourceSet), + project.getConfigurations().getByName("dataTemplateCompile")); + }); + if (debug) { System.out.println("configureDataTemplateGeneration sourceSet " + sourceSet.getName());