Skip to content

Commit

Permalink
fix: Add backward compatibility for Gradle 5.0
Browse files Browse the repository at this point in the history
The `fileValue` method did not yet exist in Gradle 5.0. By replacing it,
we're able to stretch our compatibility matrix to Gradle 5.0 and above.
  • Loading branch information
dustinbyrne committed Oct 1, 2021
1 parent 8370670 commit 5fad30c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public List<String> getAsJvmArg() {
if (!appmap.isConfigFileValid()) {
appmap.setSkip(true);
throw new GradleException("Configuration file must exist and be readable: "
+ appmap.getConfigFile().get().getAsFile().getPath());
+ appmap.getConfigFilePath());
}
if (appmap.shouldSkip()) {
LOGGER.warn("AppMap task was executed but but is disabled, 'skip' property set to " + appmap
Expand All @@ -70,9 +70,9 @@ public List<String> getAsJvmArg() {
argumentLn.add(javaAgentArg);

if ( appmap.getConfigFile().isPresent() ) {
argumentLn.add("-Dappmap.config.file=" + appmap.getConfigFile().get());
argumentLn.add("-Dappmap.config.file=" + appmap.getConfigFilePath());
}
argumentLn.add("-Dappmap.output.directory=" + appmap.getOutputDirectory().get());
argumentLn.add("-Dappmap.output.directory=" + appmap.getOutputDirectoryPath());
argumentLn.add("-Dappmap.event.valueSize=" + appmap.getEventValueSize());
argumentLn.addAll(buildDebugParams());
LOGGER.lifecycle("Arguments line set to " + Joiner.on(",").join(argumentLn));
Expand Down Expand Up @@ -100,7 +100,7 @@ private List<String> buildDebugParams() {

if (hasDebug) {
debugArgs.add(0, "-Dappmap.debug.file=" + StringEscapeUtils
.escapeJava(format("%s", appmap.getDebugFile())));
.escapeJava(format("%s", appmap.getDebugFilePath())));
}
}
return debugArgs;
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/com/appland/appmap/gradle/AppMapPluginExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
public class AppMapPluginExtension {

public static final String DEFAULT_OUTPUT_DIRECTORY = "build/appmap";
public static final String DEFAULT_OUTPUT_DIRECTORY = "appmap";
protected final Project project;
private final Logger logger = Logger.getLogger("com.appland.appmap.gradle");
private final Configuration agentConf;
Expand All @@ -38,11 +38,12 @@ public class AppMapPluginExtension {
public AppMapPluginExtension(Project project, Configuration agentConf) {
this.project = project;
this.agentConf = agentConf;
this.configFile = project.getObjects().fileProperty().fileValue(new File("appmap.yml"));
this.configFile = project.getObjects().fileProperty()
.value(project.getLayout().getProjectDirectory().file("appmap.yml"));
this.outputDirectory = project.getObjects().directoryProperty()
.fileValue(new File(DEFAULT_OUTPUT_DIRECTORY));
.value(project.getLayout().getBuildDirectory().dir(DEFAULT_OUTPUT_DIRECTORY).get());
this.debugFile = project.getObjects().fileProperty()
.fileValue(new File("build/appmap/agent.log"));
.value(project.getLayout().getBuildDirectory().file("appmap/agent.log").get());
logger.info("AppMap Plugin Initialized.");
}

Expand Down Expand Up @@ -71,6 +72,10 @@ public RegularFileProperty getDebugFile() {
return debugFile;
}

public String getDebugFilePath() {
return debugFile.getAsFile().get().getAbsolutePath();
}

public void setDebugFile(RegularFileProperty debugFile) {
this.debugFile = debugFile;
}
Expand All @@ -87,14 +92,18 @@ public DirectoryProperty getOutputDirectory() {
return outputDirectory;
}

public String getOutputDirectoryAsString() {
return outputDirectory.toString();
public String getOutputDirectoryPath() {
return outputDirectory.getAsFile().get().getAbsolutePath();
}

public RegularFileProperty getConfigFile() {
return configFile;
}

public String getConfigFilePath() {
return configFile.getAsFile().get().getAbsolutePath();
}

public void setConfigFile(RegularFileProperty configFile) {
this.configFile = configFile;
}
Expand Down

0 comments on commit 5fad30c

Please sign in to comment.