Skip to content

Commit

Permalink
Merge pull request #7 from GradleUp/add-end-to-end-test
Browse files Browse the repository at this point in the history
Add end to end test using mockserver
  • Loading branch information
martinbonnin authored Apr 4, 2024
2 parents d500d88 + 6896d8d commit 7861dac
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 85 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: gradle/gradle-build-action@v2
- name: Run the CI task
run: ./gradlew ci
- run: |
./gradlew ci
./gradlew -p tests/kmp build
./gradlew -p tests/jvm build
env:
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_USER: ${{ secrets.OSSRH_USER }}
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/nmcp/NmcpAggregation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class NmcpAggregation(
val password: Property<String>,
val publicationType: Property<String>,
val publicationName: Property<String>,
val endpoint: Property<String>,
) {
fun project(path: String) {
project.dependencies.add(configuration.name, project.dependencies.project(mapOf("path" to path)))
Expand Down
7 changes: 6 additions & 1 deletion src/main/kotlin/nmcp/NmcpExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class NmcpExtension(private val project: Project) {
it.password.set(spec.password)
it.publicationType.set(spec.publicationType)
it.publicationName.set(spec.publicationName.orElse("${project.name}-${project.version}.zip"))
it.endpoint.set(spec.endpoint)
}

publishAllPublicationsToCentralPortal.configure {
Expand All @@ -88,6 +89,7 @@ class NmcpExtension(private val project: Project) {
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
)
action.execute(spec)

Expand Down Expand Up @@ -127,7 +129,7 @@ class NmcpExtension(private val project: Project) {
/**
* Adds a `publishAggregatedPublicationToCentralPortal` task to publish a bundle containing all projects.
*
* This function requires [publishAllPublications] or [publish] to be called from at least one submodule.
* This function requires [publishAllPublications] or [publish] to be configured in at least one submodule.
*/
fun publishAggregation(action: Action<NmcpAggregation>) {
val configuration = project.configurations.create("nmcpConsumer") {
Expand All @@ -144,6 +146,7 @@ class NmcpExtension(private val project: Project) {
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
)

action.execute(aggregation)
Expand All @@ -168,6 +171,7 @@ class NmcpExtension(private val project: Project) {
it.password.set(aggregation.password)
it.publicationType.set(aggregation.publicationType)
it.publicationName.set(aggregation.publicationName.orElse("${project.name}-${project.version}.zip"))
it.endpoint.set(aggregation.endpoint)
}
}

Expand All @@ -185,6 +189,7 @@ class NmcpExtension(private val project: Project) {
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
)
action.execute(spec)

Expand Down
5 changes: 4 additions & 1 deletion src/main/kotlin/nmcp/NmcpPublishTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ abstract class NmcpPublishTask : DefaultTask() {
@get:Input
abstract val publicationName: Property<String>

@get:Input
abstract val endpoint: Property<String>

@TaskAction
fun taskAction() {
val username = username.get()
Expand Down Expand Up @@ -61,7 +64,7 @@ abstract class NmcpPublishTask : DefaultTask() {
Request.Builder()
.post(body)
.addHeader("Authorization", "UserToken $token")
.url("https://central.sonatype.com/api/v1/publisher/upload?publishingType=$publicationType")
.url(endpoint.getOrElse("https://central.sonatype.com/api/v1/publisher/upload") + "?publishingType=$publicationType")
.build()
.let {
OkHttpClient.Builder()
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/nmcp/NmcpSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ class NmcpSpec(
val password: Property<String>,
val publicationType: Property<String>,
val publicationName: Property<String>,
val endpoint: Property<String>,
)
106 changes: 53 additions & 53 deletions tests/jvm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ subprojects {
}

nmcp {
publishAllSubprojectsProbablyBreakingProjectIsolation {
publishAllProjectsProbablyBreakingProjectIsolation {
username = System.getenv("MAVEN_CENTRAL_USERNAME")
password = System.getenv("MAVEN_CENTRAL_PASSWORD")
publicationType = "USER_MANAGED"
Expand All @@ -96,59 +96,59 @@ tasks.register("checkZip") {
"net/mbonnin",
"net/mbonnin/tnmcp",
"net/mbonnin/tnmcp/module1",
"net/mbonnin/tnmcp/module1/0.0.2",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2-javadoc.jar",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2-javadoc.jar.md5",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2-javadoc.jar.sha1",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2-javadoc.jar.sha256",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2-javadoc.jar.sha512",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2-sources.jar",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2-sources.jar.md5",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2-sources.jar.sha1",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2-sources.jar.sha256",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2-sources.jar.sha512",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.jar",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.jar.md5",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.jar.sha1",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.jar.sha256",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.jar.sha512",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.module",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.module.md5",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.module.sha1",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.module.sha256",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.module.sha512",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.pom",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.pom.md5",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.pom.sha1",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.pom.sha256",
"net/mbonnin/tnmcp/module1/0.0.2/module1-0.0.2.pom.sha512",
"net/mbonnin/tnmcp/module1/${project.version}",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}-javadoc.jar",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}-javadoc.jar.md5",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}-javadoc.jar.sha1",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}-javadoc.jar.sha256",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}-javadoc.jar.sha512",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}-sources.jar",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}-sources.jar.md5",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}-sources.jar.sha1",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}-sources.jar.sha256",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}-sources.jar.sha512",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.jar",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.jar.md5",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.jar.sha1",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.jar.sha256",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.jar.sha512",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.module",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.module.md5",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.module.sha1",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.module.sha256",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.module.sha512",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.pom",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.pom.md5",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.pom.sha1",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.pom.sha256",
"net/mbonnin/tnmcp/module1/${project.version}/module1-${project.version}.pom.sha512",
"net/mbonnin/tnmcp/module2",
"net/mbonnin/tnmcp/module2/0.0.2",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2-javadoc.jar",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2-javadoc.jar.md5",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2-javadoc.jar.sha1",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2-javadoc.jar.sha256",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2-javadoc.jar.sha512",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2-sources.jar",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2-sources.jar.md5",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2-sources.jar.sha1",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2-sources.jar.sha256",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2-sources.jar.sha512",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.jar",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.jar.md5",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.jar.sha1",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.jar.sha256",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.jar.sha512",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.module",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.module.md5",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.module.sha1",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.module.sha256",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.module.sha512",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.pom",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.pom.md5",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.pom.sha1",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.pom.sha256",
"net/mbonnin/tnmcp/module2/0.0.2/module2-0.0.2.pom.sha512"
"net/mbonnin/tnmcp/module2/${project.version}",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}-javadoc.jar",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}-javadoc.jar.md5",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}-javadoc.jar.sha1",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}-javadoc.jar.sha256",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}-javadoc.jar.sha512",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}-sources.jar",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}-sources.jar.md5",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}-sources.jar.sha1",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}-sources.jar.sha256",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}-sources.jar.sha512",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.jar",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.jar.md5",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.jar.sha1",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.jar.sha256",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.jar.sha512",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.module",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.module.md5",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.module.sha1",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.module.sha256",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.module.sha512",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.pom",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.pom.md5",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.pom.sha1",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.pom.sha256",
"net/mbonnin/tnmcp/module2/${project.version}/module2-${project.version}.pom.sha512"
)
)
)
Expand Down
Loading

0 comments on commit 7861dac

Please sign in to comment.