org.gradle.api.tasks.JavaExec Java Examples

The following examples show how to use org.gradle.api.tasks.JavaExec. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JigsawPlugin.java    From gradle-java-modules with Apache License 2.0 6 votes vote down vote up
private void configureRunTask(final Project project) {
    final JavaExec run = (JavaExec) project.getTasks().findByName(ApplicationPlugin.TASK_RUN_NAME);
    final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME);
    run.getInputs().property("moduleName", module.geName());
    run.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            List<String> args = new ArrayList<>();
            args.add("--module-path");
            args.add(run.getClasspath().getAsPath());
            args.add("--module");
            args.add(module.geName() + "/" + run.getMain());
            run.setJvmArgs(args);
            run.setClasspath(project.files());
        }
    });
}
 
Example #2
Source File: NoHttpCliPlugin.java    From nohttp with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
	this.project = project;
	this.extension = (NoHttpExtension) this.project.getExtensions().getByName(NOHTTP_EXTENSION_NAME);

	Configuration nohttpCli = this.project.getConfigurations().create("nohttp-cli");
	configureDefaultDependenciesForProject(nohttpCli);

	JavaExec nohttp = project.getTasks().create("nohttp", JavaExec.class);
	nohttp.setDescription("Runs nohttp");

	nohttp.setMain("io.spring.nohttp.cli.NoHttpCliMain");
	nohttp.setClasspath(nohttpCli);
}
 
Example #3
Source File: ModularJavaExec.java    From gradle-modules-plugin with MIT License 5 votes vote down vote up
@Override
public JavaExec jvmArgs(Object... arguments) {
    for (Object arg : arguments) {
        ownJvmArgs.add(String.valueOf(arg));
    }
    return super.jvmArgs(arguments);
}
 
Example #4
Source File: ModularJavaExec.java    From gradle-modules-plugin with MIT License 5 votes vote down vote up
@Override
public JavaExec setMain(String mainClassName) {
    if(GradleVersion.current().compareTo(GradleVersion.version("6.4")) >= 0) {
        getMainClass().set(stripModule(mainClassName));
    } else {
        super.setMain(mainClassName);
    }
    return this;
}
 
Example #5
Source File: ExecTask.java    From javafx-gradle-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Inject
public ExecTask(Project project) {
    this.project = project;
    project.getPluginManager().withPlugin(ApplicationPlugin.APPLICATION_PLUGIN_NAME, e -> {
        execTask = (JavaExec) project.getTasks().findByName(ApplicationPlugin.TASK_RUN_NAME);
        if (execTask != null) {
            execTask.dependsOn(this);
        } else {
            throw new GradleException("Run task not found.");
        }
    });
}
 
Example #6
Source File: BootPlugin.java    From purplejs with Apache License 2.0 5 votes vote down vote up
private void configureAppPlugin()
{
    final ApplicationPluginConvention convention = this.project.getConvention().findPlugin( ApplicationPluginConvention.class );
    convention.setMainClassName( "io.purplejs.boot.MainApp" );

    final JavaExec runTask = (JavaExec) this.project.getTasks().getByName( ApplicationPlugin.TASK_RUN_NAME );
    runTask.systemProperty( "io.purplejs.runMode", "dev" );

    final String devDirs = new File( this.project.getProjectDir(), "src/main/resources" ).getAbsolutePath();
    runTask.systemProperty( "io.purplejs.devSourceDirs", devDirs );
}
 
Example #7
Source File: GradleJavaExec.java    From juniversal with MIT License 5 votes vote down vote up
public GradleJavaExec(Project project, String name, File executableJar) {
    javaExec = project.getTasks().create(name, JavaExec.class);

    javaExec.setWorkingDir(project.getProjectDir());

    // Because JavaExec doesn't have proper support for exec'ing runnable jars, use this hack,
    // saying the main class is "-jar", to make it work
    javaExec.setMain("-jar");
    javaExec.args(executableJar.getAbsolutePath());
}
 
Example #8
Source File: StartScriptsMutator.java    From gradle-modules-plugin with MIT License 4 votes vote down vote up
public StartScriptsMutator(JavaExec execTask, Project project) {
    super(execTask, project);
}
 
Example #9
Source File: RunTask.java    From gradle-modules-plugin with MIT License 4 votes vote down vote up
private JavaExec getRunTask() {
    return helper().task(ApplicationPlugin.TASK_RUN_NAME, JavaExec.class);
}
 
Example #10
Source File: RunTaskMutator.java    From gradle-modules-plugin with MIT License 4 votes vote down vote up
public RunTaskMutator(JavaExec execTask, Project project) {
    super(execTask, project);
}
 
Example #11
Source File: ModularJavaExec.java    From gradle-modules-plugin with MIT License 4 votes vote down vote up
@Override
public JavaExec jvmArgs(Iterable<?> arguments) {
    arguments.forEach(arg -> ownJvmArgs.add(String.valueOf(arg)));
    return super.jvmArgs(arguments);
}
 
Example #12
Source File: AbstractExecutionMutator.java    From gradle-modules-plugin with MIT License 4 votes vote down vote up
AbstractExecutionMutator(JavaExec execTask, Project project) {
    this.execTask = execTask;
    this.project = project;
}
 
Example #13
Source File: RhinoShellExec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public JavaExec setArgs(Iterable<?> applicationArgs) {
    throw argsUnsupportOperationException();
}
 
Example #14
Source File: RhinoShellExec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public JavaExec setArgs(Iterable<?> applicationArgs) {
    throw argsUnsupportOperationException();
}
 
Example #15
Source File: RhinoShellExec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public JavaExec setArgs(Iterable<?> applicationArgs) {
    throw argsUnsupportOperationException();
}
 
Example #16
Source File: RhinoShellExec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public JavaExec setArgs(Iterable<?> applicationArgs) {
    throw argsUnsupportOperationException();
}