use of org.gradle.util.VersionNumber in project gradle by gradle.
the class GroovySystemLoaderFactory method forClassLoader.
public GroovySystemLoader forClassLoader(ClassLoader classLoader) {
try {
Class<?> groovySystem;
try {
groovySystem = classLoader.loadClass("groovy.lang.GroovySystem");
} catch (ClassNotFoundException e) {
// Not a Groovy implementation, or not an implementation that we need to deal with
return NOT_BROKEN;
}
if (groovySystem.getClassLoader() != classLoader) {
// Groovy implementation visible from somewhere else
return NOT_BROKEN;
}
String versionString;
try {
Method getVersion = groovySystem.getDeclaredMethod("getVersion");
versionString = (String) getVersion.invoke(null);
} catch (NoSuchMethodException ex) {
return NOT_BROKEN;
}
VersionNumber groovyVersion = VersionNumber.parse(versionString);
boolean isFaultyGroovy = groovyVersion.getMajor() == 2 && groovyVersion.getMinor() == 4;
return isFaultyGroovy ? new LeakyOnJava7GroovySystemLoader(classLoader) : NOT_BROKEN;
} catch (Exception e) {
throw new GradleException("Could not inspect the Groovy system for ClassLoader " + classLoader, e);
}
}
use of org.gradle.util.VersionNumber in project gradle by gradle.
the class DefaultUcrtLocator method locateUserSpecifiedUcrt.
private SearchResult locateUserSpecifiedUcrt(File candidate) {
File ucrtDir = FileUtils.canonicalize(candidate);
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(), versionDir, ucrtDir);
if (!foundUcrts.containsKey(ucrtDir)) {
putUcrt(new Ucrt(ucrtDir, NAME_USER, version));
}
}
return new UcrtFound(getBestUcrt(candidate));
} else {
return new UcrtNotFound(String.format("The specified installation directory '%s' does not appear to contain a ucrt installation.", candidate));
}
}
use of org.gradle.util.VersionNumber in project gradle by gradle.
the class DefaultVisualStudioLocator method locateInstallsInRegistry.
private void locateInstallsInRegistry(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 valueName : visualCppVersions) {
if (!valueName.matches("\\d+\\.\\d+")) {
// Ignore the other values
continue;
}
File visualCppDir = new File(windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, baseKey + REGISTRY_ROOTPATH_VC, valueName));
visualCppDir = FileUtils.canonicalize(visualCppDir);
File visualStudioDir = visualCppDir.getParentFile();
if (isVisualCpp(visualCppDir) && isVisualStudio(visualStudioDir)) {
LOGGER.debug("Found Visual C++ {} at {}", valueName, visualCppDir);
VersionNumber version = VersionNumber.parse(valueName);
VisualCppInstall visualCpp = buildVisualCppInstall("Visual C++ " + valueName, visualStudioDir, visualCppDir, version);
VisualStudioInstall visualStudio = new VisualStudioInstall(visualStudioDir, visualCpp);
foundInstalls.put(visualStudioDir, visualStudio);
} else {
LOGGER.debug("Ignoring candidate Visual C++ directory {} as it does not look like a Visual C++ installation.", visualCppDir);
}
}
}
use of org.gradle.util.VersionNumber in project gradle by gradle.
the class AntGroovydoc method execute.
public void execute(final FileCollection source, File destDir, boolean use, boolean noTimestamp, boolean noVersionStamp, String windowTitle, String docTitle, String header, String footer, String overview, boolean includePrivate, final Set<Groovydoc.Link> links, final Iterable<File> groovyClasspath, Iterable<File> classpath, Project project) {
final File tmpDir = new File(project.getBuildDir(), "tmp/groovydoc");
FileOperations fileOperations = (ProjectInternal) project;
fileOperations.delete(tmpDir);
fileOperations.copy(new Action<CopySpec>() {
public void execute(CopySpec copySpec) {
copySpec.from(source).into(tmpDir);
}
});
List<File> combinedClasspath = ImmutableList.<File>builder().addAll(classpath).addAll(groovyClasspath).build();
VersionNumber version = VersionNumber.parse(getGroovyVersion(combinedClasspath));
final Map<String, Object> args = Maps.newLinkedHashMap();
args.put("sourcepath", tmpDir.toString());
args.put("destdir", destDir);
args.put("use", use);
if (isAtLeast(version, "2.4.6")) {
args.put("noTimestamp", noTimestamp);
args.put("noVersionStamp", noVersionStamp);
}
args.put("private", includePrivate);
putIfNotNull(args, "windowtitle", windowTitle);
putIfNotNull(args, "doctitle", docTitle);
putIfNotNull(args, "header", header);
putIfNotNull(args, "footer", footer);
if (overview != null) {
args.put("overview", overview);
}
invokeGroovydoc(links, combinedClasspath, args);
}
use of org.gradle.util.VersionNumber in project gradle by gradle.
the class ApiGroovyCompiler method applyConfigurationScript.
private void applyConfigurationScript(File configScript, CompilerConfiguration configuration) {
VersionNumber version = parseGroovyVersion();
if (version.compareTo(VersionNumber.parse("2.1")) < 0) {
throw new GradleException("Using a Groovy compiler configuration script requires Groovy 2.1+ but found Groovy " + version + "");
}
Binding binding = new Binding();
binding.setVariable("configuration", configuration);
CompilerConfiguration configuratorConfig = new CompilerConfiguration();
ImportCustomizer customizer = new ImportCustomizer();
customizer.addStaticStars("org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder");
configuratorConfig.addCompilationCustomizers(customizer);
GroovyShell shell = new GroovyShell(binding, configuratorConfig);
try {
shell.evaluate(configScript);
} catch (Exception e) {
throw new GradleException("Could not execute Groovy compiler configuration script: " + configScript.getAbsolutePath(), e);
}
}
Aggregations