Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ By default we generate the buildspec in JSON format as follows:
[
"mvn",
"-DskipTests=true",
"-Dmaven.test.skip=true",
"-Dmaven.site.skip=true",
"-Drat.skip=true",
"-Dmaven.javadoc.skip=true",
Expand Down Expand Up @@ -161,7 +160,7 @@ The resulting file will be saved as ``output/buildspec/maven/org_apache_hugegrap
tool=mvn
jdk=8
newline=lf
command="mvn -DskipTests=true -Dmaven.test.skip=true -Dmaven.site.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true clean package"
command="mvn -Dmaven.test.skip=true -DskipTests=true -Dmaven.site.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true clean package"
buildinfo=target/computer-k8s-1.0.0.buildinfo

You can now use this file to automate rebuilding artifacts, for example as part of the Reproducible Central infrastructure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
# To remove "-Dgpg.passphrase=$MACARON_UNKNOWN"
"gpg.passphrase": None,
"skipTests": "true",
"maven.test.skip": "true",
"maven.site.skip": "true",
"rat.skip": "true",
"maven.javadoc.skip": "true",
Expand Down
6 changes: 3 additions & 3 deletions src/macaron/build_spec_generator/common_spec/jdk_finder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2025 - 2026, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.

"""This module includes the functions for obtaining the JDK version from a Java artifact."""
Expand Down Expand Up @@ -198,7 +198,7 @@ def find_jdk_version_from_remote_maven_repo_standalone(
local_artifact_path,
)
except InvalidHTTPResponseError as error:
logger.error("Failed why trying to download jar file. Error: %s", error)
logger.debug("Failed while trying to download jar file. Error: %s", error)
return None
except OSError as os_error:
logger.critical("Critical %s", os_error)
Expand Down Expand Up @@ -278,7 +278,7 @@ def find_jdk_version_from_remote_maven_repo_cache(
local_artifact_path,
)
except InvalidHTTPResponseError as error:
logger.error("Failed why trying to download jar file. Error: %s", error)
logger.debug("Failed while trying to download jar file. Error: %s", error)
return None
except OSError as os_error:
logger.critical("Critical %s", os_error)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2025 - 2026, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.

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

# Add -Dmaven.test.skip for Maven builds.
# TODO: Use the build tool associated with the build command once
# https://github.com/oracle/macaron/issues/1300 is closed.
adapted_build_commands = [
cmd[:1] + ["-Dmaven.test.skip=true"] + cmd[1:] if ReproducibleCentralBuildTool.MAVEN in cmd[0] else cmd
for cmd in build_spec["build_commands"]
]

template_format_values: dict[str, str] = {
"macaron_version": importlib_metadata.version("macaron"),
"group_id": build_spec["group_id"],
Expand All @@ -96,7 +104,7 @@ def gen_reproducible_central_build_spec(build_spec: BaseBuildSpecDict) -> str |
"newline": build_spec["newline"],
"buildinfo": f"target/{build_spec['artifact_id']}-{build_spec['version']}.buildinfo",
"jdk": build_spec["language_version"][0],
"command": compose_shell_commands(build_spec["build_commands"]),
"command": compose_shell_commands(adapted_build_commands),
}

return STRING_TEMPLATE.format_map(template_format_values)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2025 - 2026, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.

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


def test_unsupported_build_tool(base_build_spec: BaseBuildSpecDict) -> None:
Expand Down Expand Up @@ -80,6 +80,8 @@ def test_compose_shell_commands_integration(base_build_spec: BaseBuildSpecDict)
"""Test that the correct compose_shell_commands function is used."""
base_build_spec["build_commands"] = [["mvn", "clean", "package"], ["echo", "done"]]
content = gen_reproducible_central_build_spec(base_build_spec)
expected_commands = compose_shell_commands([["mvn", "clean", "package"], ["echo", "done"]])
expected_commands = compose_shell_commands(
[["mvn", "-Dmaven.test.skip=true", "clean", "package"], ["echo", "done"]]
)
assert content
assert f'command="{expected_commands}"' in content
Original file line number Diff line number Diff line change
@@ -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"]]}
{"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"]]}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jdk=17

newline=lf

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

buildinfo=target/core-2.0.3.buildinfo
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
[
"mvn",
"-DskipTests=true",
"-Dmaven.test.skip=true",
"-Dmaven.site.skip=true",
"-Drat.skip=true",
"-Dmaven.javadoc.skip=true",
Expand Down
Loading