Search in sources :

Example 6 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)

Example 7 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 8 with VersionNumber

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

the class SwiftcMetadataProvider method parseCompilerOutput.

@Override
protected SwiftcMetadata parseCompilerOutput(String stdout, String stderr, File swiftc, List<File> path) {
    BufferedReader reader = new BufferedReader(new StringReader(stdout));
    try {
        String line;
        while ((line = reader.readLine()) != null) {
            if (line.contains("Swift version")) {
                String[] tokens = line.split(" ");
                // Assuming format: 'Swift version 4.0.2 (...)'
                int i = 2;
                if ("Apple".equals(tokens[0])) {
                    // Actual format: 'Apple Swift version 4.0.2 (...)'
                    i++;
                }
                VersionNumber version = VersionNumber.parse(tokens[i]);
                return new DefaultSwiftcMetadata(line, version);
            }
        }
        throw new BrokenResultException(String.format("Could not determine %s metadata: %s produced unexpected output.", getCompilerType().getDescription(), swiftc.getName()));
    } catch (IOException e) {
        // Should not happen when reading from a StringReader
        throw new UncheckedIOException(e);
    }
}
Also used : BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) VersionNumber(org.gradle.util.internal.VersionNumber)

Example 9 with VersionNumber

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

the class AvailableToolChains method findXcodes.

static List<InstalledXcode> findXcodes() {
    List<InstalledXcode> xcodes = new ArrayList<>();
    // On macOS, we assume co-located Xcode is installed into /opt/xcode
    File rootXcodeInstall = new File("/opt/xcode");
    List<File> xcodeCandidates = Lists.newArrayList(Arrays.asList(GUtil.getOrDefault(rootXcodeInstall.listFiles(File::isDirectory), () -> new File[0])));
    // Default Xcode installation
    xcodeCandidates.add(new File("/Applications/Xcode.app"));
    xcodeCandidates.stream().filter(File::exists).forEach(xcodeInstall -> {
        TestFile xcodebuild = new TestFile("/usr/bin/xcodebuild");
        String output = xcodebuild.execute(Collections.singletonList("-version"), Collections.singletonList("DEVELOPER_DIR=" + xcodeInstall.getAbsolutePath())).getOut();
        Pattern versionRegex = Pattern.compile("Xcode (\\d+\\.\\d+(\\.\\d+)?)");
        Matcher matcher = versionRegex.matcher(output);
        if (matcher.find()) {
            VersionNumber version = VersionNumber.parse(matcher.group(1));
            xcodes.add(new InstalledXcode(xcodeInstall, version));
        }
    });
    return xcodes;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) TestFile(org.gradle.test.fixtures.file.TestFile) ArrayList(java.util.ArrayList) File(java.io.File) TestFile(org.gradle.test.fixtures.file.TestFile) VersionNumber(org.gradle.util.internal.VersionNumber)

Example 10 with VersionNumber

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

the class GccMetadataProvider method parseCompilerOutput.

@Override
protected GccMetadata parseCompilerOutput(String output, String error, File gccBinary, List<File> path) {
    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(defines, path, 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.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