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 MSBuildVersionLocator method getMSBuildInstall.
public File getMSBuildInstall(AvailableToolChains.InstalledToolChain toolChain) {
VersionNumber vsVersion;
if (toolChain instanceof AvailableToolChains.InstalledVisualCpp) {
AvailableToolChains.InstalledVisualCpp visualCpp = (AvailableToolChains.InstalledVisualCpp) toolChain;
vsVersion = visualCpp.getVersion();
} else {
vsVersion = VersionNumber.version(15);
}
File vswhere = vswhereLocator.getVswhereInstall();
if (vswhere == null) {
throw new IllegalStateException("vswhere tool is required to be installed");
}
ExecOutput vsWhereOutput = new TestFile(vswhere).exec("-version", String.format("[%s.0,%s.0)", vsVersion.getMajor(), vsVersion.getMajor() + 1), "-products", "*", "-requires", "Microsoft.Component.MSBuild", "-property", "installationPath");
if (!vsWhereOutput.getError().trim().isEmpty()) {
throw new IllegalStateException(String.format("Could not determine the location of MSBuild %s: %s", vsVersion.getMajor(), vsWhereOutput.getError()));
}
String location = vsWhereOutput.getOut().trim();
TestFile msbuild;
if (!location.isEmpty()) {
msbuild = new TestFile(location).file("MSBuild/" + vsVersion.getMajor() + ".0/Bin/MSBuild.exe");
} else if (vsVersion.getMajor() == 11) {
msbuild = new TestFile("C:/Windows/Microsoft.Net/Framework/v4.0.30319/MSBuild.exe");
} else {
msbuild = new TestFile("C:/program files (x86)/MSBuild/" + vsVersion.getMajor() + ".0/Bin/MSBuild.exe");
}
if (!msbuild.exists()) {
throw new IllegalStateException(String.format("This test requires MSBuild %s to be installed. Expected it to be installed at %s.", vsVersion.getMajor(), msbuild));
}
return msbuild;
}
use of org.gradle.util.VersionNumber in project gradle by gradle.
the class WindowsRegistryVersionLocator method locateInstallsInRegistry.
private void locateInstallsInRegistry(List<VisualStudioInstallCandidate> installs, String baseKey) {
List<String> visualCppVersions;
try {
visualCppVersions = windowsRegistry.getValueNames(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, baseKey + REGISTRY_ROOTPATH_VC);
} catch (MissingRegistryEntryException e) {
// No Visual Studio information available in the registry
return;
}
for (String versionString : visualCppVersions) {
if (!versionString.matches("\\d+\\.\\d+")) {
// Ignore the other values
continue;
}
File visualCppDir = new File(windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, baseKey + REGISTRY_ROOTPATH_VC, versionString));
visualCppDir = FileUtils.canonicalize(visualCppDir);
File visualStudioDir = visualCppDir.getParentFile();
VersionNumber version = VersionNumber.parse(versionString);
installs.add(new VisualStudioMetadataBuilder().installDir(visualStudioDir).visualCppDir(visualCppDir).version(version).visualCppVersion(version).build());
}
}
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);
}
use of org.gradle.util.VersionNumber in project gradle by gradle.
the class DefaultVisualStudioLocator method addInstallIfValid.
private boolean addInstallIfValid(VisualStudioInstallCandidate install, String source) {
File visualCppDir = install.getVisualCppDir();
File visualStudioDir = install.getInstallDir();
if (foundInstalls.containsKey(visualStudioDir)) {
return true;
}
if (brokenInstalls.contains(visualStudioDir)) {
return false;
}
if (isValidInstall(install) && install.getVisualCppVersion() != VersionNumber.UNKNOWN) {
LOGGER.debug("Found Visual C++ {} at {}", install.getVisualCppVersion(), visualCppDir);
VersionNumber visualStudioVersion = install.getVersion();
String visualStudioDisplayVersion = install.getVersion() == VersionNumber.UNKNOWN ? "from " + source : install.getVersion().toString();
VisualCppInstall visualCpp = buildVisualCppInstall("Visual C++ " + install.getVisualCppVersion(), visualStudioDir, visualCppDir, install.getVisualCppVersion(), install.getCompatibility());
VisualStudioInstall visualStudio = new VisualStudioInstall("Visual Studio " + visualStudioDisplayVersion, visualStudioDir, visualStudioVersion, visualCpp);
foundInstalls.put(visualStudioDir, visualStudio);
return true;
} else {
LOGGER.debug("Ignoring candidate Visual C++ directory {} as it does not look like a Visual C++ installation.", visualCppDir);
brokenInstalls.add(visualStudioDir);
return false;
}
}
Aggregations