本文整理汇总了Java中org.gradle.api.invocation.Gradle类的典型用法代码示例。如果您正苦于以下问题:Java Gradle类的具体用法?Java Gradle怎么用?Java Gradle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Gradle类属于org.gradle.api.invocation包,在下文中一共展示了Gradle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onApply
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
@Override
protected void onApply(Project project) {
getLifecycleTask().setDescription("Generates all Eclipse files.");
getCleanTask().setDescription("Cleans all Eclipse files.");
EclipseModel model = project.getExtensions().create("eclipse", EclipseModel.class);
configureEclipseProject(project, model);
configureEclipseJdt(project, model);
configureEclipseClasspath(project, model);
postProcess("eclipse", new Action<Gradle>() {
@Override
public void execute(Gradle gradle) {
performPostEvaluationActions();
}
});
applyEclipseWtpPluginOnWebProjects(project);
}
示例2: convert
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
private DefaultGradleBuild convert(Gradle gradle) {
DefaultGradleBuild model = new DefaultGradleBuild();
Map<Project, BasicGradleProject> convertedProjects = new LinkedHashMap<Project, BasicGradleProject>();
Project rootProject = gradle.getRootProject();
BasicGradleProject convertedRootProject = convert(rootProject, convertedProjects);
model.setRootProject(convertedRootProject);
for (Project project : rootProject.getAllprojects()) {
model.addProject(convertedProjects.get(project));
}
for (IncludedBuild includedBuild : gradle.getIncludedBuilds()) {
Gradle includedGradle = ((IncludedBuildInternal) includedBuild).getConfiguredBuild();
DefaultGradleBuild convertedIncludedBuild = convert(includedGradle);
model.addIncludedBuild(convertedIncludedBuild);
}
return model;
}
示例3: onApply
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
@Override
protected void onApply(Project project) {
getLifecycleTask().setDescription("Generates IDEA project files (IML, IPR, IWS)");
getCleanTask().setDescription("Cleans IDEA project files (IML, IPR)");
ideaModel = project.getExtensions().create("idea", IdeaModel.class);
configureIdeaWorkspace(project);
configureIdeaProject(project);
configureIdeaModule(project);
configureForJavaPlugin(project);
configureForScalaPlugin();
postProcess("idea", new Action<Gradle>() {
@Override
public void execute(Gradle gradle) {
performPostEvaluationActions();
}
});
}
示例4: getRootDirectory
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
@Override
public File getRootDirectory(@Nullable Object scope) {
if (scope == null) {
return globalCacheDir;
}
if (scope instanceof Gradle) {
Gradle gradle = (Gradle) scope;
return getBuildCacheDir(gradle.getRootProject());
}
if (scope instanceof Project) {
Project project = (Project) scope;
return getBuildCacheDir(project.getRootProject());
}
if (scope instanceof Task) {
Task task = (Task) scope;
return getBuildCacheDir(task.getProject().getRootProject());
}
throw new IllegalArgumentException(String.format("Don't know how to determine the cache directory for scope of type %s.", scope.getClass().getSimpleName()));
}
示例5: apply
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
/**
* @see org.gradle.api.Plugin#apply(java.lang.Object)
*/
@Override
public void apply(Project project) {
this.project = project;
if (VersionNumber.parse(project.getGradle().getGradleVersion()).compareTo(MIN_GRADLE_VERSION) < 0) {
throw new GradleException(format("Base project plugin requires Gradle %s or higher", MIN_GRADLE_VERSION));
}
getLogger().info("Applying plugin {} to {}", this, getProject());
initialize();
getProject().afterEvaluate(p -> configure());
getProject().getGradle().addBuildListener(new BuildAdapter() {
@Override
public void projectsEvaluated(@Nullable Gradle gradle) {
complete();
}
});
}
示例6: DefaultGradle
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
public DefaultGradle(Gradle parent, StartParameter startParameter, ServiceRegistryFactory parentRegistry) {
this.parent = parent;
this.startParameter = startParameter;
this.services = parentRegistry.createFor(this);
this.listenerManager = services.get(ListenerManager.class);
taskGraph = services.get(TaskGraphExecuter.class);
distributionLocator = services.get(GradleDistributionLocator.class);
classLoaderScope = services.get(ClassLoaderScopeRegistry.class).getCoreAndPluginsScope();
pluginContainer = services.get(PluginContainer.class);
fileResolver = services.get(FileResolver.class);
scriptPluginFactory = services.get(ScriptPluginFactory.class);
scriptHandlerFactory = services.get(ScriptHandlerFactory.class);
buildListenerBroadcast = listenerManager.createAnonymousBroadcaster(BuildListener.class);
projectEvaluationListenerBroadcast = listenerManager.createAnonymousBroadcaster(ProjectEvaluationListener.class);
buildListenerBroadcast.add(new BuildAdapter() {
@Override
public void projectsLoaded(Gradle gradle) {
rootProjectActions.execute(rootProject);
rootProjectActions = null;
}
});
}
示例7: getBaseDirectory
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
public File getBaseDirectory(Object scope, String key, CacheBuilder.VersionStrategy versionStrategy) {
if (key.equalsIgnoreCase("projects") || key.equalsIgnoreCase("tasks") || !key.matches("\\p{Alpha}+[-//.\\w]*")) {
throw new IllegalArgumentException(String.format("Unsupported cache key '%s'.", key));
}
if (scope == null) {
return getCacheDir(globalCacheDir, versionStrategy, key);
}
if (scope instanceof Gradle) {
Gradle gradle = (Gradle) scope;
return getCacheDir(getBuildCacheDir(gradle.getRootProject()), versionStrategy, key);
}
if (scope instanceof Project) {
Project project = (Project) scope;
return getCacheDir(getBuildCacheDir(project.getRootProject()), versionStrategy, String.format("projects/%s/%s", project.getPath().replace(':', '_'), key));
}
if (scope instanceof Task) {
Task task = (Task) scope;
return getCacheDir(getBuildCacheDir(task.getProject().getRootProject()), versionStrategy, String.format("tasks/%s/%s", task.getPath().replace(':', '_'), key));
}
throw new IllegalArgumentException(String.format("Don't know how to determine the cache directory for scope of type %s.", scope.getClass().getSimpleName()));
}
示例8: DefaultGradle
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
public DefaultGradle(Gradle parent, StartParameter startParameter, ServiceRegistryFactory parentRegistry) {
this.parent = parent;
this.startParameter = startParameter;
this.services = parentRegistry.createFor(this);
this.listenerManager = services.get(ListenerManager.class);
taskGraph = services.get(TaskGraphExecuter.class);
distributionLocator = services.get(GradleDistributionLocator.class);
classLoaderScope = services.get(ClassLoaderScope.class);
pluginContainer = services.get(PluginContainer.class);
fileResolver = services.get(FileResolver.class);
scriptPluginFactory = services.get(ScriptPluginFactory.class);
scriptHandlerFactory = services.get(ScriptHandlerFactory.class);
buildListenerBroadcast = listenerManager.createAnonymousBroadcaster(BuildListener.class);
projectEvaluationListenerBroadcast = listenerManager.createAnonymousBroadcaster(ProjectEvaluationListener.class);
buildListenerBroadcast.add(new BuildAdapter() {
@Override
public void projectsLoaded(Gradle gradle) {
rootProjectActions.execute(rootProject);
rootProjectActions = null;
}
});
}
示例9: configureScalaCompile
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
private static void configureScalaCompile(final Project project, JavaBasePlugin javaPlugin, final SourceSet sourceSet) {
String taskName = sourceSet.getCompileTaskName("scala");
final ScalaCompile scalaCompile = project.getTasks().create(taskName, ScalaCompile.class);
scalaCompile.dependsOn(sourceSet.getCompileJavaTaskName());
javaPlugin.configureForSourceSet(sourceSet, scalaCompile);
Convention scalaConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
ScalaSourceSet scalaSourceSet = scalaConvention.findPlugin(ScalaSourceSet.class);
scalaCompile.setDescription("Compiles the " + scalaSourceSet.getScala() + ".");
scalaCompile.setSource(scalaSourceSet.getScala());
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(taskName);
// cannot use convention mapping because the resulting object won't be serializable
// cannot compute at task execution time because we need association with source set
project.getGradle().addBuildListener(new BuildAdapter() {
@Override
public void projectsEvaluated(Gradle gradle) {
IncrementalCompileOptions incrementalOptions = scalaCompile.getScalaCompileOptions().getIncrementalOptions();
if (incrementalOptions.getAnalysisFile() == null) {
String analysisFilePath = project.getBuildDir().getPath() + "/tmp/scala/compilerAnalysis/" + scalaCompile.getName() + ".analysis";
incrementalOptions.setAnalysisFile(new File(analysisFilePath));
}
if (incrementalOptions.getPublishedCode() == null) {
Jar jarTask = (Jar) project.getTasks().findByName(sourceSet.getJarTaskName());
incrementalOptions.setPublishedCode(jarTask == null ? null : jarTask.getArchivePath());
}
}
});
}
示例10: invokeExecuteGradleClient
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
/**
* This starts a gradle client for doing regular execution of a command. It expects the port number to set as a system property. Note: this is using gradle to find the port. See getPort().
*
* @param gradle the gradle object.
*/
public static void invokeExecuteGradleClient(Gradle gradle) {
Integer port = getPort(gradle);
if (port == null) {
return;
}
ExecuteGradleCommandClientProtocol protocol = new ExecuteGradleCommandClientProtocol(gradle);
GradleClient client = new GradleClient();
client.start(protocol, port);
}
示例11: getPort
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
/**
* This gets the port out of the start parameters. Why? Because this is meant to be run from the init script and the system properties haven't been set yet. That is due to how gradle is run from
* the bat file/shell script. It has to manually set the java system properties (-D). I don't this is a desired side-effect.
*
* @param gradle the gradle object
* @return an integer or null if we didn't get the port.
*/
private static Integer getPort(Gradle gradle) {
String portText = gradle.getStartParameter().getSystemPropertiesArgs().get(ProtocolConstants.PORT_NUMBER_SYSTEM_PROPERTY);
if (portText == null) {
LOGGER.error("Failed to set " + ProtocolConstants.PORT_NUMBER_SYSTEM_PROPERTY + " system property");
return null;
}
try {
return Integer.parseInt(portText);
} catch (NumberFormatException e) {
LOGGER.error("Invalid " + ProtocolConstants.PORT_NUMBER_SYSTEM_PROPERTY + " system property", e);
return null;
}
}
示例12: invokeTaskListGradleClient
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
/**
* This starts a gradle client that sends a task list back to the server. It expects the port number to set as a system property. You probably should be executing the "tasks" command. Note: this
* is using gradle to find the port. See getPort().
*
* @param gradle the gradle launcher object.
*/
public static void invokeTaskListGradleClient(Gradle gradle) {
Integer port = getPort(gradle);
if (port == null) {
return;
}
TaskListClientProtocol protocol = new TaskListClientProtocol(gradle);
GradleClient client = new GradleClient();
client.start(protocol, port);
}
示例13: GradleBuildComparison
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
public GradleBuildComparison(
ComparableGradleBuildExecuter sourceBuildExecuter,
ComparableGradleBuildExecuter targetBuildExecuter,
Logger logger,
ProgressLogger progressLogger,
Gradle gradle) {
this.sourceBuildExecuter = sourceBuildExecuter;
this.targetBuildExecuter = targetBuildExecuter;
this.logger = logger;
this.progressLogger = progressLogger;
this.gradle = gradle;
}
示例14: configureScalaDependencies
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
private static void configureScalaDependencies(final Project project, final GenerateEclipseClasspath task) {
project.getPlugins().withType(ScalaBasePlugin.class, new Action<ScalaBasePlugin>() {
@Override
public void execute(ScalaBasePlugin scalaBasePlugin) {
task.getClasspath().containers("org.scala-ide.sdt.launching.SCALA_CONTAINER");
// exclude the dependencies already provided by SCALA_CONTAINER; prevents problems with Eclipse Scala plugin
project.getGradle().addBuildListener(new BuildAdapter() {
@Override
public void projectsEvaluated(Gradle gradle) {
final List<String> provided = Lists.newArrayList("scala-library", "scala-swing", "scala-dbc");
Predicate<Dependency> dependencyInProvided = new Predicate<Dependency>() {
@Override
public boolean apply(Dependency dependency) {
return provided.contains(dependency.getName());
}
};
List<Dependency> dependencies = Lists.newArrayList(Iterables.filter(Iterables.concat(Iterables.transform(task.getClasspath().getPlusConfigurations(), new Function<Configuration, Iterable<Dependency>>() {
@Override
public Iterable<Dependency> apply(Configuration config) {
return config.getAllDependencies();
}
})), dependencyInProvided));
if (!dependencies.isEmpty()) {
task.getClasspath().getMinusConfigurations().add(project.getConfigurations().detachedConfiguration(dependencies.toArray(new Dependency[0])));
}
}
});
}
});
}
示例15: postProcess
import org.gradle.api.invocation.Gradle; //导入依赖的package包/类
/**
* Executes the provided Action after all projects have been evaluated.
* Action will only be added once per provided key. Any subsequent calls for the same key will be ignored.
* This permits the plugin to be applied in multiple subprojects, with the postprocess action executed once only.
*/
protected void postProcess(String key, final Action<? super Gradle> action) {
Project rootProject = project.getRootProject();
ExtraPropertiesExtension rootExtraProperties = rootProject.getExtensions().getByType(ExtraPropertiesExtension.class);
String extraPropertyName = "org.gradle." + key + ".postprocess.applied";
if (!rootExtraProperties.has(extraPropertyName)) {
project.getGradle().addBuildListener(new BuildAdapter() {
@Override
public void projectsEvaluated(Gradle gradle) {
action.execute(gradle);
}
});
rootExtraProperties.set(extraPropertyName, true);
}
}