Skip to content

Commit

Permalink
changed maven-artifact-plugin configuration, cleanup, added DISCLAIME…
Browse files Browse the repository at this point in the history
…R and docs
  • Loading branch information
pefernan committed Jun 28, 2024
1 parent 493ddd0 commit 76a6317
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 56 deletions.
58 changes: 22 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -152,41 +152,27 @@ To correctly enable _Reproducible Builds_ package follow the steps:
<projec>
```

- `@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
---

Expand Down
2 changes: 1 addition & 1 deletion packages/extended-services-java/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions packages/extended-services-java/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
`);
1 change: 0 additions & 1 deletion packages/jbpm-quarkus-devui/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
`);
4 changes: 0 additions & 4 deletions packages/maven-base/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")], {
Expand All @@ -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: {
Expand Down
14 changes: 12 additions & 2 deletions packages/maven-base/not-reproducible-plugins.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/maven-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions packages/maven-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@
<version>${version.maven.artifact.plugin}</version>
<configuration>
<outputTimestamp>${project.build.outputTimestamp}</outputTimestamp>
<!--
This configuration overrides the list of issues registered in the plugin to enable the `maven-flatten-plugin
TODO: remove as a part of: https://github.com/apache/incubator-kie-issues/issues/1371
-->
<pluginIssues
>${session.executionRootDirectory}/node_modules/@kie-tools/maven-base/not-reproducible-plugins.properties</pluginIssues>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -233,6 +239,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-artifact-plugin</artifactId>
<configuration />
<executions>
<execution>
<id>check-buildplan</id>
Expand Down
1 change: 0 additions & 1 deletion packages/sonataflow-quarkus-devui/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
`);
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand Down
2 changes: 1 addition & 1 deletion packages/yard-model/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion packages/yard-model/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
`);
2 changes: 1 addition & 1 deletion packages/yard-validator-worker/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion packages/yard-validator-worker/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
`);

0 comments on commit 76a6317

Please sign in to comment.