use of org.gradle.util.VersionNumber in project gradle by gradle.
the class DefaultUcrtLocator method locateUcrtsInRegistry.
private void locateUcrtsInRegistry(String baseKey) {
String[] keys = { REGISTRY_KIT_10 };
for (String key : keys) {
try {
File ucrtDir = FileUtils.canonicalize(new File(windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, baseKey + REGISTRY_ROOTPATH_KIT, key)));
String[] versionDirs = getUcrtVersionDirs(ucrtDir);
if (versionDirs.length > 0) {
for (String versionDir : versionDirs) {
VersionNumber version = VersionNumber.withPatchNumber().parse(versionDir);
LOGGER.debug("Found ucrt {} at {}", version.toString(), ucrtDir);
putUcrt(new Ucrt(ucrtDir, NAME_KIT + " " + version.getMajor(), version));
}
} else {
LOGGER.debug("Ignoring candidate ucrt directory {} as it does not look like a ucrt installation.", ucrtDir);
}
} catch (MissingRegistryEntryException e) {
// Ignore the version if the string cannot be read
}
}
}
use of org.gradle.util.VersionNumber in project gradle by gradle.
the class GccVersionDeterminer method transform.
private GccVersionResult transform(String output, File gccBinary) {
BufferedReader reader = new BufferedReader(new StringReader(output));
String line;
Map<String, String> defines = new HashMap<String, String>();
try {
while ((line = reader.readLine()) != null) {
Matcher matcher = DEFINE_PATTERN.matcher(line);
if (!matcher.matches()) {
return new BrokenResult(String.format("Could not determine %s version: %s produced unexpected output.", getDescription(), gccBinary.getName()));
}
defines.put(matcher.group(1), matcher.group(2));
}
} catch (IOException e) {
// Should not happen reading from a StringReader
throw new UncheckedIOException(e);
}
if (!defines.containsKey("__GNUC__")) {
return new BrokenResult(String.format("Could not determine %s version: %s produced unexpected output.", getDescription(), gccBinary.getName()));
}
int major;
int minor;
int patch;
if (clang) {
if (!defines.containsKey("__clang__")) {
return new BrokenResult(String.format("%s appears to be GCC rather than Clang. Treating it as GCC.", gccBinary.getName()));
}
major = toInt(defines.get("__clang_major__"));
minor = toInt(defines.get("__clang_minor__"));
patch = toInt(defines.get("__clang_patchlevel__"));
} else {
if (defines.containsKey("__clang__")) {
return new BrokenResult(String.format("XCode %s is a wrapper around Clang. Treating it as Clang and not GCC.", gccBinary.getName()));
}
major = toInt(defines.get("__GNUC__"));
minor = toInt(defines.get("__GNUC_MINOR__"));
patch = toInt(defines.get("__GNUC_PATCHLEVEL__"));
}
final ArchitectureInternal architecture = determineArchitecture(defines);
return new DefaultGccVersionResult(new VersionNumber(major, minor, patch, null), architecture, clang);
}
use of org.gradle.util.VersionNumber in project gradle by gradle.
the class BuildScanConfigManager method collect.
@Override
public BuildScanConfig collect(BuildScanPluginMetadata pluginMetadata) {
if (collected) {
throw new IllegalStateException("Configuration has already been collected.");
}
collected = true;
BuildScanConfig.Attributes configAttributes = this.configAttributes.create();
VersionNumber pluginVersion = VersionNumber.parse(pluginMetadata.getVersion()).getBaseVersion();
String unsupportedReason = compatibility.unsupportedReason(pluginVersion, configAttributes);
if (unsupportedReason != null) {
if (isPluginAwareOfUnsupported(pluginVersion)) {
return requestedness.toConfig(unsupportedReason, configAttributes);
} else {
throw new UnsupportedBuildScanPluginVersionException(unsupportedReason);
}
}
return requestedness.toConfig(null, configAttributes);
}
use of org.gradle.util.VersionNumber in project gradle by gradle.
the class IdeaScalaConfigurer method configure.
public void configure() {
rootProject.getGradle().addBuildListener(new BuildAdapter() {
public void projectsEvaluated(Gradle gradle) {
VersionNumber ideaTargetVersion = findIdeaTargetVersion();
final boolean useScalaSdk = ideaTargetVersion == null || IDEA_VERSION_WHEN_SCALA_SDK_WAS_INTRODUCED.compareTo(ideaTargetVersion) <= 0;
final Collection<Project> scalaProjects = findProjectsApplyingIdeaAndScalaPlugins();
final Map<String, ProjectLibrary> scalaCompilerLibraries = Maps.newLinkedHashMap();
rootProject.getTasks().getByName("ideaProject").doFirst(new Action<Task>() {
@Override
public void execute(Task task) {
if (scalaProjects.size() > 0) {
scalaCompilerLibraries.clear();
scalaCompilerLibraries.putAll(resolveScalaCompilerLibraries(scalaProjects, useScalaSdk));
declareUniqueProjectLibraries(Sets.newLinkedHashSet(scalaCompilerLibraries.values()));
}
}
});
rootProject.configure(scalaProjects, new Action<Project>() {
@Override
public void execute(final Project project) {
project.getExtensions().getByType(IdeaModel.class).getModule().getIml().withXml(new Action<XmlProvider>() {
@Override
public void execute(XmlProvider xmlProvider) {
if (useScalaSdk) {
declareScalaSdk(scalaCompilerLibraries.get(project.getPath()), xmlProvider.asNode());
} else {
declareScalaFacet(scalaCompilerLibraries.get(project.getPath()), xmlProvider.asNode());
}
}
});
}
});
}
});
}
use of org.gradle.util.VersionNumber in project gradle by gradle.
the class GccMetadataProvider method parseCompilerOutput.
@Override
protected GccMetadata parseCompilerOutput(String output, String error, File gccBinary) {
Map<String, String> defines = parseDefines(output, gccBinary);
VersionNumber scrapedVersion = determineVersion(defines, gccBinary);
ArchitectureInternal architecture = determineArchitecture(defines);
String scrapedVendor = determineVendor(error, scrapedVersion, gccBinary);
ImmutableList<File> systemIncludes = determineSystemIncludes(error);
return new DefaultGccMetadata(scrapedVersion, scrapedVendor, architecture, systemIncludes);
}
Aggregations