Search in sources :

Example 6 with GradleVersion

use of org.gradle.util.GradleVersion in project gradle by gradle.

the class WrapperDistributionCleanupAction method determineChecksumDirsByVersion.

private Multimap<GradleVersion, File> determineChecksumDirsByVersion() {
    Multimap<GradleVersion, File> result = ArrayListMultimap.create();
    for (File dir : listDirs(distsDir)) {
        for (File checksumDir : listDirs(dir)) {
            try {
                GradleVersion gradleVersion = determineGradleVersionFromBuildReceipt(checksumDir);
                result.put(gradleVersion, checksumDir);
            } catch (Exception e) {
                LOGGER.debug("Could not determine Gradle version for {}: {} ({})", checksumDir, e.getMessage(), e.getClass().getName());
            }
        }
    }
    return result;
}
Also used : GradleVersion(org.gradle.util.GradleVersion) DefaultGradleVersion(org.gradle.util.internal.DefaultGradleVersion) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 7 with GradleVersion

use of org.gradle.util.GradleVersion in project gradle by gradle.

the class WrapperDistributionCleanupAction method determineGradleVersionFromDistribution.

@VisibleForTesting
protected GradleVersion determineGradleVersionFromDistribution(File distributionHomeDir) throws Exception {
    List<File> checkedJarFiles = new ArrayList<File>();
    for (Map.Entry<String, Pattern> entry : JAR_FILE_PATTERNS_BY_PREFIX.entrySet()) {
        List<File> jarFiles = listFiles(new File(distributionHomeDir, "lib"), new RegexFileFilter(entry.getValue()));
        if (!jarFiles.isEmpty()) {
            Preconditions.checkArgument(jarFiles.size() == 1, "A Gradle distribution must contain at most one %s-*.jar: %s", entry.getKey(), jarFiles);
            File jarFile = single(jarFiles);
            GradleVersion gradleVersion = readGradleVersionFromJarFile(jarFile);
            if (gradleVersion != null) {
                return gradleVersion;
            }
            checkedJarFiles.add(jarFile);
        }
    }
    throw new IllegalArgumentException("No checked JAR file contained a build receipt: " + checkedJarFiles);
}
Also used : Pattern(java.util.regex.Pattern) ArrayList(java.util.ArrayList) RegexFileFilter(org.apache.commons.io.filefilter.RegexFileFilter) GradleVersion(org.gradle.util.GradleVersion) DefaultGradleVersion(org.gradle.util.internal.DefaultGradleVersion) ZipFile(java.util.zip.ZipFile) File(java.io.File) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 8 with GradleVersion

use of org.gradle.util.GradleVersion in project gradle by gradle.

the class VersionSpecificCacheCleanupAction method performCleanup.

private void performCleanup(CleanupProgressMonitor progressMonitor) {
    MinimumTimestampProvider minimumTimestampProvider = new MinimumTimestampProvider();
    SortedSetMultimap<GradleVersion, VersionSpecificCacheDirectory> cacheDirsByBaseVersion = scanForVersionSpecificCacheDirs();
    for (GradleVersion baseVersion : cacheDirsByBaseVersion.keySet()) {
        performCleanup(cacheDirsByBaseVersion.get(baseVersion), minimumTimestampProvider, progressMonitor);
    }
    markCleanedUp();
}
Also used : GradleVersion(org.gradle.util.GradleVersion)

Example 9 with GradleVersion

use of org.gradle.util.GradleVersion in project gradle by gradle.

the class CrossVersionResultsStore method resolveGradleVersion.

protected GradleVersion resolveGradleVersion(String version) {
    GradleVersion gradleVersion = gradleVersionCache.get(version);
    if (gradleVersion == null) {
        gradleVersion = GradleVersion.version(version);
        gradleVersionCache.put(version, gradleVersion);
    }
    return gradleVersion;
}
Also used : GradleVersion(org.gradle.util.GradleVersion)

Example 10 with GradleVersion

use of org.gradle.util.GradleVersion in project gradle by gradle.

the class AbstractGradleExecuter method cleanupIsolatedDaemons.

private void cleanupIsolatedDaemons() {
    List<DaemonLogsAnalyzer> analyzers = new ArrayList<>();
    List<GradleVersion> versions = (gradleVersionOverride != null) ? ImmutableList.of(gradleVersion, gradleVersionOverride) : ImmutableList.of(gradleVersion);
    for (File dir : isolatedDaemonBaseDirs) {
        for (GradleVersion version : versions) {
            try {
                DaemonLogsAnalyzer analyzer = new DaemonLogsAnalyzer(dir, version.getVersion());
                analyzers.add(analyzer);
                analyzer.killAll();
            } catch (Exception e) {
                getLogger().warn("Problem killing isolated daemons of Gradle version " + version + " in " + dir, e);
            }
        }
    }
    if (checkDaemonCrash) {
        analyzers.forEach(DaemonLogsAnalyzer::assertNoCrashedDaemon);
    }
}
Also used : DaemonLogsAnalyzer(org.gradle.integtests.fixtures.daemon.DaemonLogsAnalyzer) ArrayList(java.util.ArrayList) GradleVersion(org.gradle.util.GradleVersion) File(java.io.File) TestFile(org.gradle.test.fixtures.file.TestFile) UncheckedException(org.gradle.internal.UncheckedException) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException)

Aggregations

GradleVersion (org.gradle.util.GradleVersion)19 File (java.io.File)10 ArrayList (java.util.ArrayList)6 DefaultGradleConnector (org.gradle.tooling.internal.consumer.DefaultGradleConnector)4 IOException (java.io.IOException)3 List (java.util.List)3 Map (java.util.Map)3 ZipFile (java.util.zip.ZipFile)3 GradleConnector (org.gradle.tooling.GradleConnector)3 ProjectConnection (org.gradle.tooling.ProjectConnection)3 InputStream (java.io.InputStream)2 BuildEnvironment (org.gradle.tooling.model.build.BuildEnvironment)2 DefaultGradleVersion (org.gradle.util.internal.DefaultGradleVersion)2 NotNull (org.jetbrains.annotations.NotNull)2 UnsupportedCancellationToken (org.jetbrains.plugins.gradle.service.execution.UnsupportedCancellationToken)2 GradleBuildParticipant (org.jetbrains.plugins.gradle.settings.GradleBuildParticipant)2 GradleExecutionSettings (org.jetbrains.plugins.gradle.settings.GradleExecutionSettings)2 AndroidProject (com.android.builder.model.AndroidProject)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Joiner (com.google.common.base.Joiner)1