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

Support subprojects in export dependencies to TeamCity #53

Merged
merged 19 commits into from
Jun 27, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,37 @@ class ReleaseManagementPluginTest {
Arguments.of("transitive-dependencies", "teamcity-gradle-template-command.properties", emptyList<String>()),

// indirect "DBSM-Cloud-API:0.1.55" must not be included!
Arguments.of("transitive-dependencies", "teamcity-gradle-template-command-include-all-deps.properties", listOf("DBSM-Cloud-Common:0.1.54"))
Arguments.of("transitive-dependencies", "teamcity-gradle-template-command-include-all-deps.properties", listOf("DBSM-Cloud-Common:0.1.54")),

Arguments.of("multi-module", "template-all-deps-subproj_api.properties", listOf("DBSM-Cloud-API:0.1.71")),
Arguments.of(
"multi-module",
"template-all-deps-subproj_core.properties",
listOf("DBSM-Cloud-Common:0.1.67", "components-registry-service:0.0.645")
),
Arguments.of(
"multi-module",
"template-all-deps-root_prj.properties",
listOf("DBSM-Cloud-API:0.1.71", "DBSM-Cloud-Common:0.1.67", "components-registry-service:0.0.645")
)
)

@JvmStatic
fun subprojectDeclaredData(): Stream<Arguments> = Stream.of(
Arguments.of(
"sub-projects",
"template-deps-subproj2.properties",
listOf("ComponentOne:3.2.1", "ComponentThree:7.8.9")
)
)

@JvmStatic
fun versionSpecificationData(): Stream<Arguments> = Stream.of(
Arguments.of("1.0-SNAPSHOT", listOf("--no-daemon", "assemble")),
Arguments.of("0.1", listOf("--no-daemon", "assemble", "-PbuildVersion=0.1"))
)


}

