From 0d9cf511e58d0329dbff7e749109be76c61fb84e Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Sat, 6 Nov 2021 05:29:14 +0100 Subject: [PATCH] fix(pacmak): development version cannot pack java (#3121) When the version of `jsii-pacmak` is `0.0.0`, it will write the following requirement for `jsii-runtime`: `[,0.0.1)`. There is no version that satisfies that dependency, so the build fails. Make an exception: if the version we're trying to install is `^0.0.0`, translate it to "any old version" instead. Fixes #3107. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0 --- packages/jsii-pacmak/lib/targets/version-utils.ts | 2 +- .../__snapshots__/examples.test.ts.snap | 8 ++++---- .../prerelease-identifiers.test.ts.snap | 8 ++++---- .../__snapshots__/target-dotnet.test.ts.snap | 12 ++++++------ .../__snapshots__/target-java.test.ts.snap | 14 +++++++------- .../jsii-pacmak/test/targets/version-utils.test.ts | 4 ++++ 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/version-utils.ts b/packages/jsii-pacmak/lib/targets/version-utils.ts index 1cc5568e7b..af33cc7df2 100644 --- a/packages/jsii-pacmak/lib/targets/version-utils.ts +++ b/packages/jsii-pacmak/lib/targets/version-utils.ts @@ -158,7 +158,7 @@ function toBracketNotation( target = TargetName.JAVASCRIPT, }: { semver?: boolean; target?: TargetName } = {}, ): string { - if (semverRange === '*') { + if (semverRange === '*' || semverRange === '^0.0.0') { semverRange = '>=0.0.0'; } const range = new Range(semverRange); diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap index dc73a76aa1..1f67e89b33 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.ts.snap @@ -89,7 +89,7 @@ exports[`diamond-struct-parameter.ts: /dotnet/Example.Test.Demo/Example. - + @@ -528,7 +528,7 @@ exports[`diamond-struct-parameter.ts: /java/pom.xml 1`] = ` software.amazon.jsii jsii-runtime - (,0.0.1) + [0.0.0,) org.jetbrains @@ -1503,7 +1503,7 @@ exports[`nested-types.ts: /dotnet/Example.Test.Demo/Example.Test.Demo.cs - + @@ -2027,7 +2027,7 @@ exports[`nested-types.ts: /java/pom.xml 1`] = ` software.amazon.jsii jsii-runtime - (,0.0.1) + [0.0.0,) org.jetbrains diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.ts.snap index d042195d8d..a0cef5e205 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.ts.snap @@ -208,7 +208,7 @@ exports[`foo@1.2.3 depends on bar@^2.0.0-rc.42: /java/pom.xml 1`] = ` software.amazon.jsii jsii-runtime - (,0.0.1) + [0.0.0,) org.jetbrains @@ -717,7 +717,7 @@ exports[`foo@1.2.3 depends on bar@^4.5.6-pre.1337: /java/pom.xml 1`] = ` software.amazon.jsii jsii-runtime - (,0.0.1) + [0.0.0,) org.jetbrains @@ -1214,7 +1214,7 @@ exports[`foo@2.0.0-rc.42: /java/pom.xml 1`] = ` software.amazon.jsii jsii-runtime - (,0.0.1) + [0.0.0,) org.jetbrains @@ -1700,7 +1700,7 @@ exports[`foo@4.5.6-pre.1337: /java/pom.xml 1`] = ` software.amazon.jsii jsii-runtime - (,0.0.1) + [0.0.0,) org.jetbrains diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap index 6073bf8b18..6e9756aa9e 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap @@ -52,7 +52,7 @@ exports[`Generated code for "@scope/jsii-calc-base": /dotnet/Amazon.JSII - + @@ -549,7 +549,7 @@ exports[`Generated code for "@scope/jsii-calc-base-of-base": /dotnet/Ama - + @@ -1033,8 +1033,8 @@ exports[`Generated code for "@scope/jsii-calc-lib": /dotnet/Amazon.JSII. - - + + @@ -3104,8 +3104,8 @@ exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.Calcu - - + + diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap index f6e7c100d7..e15d97d6a0 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap @@ -286,7 +286,7 @@ exports[`Generated code for "@scope/jsii-calc-base": /java/pom.xml 1`] = software.amazon.jsii jsii-runtime - (,0.0.1) + [0.0.0,) org.jetbrains @@ -1004,7 +1004,7 @@ exports[`Generated code for "@scope/jsii-calc-base-of-base": /java/pom.x software.amazon.jsii jsii-runtime - (,0.0.1) + [0.0.0,) org.jetbrains @@ -1696,7 +1696,7 @@ exports[`Generated code for "@scope/jsii-calc-lib": /java/pom.xml 1`] = software.amazon.jsii.tests calculator-base - (,0.0.1) + [0.0.0,) software.amazon.jsii.tests @@ -1706,7 +1706,7 @@ exports[`Generated code for "@scope/jsii-calc-lib": /java/pom.xml 1`] = software.amazon.jsii jsii-runtime - (,0.0.1) + [0.0.0,) org.jetbrains @@ -4149,17 +4149,17 @@ exports[`Generated code for "jsii-calc": /java/pom.xml 1`] = ` software.amazon.jsii.tests calculator-base - (,0.0.1) + [0.0.0,) software.amazon.jsii.tests calculator-lib - (,0.0.1.DEVPREVIEW) + [0.0.0,) software.amazon.jsii jsii-runtime - (,0.0.1) + [0.0.0,) org.jetbrains diff --git a/packages/jsii-pacmak/test/targets/version-utils.test.ts b/packages/jsii-pacmak/test/targets/version-utils.test.ts index 855d13a39f..8564706e2d 100644 --- a/packages/jsii-pacmak/test/targets/version-utils.test.ts +++ b/packages/jsii-pacmak/test/targets/version-utils.test.ts @@ -91,6 +91,10 @@ describe(toMavenVersionRange, () => { } }); +test('Maven dependency on jsii-runtime for a development version is workable', () => { + expect(toMavenVersionRange('^0.0.0')).toEqual('[0.0.0,)'); +}); + describe(toNuGetVersionRange, () => { for (const [semver, { nuget }] of Object.entries(examples)) { test(`${semver} translates to ${nuget}`, () =>