本文整理了Java中org.gradle.api.invocation.Gradle
类的一些代码示例,展示了Gradle
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gradle
类的具体详情如下:
包路径:org.gradle.api.invocation.Gradle
类名称:Gradle
暂无
代码示例来源:origin: jooby-project/jooby
private void configureJoobyRun(final Project project) {
project.getTasks()
.withType(JoobyTask.class, joobyRun -> {
ConventionMapping mapping = joobyRun.getConventionMapping();
mapping.map("classpath", () -> new JoobyProject(project).classpath());
mapping.map("src", () -> new JoobyProject(project).sources());
mapping.map("mainClassName", () -> project.getProperties().get("mainClassName"));
mapping.map("srcExtensions", () -> Arrays.asList(".java", ".conf", ".properties", ".kt"));
mapping.map("compiler", () -> {
File eclipseClasspath = new File(project.getProjectDir(), ".classpath");
return eclipseClasspath.exists() ? "off" : "on";
});
Gradle gradle = project.getGradle();
mapping.map("block", () -> !gradle.getStartParameter().isContinuous());
mapping.map("logLevel", () -> gradle.getStartParameter().getLogLevel().name());
});
Map<String, Object> options = new HashMap<>();
options.put(Task.TASK_TYPE, JoobyTask.class);
options.put(Task.TASK_DEPENDS_ON, "classes");
options.put(Task.TASK_NAME, "joobyRun");
options.put(Task.TASK_DESCRIPTION, "Run, debug and hot reload applications");
options.put(Task.TASK_GROUP, "jooby");
project.getTasks().create(options);
}
代码示例来源:origin: org.gradle/gradle-core
private boolean isRootTaskGraph(TaskExecutionGraph graph) {
return rootGradle != null && graph == rootGradle.getTaskGraph();
}
}
代码示例来源:origin: alipay/sofa-boot
private void unregisterUnresolvedDependenciesAnalyzer(Project project) {
UnresolvedDependenciesAnalyzer unresolvedDependenciesAnalyzer = new UnresolvedDependenciesAnalyzer();
project.getConfigurations().all((configuration) -> {
ResolvableDependencies incoming = configuration.getIncoming();
incoming.afterResolve((resolvableDependencies) -> {
if (incoming.equals(resolvableDependencies)) {
unresolvedDependenciesAnalyzer.analyze(configuration
.getResolvedConfiguration().getLenientConfiguration()
.getUnresolvedModuleDependencies());
}
});
});
project.getGradle().buildFinished(
(buildResult) -> unresolvedDependenciesAnalyzer.buildFinished(project));
}
代码示例来源:origin: jooby-project/jooby
.useInstallation(project.getGradle().getGradleHomeDir())
.forProjectDirectory(project.getRootDir())
.connect();
String[] args = project.getGradle().getStartParameter().getProjectProperties()
.entrySet().stream().map(Object::toString).collect(Collectors.toList())
.toArray(new String[0]);
代码示例来源:origin: com.android.tools.build/gradle-core
&& project.getGradle().getStartParameter().isContinueOnFailure()) {
project.getGradle().getTaskGraph().whenReady(new Closure(this) {
void doCall(TaskGraphExecuter taskGraph) {
if (taskGraph.hasTask(mergeReportsTask)) {
代码示例来源:origin: MinecraftForge/ForgeGradle
List<String> split = Splitter.on('.').splitToList(project.getGradle().getGradleVersion());
File projectCacheDir = project.getGradle().getStartParameter().getProjectCacheDir();
if (projectCacheDir == null)
projectCacheDir = new File(project.getProjectDir(), ".gradle");
project.getLogging().addStandardOutputListener(listener);
project.getLogging().addStandardErrorListener(listener);
project.getGradle().addBuildListener(listener);
代码示例来源:origin: typelead/gradle-eta
project.getGradle().projectsEvaluated(gradle -> {
if (extension.shouldPreInstallDependencies()) {
setupEnvironmentTask.setupEnvironment();
project.getGradle().getTaskGraph().whenReady(graph -> {
List<Task> tasks = graph.getAllTasks();
for (Task task: tasks) {
if (project.getGradle().getStartParameter().getLogLevel().compareTo(LogLevel.QUIET) < 0) {
project.getLogger().warn("WARNING: You are running a REPL task without '-q'. You are missing out on a better REPL experience.");
if (!project.getGradle().getStartParameter().getConsoleOutput().equals(ConsoleOutput.Plain)) {
project.getLogger().warn("WARNING: You are running a REPL task without '--console plain'. You are missing out on a better REPL experience.");
代码示例来源:origin: gradle.plugin.com.prezi.pride/gradle-pride-plugin
private static void checkGradleVersion(Project project) {
Pattern versionPattern = Pattern.compile("(\\d+(?:\\.\\d+)+).*");
String gradleVersion = project.getGradle().getGradleVersion();
Matcher versionMatcher = versionPattern.matcher(gradleVersion);
if (!versionMatcher.matches()) {
throw new GradleException("Invalid Gradle version: " + gradleVersion);
}
if (compareVersions(versionMatcher.group(1), MINIMUM_GRADLE_VERSION) < 0) {
throw new GradleException("Pride requires Gradle version " + MINIMUM_GRADLE_VERSION + " or later. " +
"If you want to use an earlier Gradle version, try Pride 0.10.");
}
}
代码示例来源:origin: com.android.tools.build/gradle-core
/**
* Initialize the {@link ProcessProfileWriterFactory}. Idempotent.
*
* @param project the current Gradle {@link Project}.
*/
public static void init(@NonNull Project project) {
synchronized (LOCK) {
//noinspection VariableNotUsedInsideIf
if (recordingBuildListener != null) {
return;
}
ProcessProfileWriterFactory.initialize(
project.getRootProject().getProjectDir(),
project.getGradle().getGradleVersion(),
new LoggerWrapper(project.getLogger()),
new File(project.getRootProject().getBuildDir(), "android-profile"));
recordingBuildListener = new RecordingBuildListener(ProcessProfileWriter.get());
project.getGradle().addListener(recordingBuildListener);
}
project.getGradle().addListener(new ProfileShutdownListener(project));
}
代码示例来源:origin: me.seeber.gradle/gradle-project-config
/**
* @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();
}
});
}
代码示例来源:origin: MinecraftForge/ForgeGradle
protected File cacheFile(String path)
{
return new File(project.getGradle().getGradleUserHomeDir(), "caches/minecraft/" + path);
}
}
代码示例来源:origin: google/play-services-plugins
@Override
public void apply(@Nonnull Project project) {
// When debugging and testing ensure to look at release dependencies,
// not testing dependencies because of the Android test-app
// de-duplication that happens to produce an Android test app that
// can be run in the same process as the Android App (under test).
project.getGradle().addListener(
new DependencyInspector(globalDependencies, project.getName(),
"This error message came from the strict-version-matcher-plugin Gradle plugin, report" +
" issues at https://github.com/google/play-services-plugins and disable by " +
"removing the reference to the plugin (\"apply 'strict-version-matcher-plugin'\")" +
" from build.gradle."));
}
}
代码示例来源:origin: gradle.plugin.com.palantir/gradle-circle-style
private void configureBuildFailureFinalizer(Project rootProject, String circleReportsDir) {
int attemptNumber = 1;
File targetFile = new File(new File(circleReportsDir, "gradle"), "build.xml");
while (targetFile.exists()) {
targetFile = new File(new File(circleReportsDir, "gradle"), "build" + (++attemptNumber) + ".xml");
}
Integer container;
try {
container = Integer.parseInt(System.getenv("CIRCLE_NODE_INDEX"));
} catch (NumberFormatException e) {
container = null;
}
CircleBuildFailureListener listener = new CircleBuildFailureListener();
CircleBuildFinishedAction action = new CircleBuildFinishedAction(container, targetFile, listener);
rootProject.getGradle().addListener(listener);
rootProject.getGradle().buildFinished(action);
}
代码示例来源:origin: MinecraftForge/ForgeGradle
.useGradleUserHomeDir(gradle.getGradleUserHomeDir())
.useInstallation(gradle.getGradleHomeDir())
.forProjectDirectory(getProjectDir())
.connect();
代码示例来源:origin: com.amazon.device.tools.build/gradle-core
if (!reportTasks.isEmpty() && project.getGradle().getStartParameter()
.isContinueOnFailure()) {
project.getGradle().getTaskGraph().whenReady(new Closure<Void>(this, this) {
public void doCall(TaskExecutionGraph taskGraph) {
for (String reportTask : reportTasks) {
代码示例来源:origin: prezi/pride
private static void checkGradleVersion(Project project) {
Pattern versionPattern = Pattern.compile("(\\d+(?:\\.\\d+)+).*");
String gradleVersion = project.getGradle().getGradleVersion();
Matcher versionMatcher = versionPattern.matcher(gradleVersion);
if (!versionMatcher.matches()) {
throw new GradleException("Invalid Gradle version: " + gradleVersion);
}
if (compareVersions(versionMatcher.group(1), MINIMUM_GRADLE_VERSION) < 0) {
throw new GradleException("Pride requires Gradle version " + MINIMUM_GRADLE_VERSION + " or later. " +
"If you want to use an earlier Gradle version, try Pride 0.10.");
}
}
代码示例来源:origin: gradle.plugin.com.vkscool/web-asset-plugin
public WatchTargetTaskRunner(Project project) {
StartParameter parameter = project.getGradle().getStartParameter();
.useInstallation(project.getGradle().getGradleHomeDir())
.forProjectDirectory(project.getProjectDir())
.connect();
代码示例来源:origin: gradle.plugin.me.seeber.gradle/gradle-project-config
/**
* @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();
}
});
}
代码示例来源:origin: gradle.plugin.de.qaware.seu.as.code/seuac-credentials-plugin
private static File credentialsFile(Project project, CredentialsExtension extension) {
String propertyFile = extension.getPropertyFile();
return (propertyFile != null) ? new File(propertyFile) :
new File(project.getGradle().getGradleUserHomeDir(), DEFAULT_FILENAME);
}
代码示例来源:origin: google/play-services-plugins
@Override
public void apply(@Nonnull Project project) {
// When debugging and testing ensure to look at release dependencies,
// not testing dependencies because of the Android test-app
// de-duplication that happens to produce an Android test app that
// can be run in the same process as the Android App (under test).
project.getGradle().addListener(
new DependencyInspector(globalDependencies, project.getName(),
"This error message came from the strict-version-matcher-plugin Gradle plugin, report" +
" issues at https://github.com/google/play-services-plugins and disable by " +
"removing the reference to the plugin (\"apply 'strict-version-matcher-plugin'\")" +
" from build.gradle."));
}
}
内容来源于网络,如有侵权,请联系作者删除!