diff --git a/README.md b/README.md index 392524cc780..8d9c959c945 100644 --- a/README.md +++ b/README.md @@ -119,21 +119,21 @@ Bootstrapping installs the necessary dependencies for each package. ## Reproducible Builds for _maven-based_ packages -It is mandatory that any _maven-based_ that publishes artifacts runs [Reproducible Builds](https://reproducible-builds.org/) +It is mandatory that any _maven-based_ that releases artifacts runs [Reproducible Builds](https://reproducible-builds.org/) to build it's artifacts, in this case in our `build:prod` scripts. -> IMPORTANT: the current version of the `maven-artifact-plugin` (3.4.1) used in `kie-tools` bans the `maven-flatten-plugin` that -> we use to generate deployable artifacts using the dynamic `${revision}` variable. You can check the full list of banned -> plugins [here](https://maven.apache.org/plugins-archives/maven-artifact-plugin-3.4.1/plugin-issues.html). -> The issue that caused the ban [flatten-maven-plugin/issues/256](https://github.com/mojohaus/flatten-maven-plugin/issues/256) was created -> due to a problem in `maven` (v3.8.1 ~ v3.8.2) and isn't a problem of the `maven-flatten-plugin` itself and did not require -> any action in the plugin. Actually in later versions of the `maven-artifact-plugin` the ban got revoked. -> Having this in mind, and due to the fact that `kie-tools` requires newer `maven` versions, our _Reproducible Builds_ require -> temporarily overriding the list of banned plugins, until we upgrade to a newer `maven-artifact-plugin` version. +`@kie-tools/maven-base` provides a `maven` profile to enable _Reproducible Builds_ in our builds. To do it follow the steps: -To correctly enable _Reproducible Builds_ package follow the steps: +- Make sure the `package.json` depends on `@kie-tools/maven-base`: + +```json +{ + "dependencies": { + "@kie-tools/maven-base": "workspace:*" + } +} +``` -- Make sure the `package.json` depends on `@kie-tools/maven-base` - Make the package `pom.xml` has `kie-tools-maven-base` as a parent and declares the `project.build.outputTimestamp` property like: ```xml @@ -152,41 +152,27 @@ To correctly enable _Reproducible Builds_ package follow the steps: ``` -- `@kie-tools/maven-base` provides a `reproducible` `maven` profile that can be enabled by using the `-Dreproducible` - argument in `build:prod` scripts, like: +- In your `package.json` scripts, enable the _Reproducible Build_ profile adding the `-Dreproducible` argument in `build:prod` scripts, like: ```json { "scripts": { "build:prod": "pnpm lint && run-script-os", "build:prod:darwin:linux": "mvn clean deploy [...other maven options...] -Dreproducible", - "build:prod:win32": "pnpm powershell \"mvn clean deploy [...other maven options...] `-Dreproducible\"", - "install": "node install.js" + "build:prod:win32": "pnpm powershell \"mvn clean deploy [...other maven options...] `-Dreproducible\"" } } ``` -- Make your `env/index.js` import the `@kie-tools/maven-base` build env: - -```javascript -const { varsWithName, composeEnv } = require("@kie-tools-scripts/build-env"); - -module.exports = composeEnv([require("@kie-tools/root-env/env"), require("@kie-tools/maven-base/env")], { - vars: varsWithName({}), - get env() {}, -}); -``` - -- Modify the package `install.js` to configure the `mvn.config` file to override the list of `plugin-issues` plugins setting the `check.plugin-issues` flag. - -```javascript -const buildEnv = require("./env"); -const { setup } = require("@kie-tools/maven-config-setup-helper"); -setup(` - -Drevision=${buildEnv.env.yourEnv.version} - -Dcheck.plugin-issues=${buildEnv.env.mavenBase.reproducibleBuildIssues} -`); -``` +> IMPORTANT: the current version of the `maven-artifact-plugin` (3.4.1) used in `kie-tools` bans the `maven-flatten-plugin` that +> we use to generate deployable artifacts using the dynamic `${revision}` variable. You can check the full list of banned +> plugins [here](https://maven.apache.org/plugins-archives/maven-artifact-plugin-3.4.1/plugin-issues.html). +> The issue that caused the ban [flatten-maven-plugin/issues/256](https://github.com/mojohaus/flatten-maven-plugin/issues/256) was a result +> due to change in `maven` behaviour between `v3.8.1` and `v3.8.2`, and isn't a problem of the `maven-flatten-plugin. +Actually, in later versions of the `maven-artifact-plugin`the ban got revoked. +Having this in mind, and due to the fact that`kie-tools`requires newer`maven`versions, our _Reproducible Builds_ require +temporarily overriding the list of banned plugins, until we upgrade to a newer`maven-artifact-plugin` version. +> This will be addressed by https://github.com/apache/incubator-kie-issues/issues/1371 --- diff --git a/packages/extended-services-java/env/index.js b/packages/extended-services-java/env/index.js index 893e85a3ca2..b53ded06d18 100644 --- a/packages/extended-services-java/env/index.js +++ b/packages/extended-services-java/env/index.js @@ -19,7 +19,7 @@ const { getOrDefault, varsWithName, composeEnv } = require("@kie-tools-scripts/build-env"); -module.exports = composeEnv([require("@kie-tools/root-env/env"), require("@kie-tools/maven-base/env")], { +module.exports = composeEnv([require("@kie-tools/root-env/env")], { vars: varsWithName({ EXTENDED_SERVICES_JAVA__host: { default: "0.0.0.0", diff --git a/packages/extended-services-java/install.js b/packages/extended-services-java/install.js index 7ae2b6bf1e9..35b3e03912e 100644 --- a/packages/extended-services-java/install.js +++ b/packages/extended-services-java/install.js @@ -20,11 +20,8 @@ const buildEnv = require("./env"); const { setup } = require("@kie-tools/maven-config-setup-helper"); -console.log(buildEnv.env.mavenBase); - setup(` -Drevision=${buildEnv.env.extendedServicesJava.version} -Dquarkus.http.port=${buildEnv.env.extendedServicesJava.port} -Dquarkus.http.host=${buildEnv.env.extendedServicesJava.host} - -Dcheck.plugin-issues=${buildEnv.env.mavenBase.reproducibleBuildIssues} `); diff --git a/packages/jbpm-quarkus-devui/install.js b/packages/jbpm-quarkus-devui/install.js index b539b79bbdd..fbc73cb1c4c 100644 --- a/packages/jbpm-quarkus-devui/install.js +++ b/packages/jbpm-quarkus-devui/install.js @@ -22,5 +22,4 @@ const { setup } = require("@kie-tools/maven-config-setup-helper"); setup(` -Drevision=${buildEnv.env.jbpmQuarkusDevuiExtension.version} - -Dcheck.plugin-issues=${buildEnv.env.mavenBase.reproducibleBuildIssues} `); diff --git a/packages/maven-base/env/index.js b/packages/maven-base/env/index.js index e6bbfaa679b..96c5d8d4e6f 100644 --- a/packages/maven-base/env/index.js +++ b/packages/maven-base/env/index.js @@ -17,7 +17,6 @@ * under the License. */ -const path = require("path"); const { varsWithName, composeEnv, getOrDefault } = require("@kie-tools-scripts/build-env"); module.exports = composeEnv([require("@kie-tools/root-env/env")], { @@ -31,9 +30,6 @@ module.exports = composeEnv([require("@kie-tools/root-env/env")], { return { mavenBase: { version: require("../package.json").version, - reproducibleBuildIssues: path.resolve( - "./node_modules/@kie-tools/maven-base/not-reproducible-plugins.properties" - ), }, maven: { deploy: { diff --git a/packages/maven-base/not-reproducible-plugins.properties b/packages/maven-base/not-reproducible-plugins.properties index 187da6cbefa..4fb578634a5 100644 --- a/packages/maven-base/not-reproducible-plugins.properties +++ b/packages/maven-base/not-reproducible-plugins.properties @@ -15,6 +15,16 @@ # specific language governing permissions and limitations # under the License. + +# KIE-TOOLS DISCLAIMER: +# This file has been copied from the "maven-artifact-plugin" github repo (https://github.com/apache/maven-artifact-plugin/tree/maven-artifact-plugin-3.4.1/) +# with the unique goal of enabling then "maven-flatten-plugin" in the "kie-tools" reproducible builds. +# We are re-enabling the "maven-flatten-plugin" because the issue that caused the inclusion of plugin in this file (https://github.com/mojohaus/flatten-maven-plugin/issues/256) +# won't have any effect in our builds. The issue was reported due to a change in "maven" behaviour between v3.8.1 & v3.8.2 +# and "kie-tools" require newer "maven" versions. +# This file will be removed as a part of: https://github.com/apache/incubator-kie-issues/issues/1371 + + # list of plugins that did not produce reproducible output in the past, with minimum reproducible version # default org.apache.maven.plugins groupId @@ -63,9 +73,9 @@ org.codehaus.plexus+plexus-component-metadata=2.1.0 org.codehaus.mojo+jaxb2-maven-plugin=fail:https://github.com/mojohaus/jaxb2-maven-plugin # org.codehaus.mojo+properties-maven-plugin=1.1.0 - -# DISABLING SINCE https://github.com/mojohaus/flatten-maven-plugin/issues/256 is completed with no change required # https://github.com/mojohaus/properties-maven-plugin/pull/75 + +# Commenting to enable the "flatten-maven-plugin" for "kie-tools", please refer to the DISCLAIMER for more info. # org.codehaus.mojo+flatten-maven-plugin=fail:https://github.com/mojohaus/flatten-maven-plugin/issues/256 org.eclipse.sisu+sisu-maven-plugin=0.3.4 diff --git a/packages/maven-base/package.json b/packages/maven-base/package.json index 35f01393562..8af3e3cbf2f 100644 --- a/packages/maven-base/package.json +++ b/packages/maven-base/package.json @@ -17,8 +17,8 @@ "build:dev:darwin:linux": "mvn clean install -DskipTests", "build:dev:win32": "pnpm powershell \"mvn clean install -DskipTests \"", "build:prod": "pnpm lint && run-script-os", - "build:prod:darwin:linux": "mvn clean deploy -DdeployAtEnd -DskipTests=$(build-env tests.run --not) -Dmaven.test.failure.ignore=$(build-env tests.ignoreFailures) -Dmaven.deploy.skip=$(build-env maven.deploy.skip)", - "build:prod:win32": "pnpm powershell \"mvn clean deploy `-DdeployAtEnd `-DskipTests `-Dmaven.test.failure.ignore=$(build-env tests.ignoreFailures) `-Dmaven.deploy.skip=$(build-env maven.deploy.skip)\"", + "build:prod:darwin:linux": "mvn clean deploy -DdeployAtEnd -DskipTests=$(build-env tests.run --not) -Dmaven.test.failure.ignore=$(build-env tests.ignoreFailures) -Dmaven.deploy.skip=$(build-env maven.deploy.skip) -Dreproducible", + "build:prod:win32": "pnpm powershell \"mvn clean deploy `-DdeployAtEnd `-DskipTests `-Dmaven.test.failure.ignore=$(build-env tests.ignoreFailures) `-Dmaven.deploy.skip=$(build-env maven.deploy.skip) `-Dreproducible\"", "install": "pnpm set-quarkus-version && pnpm set-kogito-version && node install.js", "lint": "echo 'Linting'", "powershell": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command", diff --git a/packages/maven-base/pom.xml b/packages/maven-base/pom.xml index 4ff6f9e2396..8955d649fce 100644 --- a/packages/maven-base/pom.xml +++ b/packages/maven-base/pom.xml @@ -169,6 +169,12 @@ ${version.maven.artifact.plugin} ${project.build.outputTimestamp} + + ${session.executionRootDirectory}/node_modules/@kie-tools/maven-base/not-reproducible-plugins.properties @@ -233,6 +239,7 @@ org.apache.maven.plugins maven-artifact-plugin + check-buildplan diff --git a/packages/sonataflow-quarkus-devui/install.js b/packages/sonataflow-quarkus-devui/install.js index fb227950285..99bfadb8cf8 100644 --- a/packages/sonataflow-quarkus-devui/install.js +++ b/packages/sonataflow-quarkus-devui/install.js @@ -22,5 +22,4 @@ const { setup } = require("@kie-tools/maven-config-setup-helper"); setup(` -Drevision=${buildEnv.env.sonataflowQuarkusDevuiExtension.version} - -Dcheck.plugin-issues=${buildEnv.env.mavenBase.reproducibleBuildIssues} `); diff --git a/packages/vscode-java-code-completion-extension-plugin/env/index.js b/packages/vscode-java-code-completion-extension-plugin/env/index.js index 60a3ca94e24..9a77569f143 100644 --- a/packages/vscode-java-code-completion-extension-plugin/env/index.js +++ b/packages/vscode-java-code-completion-extension-plugin/env/index.js @@ -19,7 +19,7 @@ const { varsWithName, composeEnv } = require("@kie-tools-scripts/build-env"); -module.exports = composeEnv([require("@kie-tools/root-env/env"), require("@kie-tools/maven-base/env")], { +module.exports = composeEnv([require("@kie-tools/root-env/env")], { vars: varsWithName({}), get env() { return { diff --git a/packages/vscode-java-code-completion-extension-plugin/install.js b/packages/vscode-java-code-completion-extension-plugin/install.js index 3f442503a19..3fcd2b81a0f 100644 --- a/packages/vscode-java-code-completion-extension-plugin/install.js +++ b/packages/vscode-java-code-completion-extension-plugin/install.js @@ -29,7 +29,6 @@ const version = buildEnv.env.vscodeJavaCodeCompletionExtensionPlugin.version; setup(` -Drevision=${version} - -Dcheck.plugin-issues=${buildEnv.env.mavenBase.reproducibleBuildIssues} `); console.info("[vscode-java-code-completion-extension-plugin-install] Updating manifest file..."); diff --git a/packages/yard-model/env/index.js b/packages/yard-model/env/index.js index d985416c2e7..425fad9efe4 100644 --- a/packages/yard-model/env/index.js +++ b/packages/yard-model/env/index.js @@ -19,7 +19,7 @@ const { varsWithName, composeEnv } = require("@kie-tools-scripts/build-env"); -module.exports = composeEnv([require("@kie-tools/root-env/env"), require("@kie-tools/maven-base/env")], { +module.exports = composeEnv([require("@kie-tools/root-env/env")], { vars: varsWithName({}), get env() { return { diff --git a/packages/yard-model/install.js b/packages/yard-model/install.js index d823e72c4f7..aa46eae8f39 100644 --- a/packages/yard-model/install.js +++ b/packages/yard-model/install.js @@ -22,5 +22,4 @@ const { setup } = require("@kie-tools/maven-config-setup-helper"); setup(` -Drevision=${buildEnv.env.yardModel.version} - -Dcheck.plugin-issues=${buildEnv.env.mavenBase.reproducibleBuildIssues} `); diff --git a/packages/yard-validator-worker/env/index.js b/packages/yard-validator-worker/env/index.js index 6ab6da8a46e..26e1811bd5a 100644 --- a/packages/yard-validator-worker/env/index.js +++ b/packages/yard-validator-worker/env/index.js @@ -19,7 +19,7 @@ const { varsWithName, composeEnv } = require("@kie-tools-scripts/build-env"); -module.exports = composeEnv([require("@kie-tools/root-env/env"), require("@kie-tools/maven-base/env")], { +module.exports = composeEnv([require("@kie-tools/root-env/env")], { vars: varsWithName({}), get env() { return { diff --git a/packages/yard-validator-worker/install.js b/packages/yard-validator-worker/install.js index 193b1e6d62e..4247286a3fc 100644 --- a/packages/yard-validator-worker/install.js +++ b/packages/yard-validator-worker/install.js @@ -22,5 +22,4 @@ const { setup } = require("@kie-tools/maven-config-setup-helper"); setup(` -Drevision=${buildEnv.env.yardValidator.version} - -Dcheck.plugin-issues=${buildEnv.env.mavenBase.reproducibleBuildIssues} `);