All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.thundra.plugin.gradle.ThundraExtension Maven / Gradle / Ivy

The newest version!
package io.thundra.plugin.gradle;

import org.gradle.api.GradleException;
import org.gradle.api.Task;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import org.gradle.process.JavaForkOptions;

/**
 * @author tolgatakir
 */
public class ThundraExtension {
    private static final Logger LOGGER = Logging.getLogger(ThundraExtension.class);
    private String agentPath;

    public ThundraExtension() {

    }

    public String getAgentPath() {
        return agentPath;
    }

    public void setAgentPath(String agentPath) {
        this.agentPath = agentPath;
    }

    public  void apply(T task) {
        if (this.getAgentPath() != null && !this.getAgentPath().isEmpty()) {
            LOGGER.debug("Add Thundra Java agent " + this.getAgentPath() + " to " + task.getName());
            task.jvmArgs(getJvmArgs());
        } else {
            throw new GradleException("Thundra Agent path is null or empty.");
        }
    }

    private String getJvmArgs() {
        try {
            return "-javaagent:" + this.getAgentPath();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy