diff --git a/README.md b/README.md index 8475c52..526738d 100644 --- a/README.md +++ b/README.md @@ -242,7 +242,7 @@ nexusReleasePlugin { Run `./gradlew releaseAllPlan` first and review the selection, then `./gradlew bundleAll` to check, sign, and bundle it, and `./gradlew releaseAll` to upload. The ZIP defaults to -`build/releaseAll/bundle.zip`. Dependencies on omitted siblings must already be released. +`build/releaseAll/-mega-bundle.zip` (e.g. `build/releaseAll/jmlx-mega-bundle.zip`). Dependencies on omitted siblings must already be released. No BOM, Maven settings helper, candidate JSON, or custom staging tasks are needed. Embedded or compile-only internal projects can be declared explicitly with `unpublishedProjectDependencies`; see the guide for its publication-metadata requirements. diff --git a/combined-releases.md b/combined-releases.md index b9bf046..f0bbf47 100644 --- a/combined-releases.md +++ b/combined-releases.md @@ -119,7 +119,8 @@ work when the plan contains no selected static Maven components. Defaults in module mode are the root project as `sourceDirectory` and these paths under the root build directory: `releaseAll/manifest.json`, `releaseAll/staging`, -`releaseAll/bundle.zip`, `releaseAll/bundle-receipt.json`, and `releaseAll/deployment.json`. +`releaseAll/-mega-bundle.zip`, `releaseAll/bundle-receipt.json`, +and `releaseAll/deployment.json`. The existing shared properties override these conventions. Repository/Portal URLs and credentials use the shared conventions below. Configure module selection and opt-outs in the root build script. Both lists are finalized after all projects are evaluated in default diff --git a/gradle.properties b/gradle.properties index dbb969a..042043d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=se.alipsa.gradle -version=2.5.1 +version=2.6.0-SNAPSHOT org.gradle.configuration-cache=true org.gradle.parallel=true org.gradle.caching=true diff --git a/release.md b/release.md index 92a01e3..0511e84 100644 --- a/release.md +++ b/release.md @@ -1,5 +1,14 @@ # Release history +## Ver 2.6.0 (in progress) +- Change the default combined-release bundle name from `bundle.zip` to + `-mega-bundle.zip` (e.g. `jmlx-mega-bundle.zip`), which is + also used as the Central Portal deployment name. Override with + `combinedRelease { bundleFile = ... }` as before. +- Re-run `bundleAll` after upgrading if a bundle was built with an earlier + version; the old `build/releaseAll/bundle.zip` is no longer used and can be + deleted. + ## Ver 2.5.1, 2026-11-05 - Fix #11: use fixed, timezone-independent timestamps for all combined ZIP entries; document per-run receipt hashes and signing limits. - Fix #12: order manifest consumers after `releaseAllPlan` when scheduled together. Reject changed selections before bundling stale staging files, and reject resolved task graphs containing both planning and upload before any tasks run so the saved manifest can be reviewed. Preserve separate initial planning and status-only resume. diff --git a/src/main/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseConfigurer.groovy b/src/main/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseConfigurer.groovy index 725aa62..853490d 100644 --- a/src/main/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseConfigurer.groovy +++ b/src/main/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseConfigurer.groovy @@ -29,7 +29,7 @@ final class ModuleReleaseConfigurer { extension.sourceDirectory.convention(project.layout.projectDirectory) extension.manifestFile.convention(project.layout.buildDirectory.file('releaseAll/manifest.json')) extension.stagingDirectory.convention(project.layout.buildDirectory.dir('releaseAll/staging')) - extension.bundleFile.convention(project.layout.buildDirectory.file('releaseAll/bundle.zip')) + extension.bundleFile.convention(project.layout.buildDirectory.file("releaseAll/${project.name}-mega-bundle.zip")) extension.receiptFile.convention(project.layout.buildDirectory.file('releaseAll/bundle-receipt.json')) extension.recordFile.convention(project.layout.buildDirectory.file('releaseAll/deployment.json')) // Under configure-on-demand, projects must be evaluated here, outside lazy task diff --git a/src/test/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseTest.groovy b/src/test/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseTest.groovy index c84c71c..ffd0967 100644 --- a/src/test/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseTest.groovy +++ b/src/test/groovy/se/alipsa/gradle/plugin/release/ModuleReleaseTest.groovy @@ -2,6 +2,7 @@ package se.alipsa.gradle.plugin.release import com.sun.net.httpserver.HttpServer import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Timeout import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource @@ -9,6 +10,8 @@ import java.util.zip.ZipFile import static org.junit.jupiter.api.Assertions.* class ModuleReleaseTest { + private static final String BUNDLE = 'build/releaseAll/module-release-fixture-mega-bundle.zip' + @TempDir File root @Test void helpDoesNotRealizeReleaseAll() { @@ -92,14 +95,14 @@ publishing.publications.maven.pom.withXml { if (!disableMetadata) { def failed = runner('bundleAll').buildAndFail() assertTrue(failed.output.contains("Unpublished project dependency ':core' is still referenced by Gradle Module Metadata")) - assertFalse(new File(root, 'build/releaseAll/bundle.zip').exists()) + assertFalse(new File(root, BUNDLE).exists()) } else { run('bundleAll') new ZipFile(new File(root, 'build/releaseAll/staging/example/api-artifact/1.0/api-artifact-1.0.jar')).withCloseable { jar -> assertNotNull(jar.getEntry('Core.class')) assertNotNull(jar.getEntry('Api.class')) } - assertTrue(new File(root, 'build/releaseAll/bundle.zip').isFile()) + assertTrue(new File(root, BUNDLE).isFile()) } } } @@ -212,7 +215,7 @@ if (gradle.startParameter.taskNames == ['help']) { Map publication = ReleaseManifest.read(new File(root, 'build/releaseAll/manifest.json')).selected.first() assertFalse(publication.files.any { it.endsWith('.module') }) run('bundleAll') - new ZipFile(new File(root, 'build/releaseAll/bundle.zip')).withCloseable { zip -> + new ZipFile(new File(root, BUNDLE)).withCloseable { zip -> assertFalse(zip.entries().any { it.name.contains('.module') }) } } @@ -241,7 +244,7 @@ if (gradle.startParameter.taskNames == ['help']) { assertNull(bundle.task(':unused:signMavenPublication')) assertNull(bundle.task(':unused:check')) assertNull(bundle.task(':releaseAllPrepareMaven')) - File zip = new File(root, 'build/releaseAll/bundle.zip') + File zip = new File(root, BUNDLE) Set entries = new ZipFile(zip).withCloseable { it.entries().collect { it.name } as Set } Set expected = [] as Set ['api-artifact', 'core-artifact'].each { String name -> @@ -259,6 +262,22 @@ if (gradle.startParameter.taskNames == ['help']) { } } + @Test + @Timeout(120) + void consumerConfiguredBundleFileOverridesTheModuleModeDefault() { + withServer(Collections.synchronizedSet([] as Set), ['example:core-artifact:1.0'] as Set) { String base, List requests, List bodies -> + fixture(base, "modules = [':core']; bundleFile = layout.buildDirectory.file('custom/my-bundle.zip')") + run('releaseAllPlan') + run(':bundleAll') + assertTrue(new File(root, 'build/custom/my-bundle.zip').isFile()) + assertFalse(new File(root, BUNDLE).exists()) + run(':releaseAll') + assertTrue(requests.any { it.contains('/publisher/upload') }) + assertTrue(bodies.any { it.contains('filename="my-bundle.zip"') }, + { -> "upload should use my-bundle.zip; Content-Disposition lines: ${bodies*.readLines().flatten().findAll { it.startsWith('Content-Disposition') }}" } as java.util.function.Supplier) + } + } + @Test void planAndConsumersCanShareAnInvocationAfterInitialPlanning() { withServer { String base, List requests -> fixture(base, "modules = [':core']") @@ -266,7 +285,7 @@ if (gradle.startParameter.taskNames == ['help']) { // Request consumers first to prove ordering is independent of CLI order. def result = run(':bundleAll', ':releaseAllPrepareMaven', ':releaseAllPlan') assertNotNull(result.task(':core:signMavenPublication')) - assertTrue(new File(root, 'build/releaseAll/bundle.zip').isFile()) + assertTrue(new File(root, BUNDLE).isFile()) List tasks = result.tasks*.path [':releaseAllSigningCheck', ':releaseAllGuard', ':releaseAllPrepareMaven', ':bundleAll'].each { assertTrue(tasks.indexOf(':releaseAllPlan') < tasks.indexOf(it)) @@ -292,7 +311,7 @@ if (gradle.startParameter.taskNames == ['help']) { build.text = build.text.replace("modules = [':core']", "modules = [':api', ':core']") new File(root, 'api/src/main/java/Api.java').text = '/** Updated. */ public class Api { public int value() { return 42; } }' commit() - File zip = new File(root, 'build/releaseAll/bundle.zip') + File zip = new File(root, BUNDLE) File receipt = new File(root, 'build/releaseAll/bundle-receipt.json') assertTrue(zip.delete()) assertTrue(receipt.delete()) @@ -336,9 +355,9 @@ if (gradle.startParameter.taskNames == ['help']) { commit() run(':releaseAllPlan') run(':bundleAll') - List saved = ['manifest.json', 'bundle.zip', 'bundle-receipt.json'].collect { + List saved = ['manifest.json', 'bundle-receipt.json'].collect { new File(root, 'build/releaseAll/' + it) - } + } + new File(root, BUNDLE) List original = saved.collect { it.bytes } requests.clear() String[] flags = request == 'fullRelease' ? [] as String[] : [':releaseAll'] as String[] @@ -389,7 +408,7 @@ if (gradle.startParameter.taskNames == ['help']) { def result = run('bundleAll') assertNull(result.task(':core:signMavenPublication')) assertNull(result.task(':core:publishMavenPublicationToCombinedReleaseStagingRepository')) - new ZipFile(new File(root, 'build/releaseAll/bundle.zip')).withCloseable { zip -> + new ZipFile(new File(root, BUNDLE)).withCloseable { zip -> assertTrue(zip.entries().every { it.name.startsWith('example/api-artifact/') }) } } @@ -407,7 +426,7 @@ if (gradle.startParameter.taskNames == ['help']) { run('releaseAllPlan') assertEquals('pom', ReleaseManifest.read(new File(root, 'build/releaseAll/manifest.json')).selected.first().packaging) run('bundleAll') - new ZipFile(new File(root, 'build/releaseAll/bundle.zip')).withCloseable { zip -> + new ZipFile(new File(root, BUNDLE)).withCloseable { zip -> assertEquals(6, zip.size()) assertTrue(zip.entries().every { it.name.contains('.pom') }) } @@ -560,22 +579,37 @@ ${name == 'api' ? "dependencies { ${compileOnly ? 'compileOnly' : 'api'} project } private void withServer(Set published = [] as Set, Closure action) { + withServer(published, false, [] as Set) { String base, List requests, List bodies -> action(base, requests) } + } + + /** Variant for full upload flows: captures bodies, answers uploads, and marks the given coordinates + * published once the upload request arrives, so post-upload availability probes succeed. */ + private void withServer(Set published, Set deployedOnUpload, Closure action) { + withServer(published, true, deployedOnUpload, action) + } + + private void withServer(Set published, boolean captureBodies, Set deployedOnUpload, Closure action) { List requests = Collections.synchronizedList([]) + List bodies = Collections.synchronizedList([]) def server = HttpServer.create(new InetSocketAddress('127.0.0.1', 0), 0) server.createContext('/') { exchange -> requests.add(exchange.requestURI.toString()) boolean portal = exchange.requestURI.path.contains('/publisher/published') boolean status = exchange.requestURI.path.contains('/publisher/status') + boolean upload = exchange.requestURI.path.contains('/publisher/upload') boolean released = published.any { String coordinate -> def (group, name, version) = coordinate.split(':') - exchange.requestURI.path.endsWith("/${group.replace('.', '/')}/${name}/${version}/${name}-${version}.pom") + exchange.requestURI.path.endsWith("/${group.replace('.', '/')}/${name}/${version}/${name}-${version}.pom") || + exchange.requestURI.path.endsWith("/${group.replace('.', '/')}/${name}/${version}/${name}-${version}.jar") } - byte[] body = (status ? '{"deploymentState":"PUBLISHED"}' : portal ? '{"published":false}' : '').getBytes('UTF-8') - exchange.sendResponseHeaders(portal || status || released ? 200 : 404, exchange.requestMethod == 'HEAD' ? -1 : body.length) + if (captureBodies) bodies.add(new String(exchange.requestBody.readAllBytes(), 'UTF-8')) + if (upload) published.addAll(deployedOnUpload) + byte[] body = (status ? '{"deploymentState":"PUBLISHED"}' : portal ? '{"published":false}' : upload ? 'upload-deployment-id' : '').getBytes('UTF-8') + exchange.sendResponseHeaders(portal || status || upload || released ? 200 : 404, exchange.requestMethod == 'HEAD' ? -1 : body.length) exchange.responseBody.withCloseable { it.write(body) } } server.start() - try { action("http://127.0.0.1:${server.address.port}".toString(), requests) } + try { action("http://127.0.0.1:${server.address.port}".toString(), requests, bodies) } finally { server.stop(0) } }