diff --git a/README.md b/README.md index bb03dbc..8e75adc 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This buildpack will participate if all the following conditions are met The buildpack will do the following for Java applications: -* Contributes the Datadog Java agent to a layer and configures `$JAVA_TOOL_OPTIONS` or `$BP_NATIVE_IMAGE_BUILD_ARGUMENTS` to use it +* Contributes the Datadog Java agent to a layer: `dd-java-agent-.jar` and `dd-java-agent.jar` (as symlink) and configures `$JAVA_TOOL_OPTIONS` or `$BP_NATIVE_IMAGE_BUILD_ARGUMENTS` to use it. The buildpack will do the following for Node.js applications: diff --git a/datadog/java_agent.go b/datadog/java_agent.go index 25a11c6..864029d 100644 --- a/datadog/java_agent.go +++ b/datadog/java_agent.go @@ -42,6 +42,9 @@ func (j JavaAgent) Contribute(layer libcnb.Layer) (libcnb.Layer, error) { if err := sherpa.CopyFile(artifact, file); err != nil { return libcnb.Layer{}, fmt.Errorf("unable to copy artifact to %s\n%w", file, err) } + if err := os.Symlink(file, filepath.Join(layer.Path, "dd-java-agent.jar")); err != nil { + return libcnb.Layer{}, fmt.Errorf("unable to create symlink to %s\n%w", file, err) + } if j.NativeImage { layer.BuildEnvironment.Appendf("BP_NATIVE_IMAGE_BUILD_ARGUMENTS", " ", "-J-javaagent:%s", file) diff --git a/datadog/java_agent_test.go b/datadog/java_agent_test.go index 627e34a..6b1a6e8 100644 --- a/datadog/java_agent_test.go +++ b/datadog/java_agent_test.go @@ -18,6 +18,7 @@ import ( . "github.com/onsi/gomega" "github.com/paketo-buildpacks/libpak" "github.com/paketo-buildpacks/libpak/bard" + "github.com/paketo-buildpacks/libpak/sherpa" "github.com/sclevine/spec" "github.com/paketo-buildpacks/datadog/datadog" @@ -63,6 +64,7 @@ func testJavaAgent(t *testing.T, context spec.G, it spec.S) { Expect(layer.Launch).To(BeTrue()) Expect(filepath.Join(layer.Path, "stub-datadog-agent.jar")).To(BeARegularFile()) + Expect(sherpa.SymlinkExists(filepath.Join(layer.Path, "dd-java-agent.jar"))).To(BeTrue()) Expect(layer.LaunchEnvironment["BPI_DATADOG_AGENT_PATH.default"]).To(Equal(filepath.Join(layer.Path, "stub-datadog-agent.jar"))) }) }