Skip to content

Commit fbd2923

Browse files
JAVA-3738 add project name fallback
1 parent a2c80a3 commit fbd2923

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

gradle-plugin/src/main/java/com/contrastsecurity/gradle/plugin/InstallAgentTask.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ private void attachAgentToTasks(final Path agentPath) {
6262
System.out.println("Attaching agent arguments to Test Tasks");
6363
task.jvmArgs(
6464
createContrastArgs(
65+
getProject().getName(),
6566
agentPath,
6667
config.getAppName(),
6768
config.getServerName(),
@@ -86,12 +87,22 @@ private void attachAgentToTasks(final Path agentPath) {
8687
*/
8788
@VisibleForTesting
8889
public static Collection<String> createContrastArgs(
89-
final Path agentPath, final String appName, final String serverName, String appVersion) {
90+
final String projectName,
91+
final Path agentPath,
92+
final String appName,
93+
final String serverName,
94+
String appVersion) {
95+
9096
final Collection<String> args = new HashSet<String>();
9197
args.add("-javaagent:" + agentPath.toAbsolutePath());
92-
args.add("-Dcontrast.override.appname=" + appName);
98+
if ("null".equals(appName) || appName == null) {
99+
args.add("-Dcontrast.override.appname=" + projectName);
100+
} else {
101+
args.add("-Dcontrast.override.appname=" + appName);
102+
}
93103
args.add("-Dcontrast.server=" + serverName);
94104
args.add("-Dcontrast.env=qa");
105+
args.add("-Dcontrast.assess.enable=true");
95106

96107
if (appVersion == null) {
97108
appVersion = computeAppVersion(appName);

gradle-plugin/src/test/java/com/contrastsecurity/gradle/plugin/InstallAgentTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void verify_correct_contrast_args() {
2424
"-Dcontrast.env=qa",
2525
"-Dcontrast.override.appversion=0.0.1");
2626
final Collection<String> actualArgs =
27-
InstallAgentTask.createContrastArgs(Path.of("/test/path"), "foo", "bar", "0.0.1");
27+
InstallAgentTask.createContrastArgs("name", Path.of("/test/path"), "foo", "bar", "0.0.1");
2828
assertTrue(actualArgs.containsAll(expectedArgs));
2929
}
3030

gradle-plugin/src/test/java/com/contrastsecurity/gradle/plugin/e2e/EndToEndTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.gradle.testkit.runner.TaskOutcome;
2020
import org.junit.jupiter.api.Test;
2121

22+
/** End To End tests for the gradle plugin for interacting with TeamServer */
2223
public class EndToEndTests extends GradleRunnerTest {
2324

2425
@Test

0 commit comments

Comments
 (0)