本文整理了Java中org.gradle.api.invocation.Gradle.getGradleVersion()
方法的一些代码示例,展示了Gradle.getGradleVersion()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gradle.getGradleVersion()
方法的具体详情如下:
包路径:org.gradle.api.invocation.Gradle
类名称:Gradle
方法名:getGradleVersion
暂无
代码示例来源: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: 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: typelead/gradle-eta
private void checkForValidGradleVersion() {
if (Version.create(project.getGradle().getGradleVersion())
.isBefore(Version.create("4.3"))) {
throw new GradleException("The Eta Gradle Plugin only supports Gradle 4.3+. You can temporarily disable this plugin and update your wrapper script with `./gradlew wrapper --gradle-version 4.7`.");
}
}
代码示例来源:origin: com.carecon.fabric3.gradle/fabric3-plugin-core
public static void checkGradleVersion(Project project, String gradleMinVersion, String gradlePluginName) {
String projectGradleVersion = project.getGradle().getGradleVersion();
if (new VersionComparator().compare(gradleMinVersion, projectGradleVersion) > 0) {
throw new BuildException(String.format(
"Detected Gradle version %s, but %s requires Gradle version %s or higher.",
projectGradleVersion, gradlePluginName, gradleMinVersion), null);
}
}
}
代码示例来源:origin: org.gosu-lang.gosu/gradle-gosu-plugin
@Inject
public GosuCompile() {
VersionNumber gradleVersion = VersionNumber.parse(getProject().getGradle().getGradleVersion());
if(gradleVersion.compareTo(VersionNumber.parse("4.2")) >= 0) {
_compileOptions = getServices().get(ObjectFactory.class).newInstance(CompileOptions.class);
} else {
try {
Constructor ctor = CompileOptions.class.getConstructor();
_compileOptions = (CompileOptions) ctor.newInstance();
} catch (ReflectiveOperationException e) {
throw new GradleException("Unable to apply Gosu plugin", e);
}
}
}
代码示例来源:origin: gradle.plugin.com.banderous.getpack/plugin
@Override
public void apply(Project project) {
project.setBuildDir("getpack/build");
Util.assertGradle3Plus(project.getGradle().getGradleVersion());
project.getTasks().create("installPuppet", InstallPuppet.class);
project.getTasks().create("launchUnity", LaunchUnity.class).dependsOn("installPuppet");
PublishConfig config = PublishConfig.load(project);
ExportPackage.configure(project, config);
CreatePackage.configure(project);
SyncDeps.configure(project);
// Ensure a project config exists.
ProjectConfig.load(project);
}
}
代码示例来源:origin: org.sonarsource.scanner.gradle/sonarqube-gradle-plugin
@TaskAction
public void run() {
Map<String, String> properties = getProperties();
if (properties.isEmpty()) {
LOGGER.warn("Skipping SonarQube analysis: no properties configured, was it skipped in all projects?");
return;
}
if (LOGGER.isDebugEnabled()) {
properties.put("sonar.verbose", "true");
}
if (isSkippedWithProperty(properties)) {
return;
}
EmbeddedScanner scanner = EmbeddedScanner.create("ScannerGradle", getPluginVersion() + "/" + getProject().getGradle().getGradleVersion(), LOG_OUTPUT)
.addGlobalProperties(properties);
scanner.start();
scanner.execute(new HashMap<>());
}
代码示例来源:origin: SonarSource/sonar-scanner-gradle
@TaskAction
public void run() {
Map<String, String> properties = getProperties();
if (properties.isEmpty()) {
LOGGER.warn("Skipping SonarQube analysis: no properties configured, was it skipped in all projects?");
return;
}
if (LOGGER.isDebugEnabled()) {
properties.put("sonar.verbose", "true");
}
if (isSkippedWithProperty(properties)) {
return;
}
EmbeddedScanner scanner = EmbeddedScanner.create("ScannerGradle", getPluginVersion() + "/" + getProject().getGradle().getGradleVersion(), LOG_OUTPUT)
.addGlobalProperties(properties);
scanner.start();
scanner.execute(new HashMap<>());
}
代码示例来源:origin: gradle.plugin.com.github.gradle-guides/gradle-site-plugin
private ProjectDescriptor deriveProjectDescription(Project project) {
ProjectDescriptor projectDescriptor = new ProjectDescriptor(project.getName(), project.getGroup().toString(), project.getDescription(), project.getVersion().toString(), new EnvironmentDescriptor(project.getGradle().getGradleVersion()));
addPluginDescription(project, projectDescriptor);
addTasksDescription(project, projectDescriptor);
addJavaDescription(project, projectDescriptor);
return projectDescriptor;
}
代码示例来源:origin: MinecraftForge/ForgeGradle
List<String> split = Splitter.on('.').splitToList(project.getGradle().getGradleVersion());
代码示例来源: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: 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: org.gosu-lang.gosu/gradle-gosu-plugin
/**
* Create and configure default compileGosu and compileTestGosu tasks
* Gradle 4.0+: call local equivalent of o.g.a.p.i.SourceSetUtil.configureForSourceSet(sourceSet, gosuSourceSet.getGosu(), gosuCompile, _project)
* Gradle 2.x, 3.x: call javaPlugin.configureForSourceSet(sourceSet, gosuCompile);
*/
private void configureGosuCompile(JavaBasePlugin javaPlugin, SourceSet sourceSet, GosuSourceSet gosuSourceSet) {
String compileTaskName = sourceSet.getCompileTaskName("gosu");
GosuCompile gosuCompile = _project.getTasks().create(compileTaskName, GosuCompile.class);
VersionNumber gradleVersion = VersionNumber.parse(_project.getGradle().getGradleVersion());
if(gradleVersion.compareTo(VersionNumber.parse("4.0")) >= 0) {
//Gradle 4.0+
configureForSourceSet(sourceSet, gosuSourceSet.getGosu(), gosuCompile, _project);
} else {
javaPlugin.configureForSourceSet(sourceSet, gosuCompile);
gosuCompile.setDescription("Compiles the " + gosuSourceSet.getGosu() + ".");
}
gosuCompile.dependsOn(sourceSet.getCompileJavaTaskName());
gosuCompile.setSource((Object) gosuSourceSet.getGosu()); // Gradle 4.0 overloads setSource; must upcast to Object for backwards compatibility
_project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName);
}
代码示例来源: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));
}
内容来源于网络,如有侵权,请联系作者删除!