@ParameterizedTest
Expand All @@ -70,11 +93,11 @@ class ReleaseManagementPluginTest {
gradleCommandAndLineProperties.load(it)
}
val gradleCommandAdnArguments = gradleCommandAndLineProperties.getProperty("command-and-arguments")
.replace("__RELEASE_MANAGEMENT_VERSION__", releaseManagementVersion)
.replace("__BUILD_VERSION__", buildVersion)
.replace("__COMPONENT_NAME__", componentName)
.replace("__PACKAGE_NAME__", System.getProperty("packageName"))
.split(Regex("\\s+"))
.replace("__RELEASE_MANAGEMENT_VERSION__", releaseManagementVersion)
.replace("__BUILD_VERSION__", buildVersion)
.replace("__COMPONENT_NAME__", componentName)
.replace("__PACKAGE_NAME__", System.getProperty("packageName"))
.split(Regex("\\s+"))
val processBuilder: LocalProcessBuilder = ProcessBuilders.newProcessBuilder(LocalProcessSpec.LOCAL_COMMAND)
val processInstance = processBuilder
.envVariables(mapOf("JAVA_HOME" to System.getProperty("java.home")))
Expand Down Expand Up @@ -105,7 +128,17 @@ class ReleaseManagementPluginTest {

@ParameterizedTest
@MethodSource("dependedComponentsRegistrationData")
fun testDependedComponentsRegistration(
fun testDependedComponentsRegistration(project: String, commandPropFile: String, expected: Collection<String>) {
teamcityRependenciesRegistrationTest(project, commandPropFile, expected)
}

@ParameterizedTest
@MethodSource("subprojectDeclaredData")
fun testSubprojectDeclared(project: String, commandPropFile: String, expected: Collection<String>) {
teamcityRependenciesRegistrationTest(project, commandPropFile, expected)
}

fun teamcityRependenciesRegistrationTest(
project: String,
gradleCommandPropFile: String,
expectedComponents: Collection<String>
Expand Down Expand Up @@ -152,6 +185,9 @@ class ReleaseManagementPluginTest {
assertThat(dependencies).containsExactlyInAnyOrderElementsOf(expectedComponents)
}




@Test
fun testDeclareDependencies() {
val releaseManagementVersion: String = System.getenv()["__RELEASE_MANAGEMENT_VERSION__"] ?: throw IllegalStateException("The __RELEASE_MANAGEMENT_VERSION__ environment variable is not set")
Expand Down
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-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
31 changes: 14 additions & 17 deletions ft/src/test/resources/publish/legacy-staging-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
/*
*/

version = hasProperty("SM_DSL_VERSION") ? SM_DSL_VERSION : hasProperty("buildVersion") ? buildVersion : "1.0-SNAPSHOT"

description "Deployer DSL $version"

buildscript {
/* Escrow build support */
ext.m2localPath = project.hasProperty('m2_local') ? new File(m2_local).toURI().toURL().toString().replaceAll(/^file:\//, 'file:///') : null
ext.escrowBuild = m2localPath != null
repositories {
if (escrowBuild) {
println("** Escrow mode detected - using local maven repository: $m2localPath")
maven {
url m2localPath
}
} else {
println("** Escrow mode not detected - using standard maven local repository")
mavenLocal()
}
}
dependencies {
if (project.hasProperty("gradleStagingPluginVersion")) {
classpath group: 'org.octopusden.octopus-gradle-plugin', name: 'gradle-staging-plugin', version: gradleStagingPluginVersion
}
}
}

plugins {
id 'org.octopusden.octopus-release-management'
}

version = hasProperty("SM_DSL_VERSION") ? SM_DSL_VERSION : hasProperty("buildVersion") ? buildVersion : "1.0-SNAPSHOT"

description "Deployer DSL $version"

allprojects {
group = 'org.octopusden.octopus-release-management.ft'
version = rootProject.version
Expand Down Expand Up @@ -65,13 +64,11 @@ configure(subprojects.findAll { !(it.name in subprojectsWithoutSources) }) {
//
apply plugin: 'maven-publish'

if (project.hasProperty("gradleStagingPluginVersion")) {
apply plugin: 'gradle-staging-plugin'
nexusStaging {
profileId = projectParameter('stagingProfileId')
repositoryId = projectParameter('stagingRepositoryId')
}
nexusStaging {
profileId = projectParameter('stagingProfileId')
repositoryId = projectParameter('stagingRepositoryId')
}

publishing {
publications {
mavenJava(MavenPublication) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
//

pluginManagement {
repositories {
mavenLocal()
maven {
credentials {
username = NEXUS_USER
password = NEXUS_PASSWORD
}

def au = System.getenv('ARTIFACTORY_URL') + '/artifactory/rnd-maven-dev-virtual'
url au

if (org.gradle.util.GradleVersion.current() >= org.gradle.util.GradleVersion.version('6.0')) {
metadataSources {
mavenPom()
artifact()
}
}
}
}
plugins {
id 'org.octopusden.octopus-release-management' version settings['octopus-release-management.version']
}
}


rootProject.name="deployer-dsl"

include ':deployer-dsl-core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
command-and-arguments=-Poctopus-release-management.version=__RELEASE_MANAGEMENT_VERSION__ \
-PbuildVersion=__BUILD_VERSION__ \
-PgradleStagingPluginVersion=__RELEASE_MANAGEMENT_VERSION__ \
-PreleaseManagementPluginVersion=7.2927 \
-PstagingProfileId=12f37fbf50910f \
-PbuildVersion=__BUILD_VERSION__ \
-Pversion=__BUILD_VERSION__ \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//

plugins {
id 'org.octopusden.octopus-release-management'
}

allprojects {
group = 'org.octopusden.dbsm.cloud'
apply plugin: "org.octopusden.octopus-release-management"
}

releaseManagement {
Expand Down
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-6.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

plugins {
id 'org.octopusden.octopus-release-management'
}

allprojects {
group = 'org.octopusden.rm.ft'
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use_dev_repository=plugins

octopus-release-management.version=1.0-SNAPSHOT

dbsm-cloud-api.version=0.1.71
dbsm-cloud-common.version=0.1.67
components-registry-api.version=0.0.645
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
fishinitself marked this conversation as resolved.
Show resolved Hide resolved
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading