Search in sources :

Example 1 with PathSpec

use of com.typelead.gradle.utils.PathSpec in project gradle-eta by typelead.

the class EtaSetupEnvironment method resolveEtlas.

private ResolvedExecutable resolveEtlas() {
    EtlasResolver resolver = new EtlasResolver(getCacheDir());
    ExecutableSpec spec = etlasSpec.get();
    ResolvedExecutable resolvedEtlas = null;
    if (spec instanceof NoSpec) {
        throw new GradleException("Etlas not configured, please supply a value for the 'etlasVersion'" + " property in an eta { .. } block.");
    } else if (spec instanceof SystemSpec) {
        resolvedEtlas = resolver.resolveInSystemPath();
        getProject().getLogger().info("Using etlas from system PATH: " + resolvedEtlas.getPath());
    } else if (spec instanceof PathSpec) {
        resolvedEtlas = resolver.resolveLocalPath(((PathSpec) spec).getPath());
    } else if (spec instanceof VersionSpec) {
        String etlasRepo = getEtlasRepository();
        if (etlasRepo == null) {
            throw new GradleException("etlasVersion provided, but etlasRepo was unexpectedly null!");
        }
        resolvedEtlas = resolver.resolveRemote(etlasRepo, ((VersionSpec) spec).getVersion());
    }
    return resolvedEtlas;
}
Also used : NoSpec(com.typelead.gradle.utils.NoSpec) ResolvedExecutable(com.typelead.gradle.utils.ResolvedExecutable) ExecutableSpec(com.typelead.gradle.utils.ExecutableSpec) GradleException(org.gradle.api.GradleException) SystemSpec(com.typelead.gradle.utils.SystemSpec) EtlasResolver(com.typelead.gradle.eta.internal.EtlasResolver) PathSpec(com.typelead.gradle.utils.PathSpec) VersionSpec(com.typelead.gradle.utils.VersionSpec)

Example 2 with PathSpec

use of com.typelead.gradle.utils.PathSpec in project gradle-eta by typelead.

the class EtaSetupEnvironment method resolveEta.

private ResolvedExecutable resolveEta(EtlasCommand etlas) {
    ResolvedExecutable resolvedEta;
    ExecutableSpec spec = etaSpec.get();
    boolean system = false;
    boolean fresh = false;
    String message = null;
    String etaVersion = null;
    if (spec instanceof NoSpec) {
        message = "latest available version";
        etaVersion = etlas.getLatestEtaVersion();
    } else if (spec instanceof SystemSpec) {
        system = true;
        message = "version available on your system";
        etaVersion = etlas.getGlobalEtaVersion();
    } else if (spec instanceof PathSpec) {
        throw new GradleException("etaSpec should never have a value PathSpec");
    } else if (spec instanceof VersionSpec) {
        final String friendlyEtaVersion = ((VersionSpec) spec).getVersion();
        etaVersion = machineVersion(friendlyEtaVersion);
        fresh = !etlas.getInstalledEtaVersions().contains(friendlyEtaVersion);
    }
    if (message != null) {
        getProject().getLogger().lifecycle("WARNING: You have not explicitly set the version of Eta to be used, " + "so the " + message + ", " + friendlyVersion(etaVersion) + ", will be used." + NEWLINE + NEWLINE + "This is not recommended since it will make this build " + "non-reproducible. Please supply a value for the 'version' property " + "in an eta { .. } block.");
    }
    return new ResolvedExecutable(null, etaVersion, system, fresh);
}
Also used : NoSpec(com.typelead.gradle.utils.NoSpec) ResolvedExecutable(com.typelead.gradle.utils.ResolvedExecutable) ExecutableSpec(com.typelead.gradle.utils.ExecutableSpec) GradleException(org.gradle.api.GradleException) SystemSpec(com.typelead.gradle.utils.SystemSpec) PathSpec(com.typelead.gradle.utils.PathSpec) VersionSpec(com.typelead.gradle.utils.VersionSpec)

Aggregations

ExecutableSpec (com.typelead.gradle.utils.ExecutableSpec)2 NoSpec (com.typelead.gradle.utils.NoSpec)2 PathSpec (com.typelead.gradle.utils.PathSpec)2 ResolvedExecutable (com.typelead.gradle.utils.ResolvedExecutable)2 SystemSpec (com.typelead.gradle.utils.SystemSpec)2 VersionSpec (com.typelead.gradle.utils.VersionSpec)2 GradleException (org.gradle.api.GradleException)2 EtlasResolver (com.typelead.gradle.eta.internal.EtlasResolver)1