当前位置: 首页>>代码示例>>Java>>正文


Java JavaExec类代码示例

本文整理汇总了Java中org.gradle.api.tasks.JavaExec的典型用法代码示例。如果您正苦于以下问题:Java JavaExec类的具体用法?Java JavaExec怎么用?Java JavaExec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaExec类属于org.gradle.api.tasks包,在下文中一共展示了JavaExec类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addRunTask

import org.gradle.api.tasks.JavaExec; //导入依赖的package包/类
private void addRunTask() {
    JavaExec run = project.getTasks().create(TASK_RUN_NAME, JavaExec.class);
    run.setDescription("Runs this project as a JVM application");
    run.setGroup(APPLICATION_GROUP);

    JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    run.setClasspath(javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath());
    run.getConventionMapping().map("main", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            return pluginConvention.getMainClassName();
        }
    });
    run.getConventionMapping().map("jvmArgs", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            return pluginConvention.getApplicationDefaultJvmArgs();
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:ApplicationPlugin.java

示例2: configureRunTask

import org.gradle.api.tasks.JavaExec; //导入依赖的package包/类
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());
        }
    });
}
 
开发者ID:gradle,项目名称:gradle-java-modules,代码行数:18,代码来源:JigsawPlugin.java

示例3: mainClassNameFinder

import org.gradle.api.tasks.JavaExec; //导入依赖的package包/类
private void mainClassNameFinder(Project project) {
	FindMainClassTask findMainClassTask = project.getTasks()
			.create(FIND_MAIN_CLASS_TASK_NAME, FindMainClassTask.class);
	SourceSet mainSourceSet = SourceSets.findMainSourceSet(project);
	if (mainSourceSet != null) {
		findMainClassTask.setMainClassSourceSetOutput(mainSourceSet.getOutput());
	}
	project.getTasks().all(new Action<Task>() {
		@Override
		public void execute(Task task) {
			if (task instanceof JavaExec || task instanceof CreateStartScripts) {
				task.dependsOn(FIND_MAIN_CLASS_TASK_NAME);
			}
		}
	});
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:RunPluginFeatures.java

示例4: fromLocalClassloader

import org.gradle.api.tasks.JavaExec; //导入依赖的package包/类
static FileCollection fromLocalClassloader() {
	Set<File> files = new LinkedHashSet<>();
	Consumer<Class<?>> addPeerClasses = clazz -> {
		URLClassLoader urlClassloader = (URLClassLoader) clazz.getClassLoader();
		for (URL url : urlClassloader.getURLs()) {
			String name = url.getFile();
			if (name != null) {
				files.add(new File(name));
			}
		}
	};
	// add the classes that goomph needs
	addPeerClasses.accept(JavaExecable.class);
	// add the gradle API
	addPeerClasses.accept(JavaExec.class);

	return new SimpleFileCollection(files);
}
 
开发者ID:diffplug,项目名称:goomph,代码行数:19,代码来源:JavaExecableImp.java

示例5: addAgent

import org.gradle.api.tasks.JavaExec; //导入依赖的package包/类
private void addAgent(Project project, JavaExec exec) {
	project.getLogger().debug("Attaching to: " + exec);
	if (this.agent != null) {
		project.getLogger().info("Attaching agent: " + this.agent);
		exec.jvmArgs("-javaagent:" + this.agent.getAbsolutePath());
		if (this.noverify != null && this.noverify) {
			exec.jvmArgs("-noverify");
		}
		Iterable<?> defaultJvmArgs = exec.getConventionMapping()
				.getConventionValue(null, "jvmArgs", false);
		if (defaultJvmArgs != null) {
			exec.jvmArgs(defaultJvmArgs);
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:16,代码来源:AgentTasksEnhancer.java

示例6: findRunTask

import org.gradle.api.tasks.JavaExec; //导入依赖的package包/类
private JavaExec findRunTask(Project project) {
	Task runTask = project.getTasks().findByName("run");
	if (runTask instanceof JavaExec) {
		return (JavaExec) runTask;
	}
	return null;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:FindMainClassTask.java

示例7: configureAppPlugin

import org.gradle.api.tasks.JavaExec; //导入依赖的package包/类
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 );
}
 
开发者ID:purplejs,项目名称:purplejs,代码行数:12,代码来源:BootPlugin.java

示例8: GradleJavaExec

import org.gradle.api.tasks.JavaExec; //导入依赖的package包/类
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());
}
 
开发者ID:juniversal,项目名称:juniversal,代码行数:11,代码来源:GradleJavaExec.java

示例9: setArgs

import org.gradle.api.tasks.JavaExec; //导入依赖的package包/类
@Override
public JavaExec setArgs(Iterable<?> applicationArgs) {
    throw argsUnsupportOperationException();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:5,代码来源:RhinoShellExec.java

示例10: findMainClass

import org.gradle.api.tasks.JavaExec; //导入依赖的package包/类
private String findMainClass() {
	Project project = getProject();

	String mainClass = null;

	// Try the SpringBoot extension setting
	SpringBootPluginExtension bootExtension = project.getExtensions()
			.getByType(SpringBootPluginExtension.class);
	if (bootExtension.getMainClass() != null) {
		mainClass = bootExtension.getMainClass();
	}

	ApplicationPluginConvention application = (ApplicationPluginConvention) project
			.getConvention().getPlugins().get("application");

	if (mainClass == null && application != null) {
		// Try the Application extension setting
		mainClass = application.getMainClassName();
	}

	JavaExec runTask = findRunTask(project);
	if (mainClass == null && runTask != null) {
		mainClass = runTask.getMain();
	}

	if (mainClass == null) {
		Task bootRunTask = project.getTasks().findByName("bootRun");
		if (bootRunTask != null) {
			mainClass = (String) bootRunTask.property("main");
		}
	}

	if (mainClass == null) {
		// Search
		if (this.mainClassSourceSetOutput != null) {
			project.getLogger().debug("Looking for main in: "
					+ this.mainClassSourceSetOutput.getClassesDir());
			try {
				mainClass = MainClassFinder.findSingleMainClass(
						this.mainClassSourceSetOutput.getClassesDir());
				project.getLogger().info("Computed main class: " + mainClass);
			}
			catch (IOException ex) {
				throw new IllegalStateException("Cannot find main class", ex);
			}
		}
	}

	project.getLogger().info("Found main: " + mainClass);

	if (bootExtension.getMainClass() == null) {
		bootExtension.setMainClass(mainClass);
	}
	if (application != null && application.getMainClassName() == null) {
		application.setMainClassName(mainClass);
	}
	if (runTask != null && !runTask.hasProperty("main")) {
		runTask.setMain(mainClass);
	}

	return mainClass;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:63,代码来源:FindMainClassTask.java


注:本文中的org.gradle.api.tasks.JavaExec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。