Search in sources :

Example 1 with VersionNumber

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

Example 2 with VersionNumber

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);
}
Also used : HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher) UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) VersionNumber(org.gradle.util.VersionNumber) ArchitectureInternal(org.gradle.nativeplatform.platform.internal.ArchitectureInternal)

Example 3 with VersionNumber

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);
}
Also used : VersionNumber(org.gradle.util.VersionNumber)

Example 4 with VersionNumber

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());
                            }
                        }
                    });
                }
            });
        }
    });
}
Also used : Project(org.gradle.api.Project) Action(org.gradle.api.Action) Task(org.gradle.api.Task) IdeaModel(org.gradle.plugins.ide.idea.model.IdeaModel) XmlProvider(org.gradle.api.XmlProvider) FileCollection(org.gradle.api.file.FileCollection) Collection(java.util.Collection) BuildAdapter(org.gradle.BuildAdapter) Gradle(org.gradle.api.invocation.Gradle) Map(java.util.Map) VersionNumber(org.gradle.util.VersionNumber)

Example 5 with VersionNumber

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

Aggregations

VersionNumber (org.gradle.util.VersionNumber)10 File (java.io.File)5 MissingRegistryEntryException (net.rubygrapefruit.platform.MissingRegistryEntryException)2 UncheckedIOException (org.gradle.api.UncheckedIOException)2 ArchitectureInternal (org.gradle.nativeplatform.platform.internal.ArchitectureInternal)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 BuildAdapter (org.gradle.BuildAdapter)1 Action (org.gradle.api.Action)1 Project (org.gradle.api.Project)1 Task (org.gradle.api.Task)1 XmlProvider (org.gradle.api.XmlProvider)1 CopySpec (org.gradle.api.file.CopySpec)1 FileCollection (org.gradle.api.file.FileCollection)1 FileOperations (org.gradle.api.internal.file.FileOperations)1