use of org.gradle.util.GradleVersion in project intellij-community by JetBrains.
the class GradleExecutionHelper method getGradleVersion.
@Nullable
public static GradleVersion getGradleVersion(@NotNull ProjectConnection connection) {
final BuildEnvironment buildEnvironment = getBuildEnvironment(connection);
GradleVersion gradleVersion = null;
if (buildEnvironment != null) {
gradleVersion = GradleVersion.version(buildEnvironment.getGradle().getGradleVersion());
}
return gradleVersion;
}
use of org.gradle.util.GradleVersion in project gradle by gradle.
the class GradleBuildComparison method createProjectConnection.
private ProjectConnection createProjectConnection(ComparableGradleBuildExecuter executer) {
DefaultGradleConnector connector = (DefaultGradleConnector) GradleConnector.newConnector();
connector.forProjectDirectory(executer.getSpec().getProjectDir());
connector.searchUpwards(false);
File gradleUserHomeDir = gradle.getStartParameter().getGradleUserHomeDir();
if (gradleUserHomeDir != null) {
connector.useGradleUserHomeDir(gradleUserHomeDir);
}
GradleVersion gradleVersion = executer.getGradleVersion();
if (gradleVersion.equals(GradleVersion.current())) {
connector.useInstallation(gradle.getGradleHomeDir());
} else {
connector.useGradleVersion(gradleVersion.getVersion());
}
return connector.connect();
}
use of org.gradle.util.GradleVersion in project meghanada-server by mopemope.
the class GradleProject method parseProject.
@Override
public Project parseProject() throws ProjectParseException {
final ProjectConnection connection = getProjectConnection();
log.info("loading gradle project:{}", new File(this.projectRoot, Project.GRADLE_PROJECT_FILE));
try {
BuildEnvironment env = connection.getModel(BuildEnvironment.class);
String version = env.getGradle().getGradleVersion();
if (isNull(version)) {
version = GradleVersion.current().getVersion();
}
if (nonNull(version)) {
this.gradleVersion = new ComparableVersion(version);
}
final IdeaProject ideaProject = debugTimeItF("get idea project model elapsed={}", () -> connection.getModel(IdeaProject.class));
this.setCompileTarget(ideaProject);
log.trace("load root project path:{}", this.rootProject);
final DomainObjectSet<? extends IdeaModule> modules = ideaProject.getModules();
final List<? extends IdeaModule> mainModules = modules.parallelStream().filter(ideaModule -> {
final org.gradle.tooling.model.GradleProject gradleProject = ideaModule.getGradleProject();
final File moduleProjectRoot = gradleProject.getProjectDirectory();
final String name = ideaModule.getName();
log.trace("find sub-module name {} path {} ", name, moduleProjectRoot);
this.allModules.putIfAbsent(name, moduleProjectRoot);
return moduleProjectRoot.equals(this.getProjectRoot());
}).collect(Collectors.toList());
mainModules.forEach(wrapIOConsumer(this::parseIdeaModule));
// set default output
if (isNull(super.output)) {
String build = Joiner.on(File.separator).join(this.projectRoot, "build", "classes", "main");
if (nonNull(gradleVersion) && gradleVersion.compareTo(new ComparableVersion("4.0")) >= 0) {
build = Joiner.on(File.separator).join(this.projectRoot, "build", "classes", "java", "main");
}
super.output = this.normalize(build);
}
if (isNull(super.testOutput)) {
String build = Joiner.on(File.separator).join(this.projectRoot, "build", "classes", "test");
if (nonNull(gradleVersion) && gradleVersion.compareTo(new ComparableVersion("4.0")) >= 0) {
build = Joiner.on(File.separator).join(this.projectRoot, "build", "classes", "java", "test");
}
super.testOutput = this.normalize(build);
}
return this;
} catch (Exception e) {
throw new ProjectParseException(e);
} finally {
connection.close();
}
}
use of org.gradle.util.GradleVersion in project spring-boot by spring-projects.
the class GradleCompatibilityExtension method provideTestTemplateInvocationContexts.
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
Stream<String> gradleVersions = GRADLE_VERSIONS.stream();
GradleCompatibility gradleCompatibility = AnnotationUtils.findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class).get();
if (StringUtils.hasText(gradleCompatibility.versionsLessThan())) {
GradleVersion upperExclusive = GradleVersion.version(gradleCompatibility.versionsLessThan());
gradleVersions = gradleVersions.filter((version) -> GradleVersion.version(version).compareTo(upperExclusive) < 0);
}
return gradleVersions.flatMap((version) -> {
List<TestTemplateInvocationContext> invocationContexts = new ArrayList<>();
invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, false));
boolean configurationCache = gradleCompatibility.configurationCache();
if (configurationCache) {
invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, true));
}
return invocationContexts.stream();
});
}
use of org.gradle.util.GradleVersion in project gradle by gradle.
the class GradleReleaseNotesPlugin method generateReleaseNotes.
private void generateReleaseNotes(Project project, ProjectLayout layout, TaskContainer tasks, GradleDocumentationExtension extension) {
TaskProvider<RenderMarkdown> releaseNotesMarkdown = tasks.register("releaseNotesMarkdown", RenderMarkdown.class, task -> {
task.setGroup("release notes");
task.setDescription("Generate release notes HTML page from Markdown.");
task.getInputEncoding().convention(Charset.defaultCharset().name());
task.getOutputEncoding().convention(Charset.defaultCharset().name());
task.getMarkdownFile().convention(extension.getReleaseNotes().getMarkdownFile());
task.getDestinationFile().convention(extension.getStagingRoot().file("release-notes/raw.html"));
});
TaskProvider<DecorateReleaseNotes> releaseNotesPostProcess = tasks.register("releaseNotes", DecorateReleaseNotes.class, task -> {
task.setGroup("release notes");
task.setDescription("Transforms generated release notes.");
task.getHtmlFile().convention(releaseNotesMarkdown.flatMap(RenderMarkdown::getDestinationFile));
task.getBaseCssFile().convention(extension.getReleaseNotes().getBaseCssFile());
task.getReleaseNotesCssFile().convention(extension.getReleaseNotes().getReleaseNotesCssFile());
task.getReleaseNotesJavascriptFile().convention(extension.getReleaseNotes().getReleaseNotesJsFile());
task.getJquery().from(extension.getReleaseNotes().getJquery());
ModuleIdentityExtension moduleIdentity = project.getExtensions().getByType(ModuleIdentityExtension.class);
MapProperty<String, String> replacementTokens = task.getReplacementTokens();
replacementTokens.put("version", moduleIdentity.getVersion().map(GradleVersion::getVersion));
replacementTokens.put("baseVersion", moduleIdentity.getVersion().map(v -> v.getBaseVersion().getVersion()));
task.getDestinationFile().convention(extension.getStagingRoot().file("release-notes/release-notes.html"));
});
Configuration jquery = project.getConfigurations().create("jquery", conf -> {
conf.setDescription("JQuery dependencies embedded by release notes.");
});
extension.releaseNotes(releaseNotes -> {
releaseNotes.getMarkdownFile().convention(extension.getSourceRoot().file("release/notes.md"));
releaseNotes.getRenderedDocumentation().convention(releaseNotesPostProcess.flatMap(DecorateReleaseNotes::getDestinationFile));
releaseNotes.getBaseCssFile().convention(extension.getSourceRoot().file("css/base.css"));
releaseNotes.getReleaseNotesCssFile().convention(extension.getSourceRoot().file("css/release-notes.css"));
releaseNotes.getReleaseNotesJsFile().convention(extension.getSourceRoot().file("release/content/script.js"));
releaseNotes.getJquery().from(jquery);
});
}
Aggregations