Search in sources :

Example 1 with VersionNumber

use of org.gradle.util.internal.VersionNumber in project gradle by gradle.

the class IdeaScalaConfigurer method findIdeaTargetVersion.

private VersionNumber findIdeaTargetVersion() {
    VersionNumber targetVersion = null;
    String targetVersionString = rootProject.getExtensions().getByType(IdeaModel.class).getTargetVersion();
    if (targetVersionString != null) {
        targetVersion = VersionNumber.parse(targetVersionString);
        if (targetVersion.equals(VersionNumber.UNKNOWN)) {
            throw new GradleScriptException("String '" + targetVersionString + "' is not a valid value for IdeaModel.targetVersion.", null);
        }
    }
    return targetVersion;
}
Also used : IdeaModel(org.gradle.plugins.ide.idea.model.IdeaModel) GradleScriptException(org.gradle.api.GradleScriptException) VersionNumber(org.gradle.util.internal.VersionNumber)

Example 2 with VersionNumber

use of org.gradle.util.internal.VersionNumber in project gradle by gradle.

the class DefaultGradleApiSourcesResolver method resolveLocalGroovySources.

@Override
public File resolveLocalGroovySources(String jarName) {
    Matcher matcher = FILE_NAME_PATTERN.matcher(jarName);
    if (!matcher.matches()) {
        return null;
    }
    VersionNumber version = VersionNumber.parse(matcher.group(3));
    final String artifactName = matcher.group(1);
    return downloadLocalGroovySources(artifactName, version);
}
Also used : Matcher(java.util.regex.Matcher) VersionNumber(org.gradle.util.internal.VersionNumber)

Example 3 with VersionNumber

use of org.gradle.util.internal.VersionNumber in project gradle by gradle.

the class UpgradeCapabilityResolver method resolve.

@Override
public void resolve(CapabilitiesConflictHandler.ResolutionDetails details) {
    Collection<? extends Capability> capabilityVersions = details.getCapabilityVersions();
    if (capabilityVersions.size() > 1) {
        Set<Capability> sorted = Sets.newTreeSet((o1, o2) -> {
            VersionNumber v1 = VersionNumber.parse(o1.getVersion());
            VersionNumber v2 = VersionNumber.parse(o2.getVersion());
            return v2.compareTo(v1);
        });
        sorted.addAll(capabilityVersions);
        boolean first = true;
        for (Capability capability : sorted) {
            DisplayName reason = Describables.of("latest version of capability", ((CapabilityInternal) capability).getCapabilityId());
            boolean isFirst = first;
            details.getCandidates(capability).forEach(cand -> {
                cand.byReason(reason);
                if (!isFirst) {
                    cand.evict();
                }
            });
            first = false;
        }
    }
}
Also used : Capability(org.gradle.api.capabilities.Capability) DisplayName(org.gradle.internal.DisplayName) VersionNumber(org.gradle.util.internal.VersionNumber)

Example 4 with VersionNumber

use of org.gradle.util.internal.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());
    }
}
Also used : MissingRegistryEntryException(net.rubygrapefruit.platform.MissingRegistryEntryException) File(java.io.File) VersionNumber(org.gradle.util.internal.VersionNumber)

Example 5 with VersionNumber

use of org.gradle.util.internal.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;
    }
}
Also used : File(java.io.File) VersionNumber(org.gradle.util.internal.VersionNumber)

Aggregations

VersionNumber (org.gradle.util.internal.VersionNumber)16 File (java.io.File)9 GradleException (org.gradle.api.GradleException)3 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 CompilerConfiguration (org.codehaus.groovy.control.CompilerConfiguration)2 TestFile (org.gradle.test.fixtures.file.TestFile)2 Binding (groovy.lang.Binding)1 GroovyClassLoader (groovy.lang.GroovyClassLoader)1 GroovyShell (groovy.lang.GroovyShell)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Pattern (java.util.regex.Pattern)1 Collectors.toList (java.util.stream.Collectors.toList)1 MissingRegistryEntryException (net.rubygrapefruit.platform.MissingRegistryEntryException)1 CompilationUnit (org.codehaus.groovy.control.CompilationUnit)1