Skip to content

Commit 4116250

Browse files
authored
fix(gen-build-spec): remove the default -Dmaven.test.skip=true mvn option from the default spec (#1301)
This PR removes the default -Dmaven.test.skip=true option from the default buildspec for Maven artifacts. Signed-off-by: behnazh-w <behnaz.hassanshahi@oracle.com>
1 parent cbf03c7 commit 4116250

8 files changed

Lines changed: 21 additions & 14 deletions

File tree

docs/source/pages/tutorials/rebuild_third_party_artifacts.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ By default we generate the buildspec in JSON format as follows:
131131
[
132132
"mvn",
133133
"-DskipTests=true",
134-
"-Dmaven.test.skip=true",
135134
"-Dmaven.site.skip=true",
136135
"-Drat.skip=true",
137136
"-Dmaven.javadoc.skip=true",
@@ -161,7 +160,7 @@ The resulting file will be saved as ``output/buildspec/maven/org_apache_hugegrap
161160
tool=mvn
162161
jdk=8
163162
newline=lf
164-
command="mvn -DskipTests=true -Dmaven.test.skip=true -Dmaven.site.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true clean package"
163+
command="mvn -Dmaven.test.skip=true -DskipTests=true -Dmaven.site.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true clean package"
165164
buildinfo=target/computer-k8s-1.0.0.buildinfo
166165
167166
You can now use this file to automate rebuilding artifacts, for example as part of the Reproducible Central infrastructure.

src/macaron/build_spec_generator/build_command_patcher.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
# To remove "-Dgpg.passphrase=$MACARON_UNKNOWN"
4848
"gpg.passphrase": None,
4949
"skipTests": "true",
50-
"maven.test.skip": "true",
5150
"maven.site.skip": "true",
5251
"rat.skip": "true",
5352
"maven.javadoc.skip": "true",

src/macaron/build_spec_generator/common_spec/jdk_finder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2025 - 2026, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
"""This module includes the functions for obtaining the JDK version from a Java artifact."""
@@ -198,7 +198,7 @@ def find_jdk_version_from_remote_maven_repo_standalone(
198198
local_artifact_path,
199199
)
200200
except InvalidHTTPResponseError as error:
201-
logger.error("Failed why trying to download jar file. Error: %s", error)
201+
logger.debug("Failed while trying to download jar file. Error: %s", error)
202202
return None
203203
except OSError as os_error:
204204
logger.critical("Critical %s", os_error)
@@ -278,7 +278,7 @@ def find_jdk_version_from_remote_maven_repo_cache(
278278
local_artifact_path,
279279
)
280280
except InvalidHTTPResponseError as error:
281-
logger.error("Failed why trying to download jar file. Error: %s", error)
281+
logger.debug("Failed while trying to download jar file. Error: %s", error)
282282
return None
283283
except OSError as os_error:
284284
logger.critical("Critical %s", os_error)

src/macaron/build_spec_generator/reproducible_central/reproducible_central.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2025 - 2026, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
"""This module contains the logic to generate a build spec in the Reproducible Central format."""
@@ -85,6 +85,14 @@ def gen_reproducible_central_build_spec(build_spec: BaseBuildSpecDict) -> str |
8585
if build_spec["group_id"] is None:
8686
raise GenerateBuildSpecError(f"Version is missing in PURL {build_spec['purl']}")
8787

88+
# Add -Dmaven.test.skip for Maven builds.
89+
# TODO: Use the build tool associated with the build command once
90+
# https://github.com/oracle/macaron/issues/1300 is closed.
91+
adapted_build_commands = [
92+
cmd[:1] + ["-Dmaven.test.skip=true"] + cmd[1:] if ReproducibleCentralBuildTool.MAVEN in cmd[0] else cmd
93+
for cmd in build_spec["build_commands"]
94+
]
95+
8896
template_format_values: dict[str, str] = {
8997
"macaron_version": importlib_metadata.version("macaron"),
9098
"group_id": build_spec["group_id"],
@@ -96,7 +104,7 @@ def gen_reproducible_central_build_spec(build_spec: BaseBuildSpecDict) -> str |
96104
"newline": build_spec["newline"],
97105
"buildinfo": f"target/{build_spec['artifact_id']}-{build_spec['version']}.buildinfo",
98106
"jdk": build_spec["language_version"][0],
99-
"command": compose_shell_commands(build_spec["build_commands"]),
107+
"command": compose_shell_commands(adapted_build_commands),
100108
}
101109

102110
return STRING_TEMPLATE.format_map(template_format_values)

tests/build_spec_generator/reproducible_central/test_reproducible_central.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2025 - 2026, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
"""This module contains tests for Reproducible Central build spec generation."""
@@ -40,7 +40,7 @@ def test_successful_build_spec(base_build_spec: BaseBuildSpecDict) -> None:
4040
assert "groupId=com.oracle" in content
4141
assert "artifactId=example-artifact" in content
4242
assert "tool=mvn" in content
43-
assert 'command="mvn package"' in content
43+
assert 'command="mvn -Dmaven.test.skip=true package"' in content
4444

4545

4646
def test_unsupported_build_tool(base_build_spec: BaseBuildSpecDict) -> None:
@@ -80,6 +80,8 @@ def test_compose_shell_commands_integration(base_build_spec: BaseBuildSpecDict)
8080
"""Test that the correct compose_shell_commands function is used."""
8181
base_build_spec["build_commands"] = [["mvn", "clean", "package"], ["echo", "done"]]
8282
content = gen_reproducible_central_build_spec(base_build_spec)
83-
expected_commands = compose_shell_commands([["mvn", "clean", "package"], ["echo", "done"]])
83+
expected_commands = compose_shell_commands(
84+
[["mvn", "-Dmaven.test.skip=true", "clean", "package"], ["echo", "done"]]
85+
)
8486
assert content
8587
assert f'command="{expected_commands}"' in content
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"macaron_version": "0.17.0", "group_id": "io.github.behnazh-w.demo", "artifact_id": "core", "version": "2.0.3", "git_repo": "https://github.com/behnazh-w/example-maven-provenance", "git_tag": "597be192fb50f03b86c34f1bfc494fea1eab264f", "newline": "lf", "language_version": "17", "ecosystem": "maven", "purl": "pkg:maven/io.github.behnazh-w.demo/core@2.0.3", "language": "java", "build_tool": "maven", "build_commands": [["./mvnw", "-DskipTests=true", "-Dmaven.test.skip=true", "-Dmaven.site.skip=true", "-Drat.skip=true", "-Dmaven.javadoc.skip=true", "clean", "package"]]}
1+
{"macaron_version": "0.17.0", "group_id": "io.github.behnazh-w.demo", "artifact_id": "core", "version": "2.0.3", "git_repo": "https://github.com/behnazh-w/example-maven-provenance", "git_tag": "597be192fb50f03b86c34f1bfc494fea1eab264f", "newline": "lf", "language_version": "17", "ecosystem": "maven", "purl": "pkg:maven/io.github.behnazh-w.demo/core@2.0.3", "language": "java", "build_tool": "maven", "build_commands": [["./mvnw", "-DskipTests=true", "-Dmaven.site.skip=true", "-Drat.skip=true", "-Dmaven.javadoc.skip=true", "clean", "package"]]}

tests/integration/cases/behnazh-w_example-maven-app_gen_rc_build_spec/expected_reproducible_central.buildspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jdk=17
1414

1515
newline=lf
1616

17-
command="./mvnw -DskipTests=true -Dmaven.test.skip=true -Dmaven.site.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true clean package"
17+
command="./mvnw -Dmaven.test.skip=true -DskipTests=true -Dmaven.site.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true clean package"
1818

1919
buildinfo=target/core-2.0.3.buildinfo

tests/integration/cases/org_apache_hugegraph/computer-k8s/expected_default.buildspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
[
2020
"mvn",
2121
"-DskipTests=true",
22-
"-Dmaven.test.skip=true",
2322
"-Dmaven.site.skip=true",
2423
"-Drat.skip=true",
2524
"-Dmaven.javadoc.skip=true",

0 commit comments

Comments
 (0)