Search in sources :

Example 1 with ResolvedExecutable

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

the class EtaSetupEnvironment method setupEnvironment.

@TaskAction
public void setupEnvironment() {
    EtlasCommand etlas = new EtlasCommand(getProject());
    ResolvedExecutable etlasExec = resolveEtlas();
    /* This is a bootstrap step since we need to populate
           this property in order for the following etlas
           invocation to work. */
    resolvedEtlas.set(etlasExec);
    ensureTelemetryPreferencesAndUpdate(etlas);
    if (etlasExec.getVersion() == null) {
        etlasExec.setVersion(etlas.numericVersion());
    }
    ResolvedExecutable etaExec = resolveEta(etlas);
    resolvedEta.set(etaExec);
    if (etaExec.isFresh()) {
        getProject().getLogger().lifecycle("Installing Eta v" + friendlyVersion(etaExec.getVersion()));
        etlas.installEta();
    }
    boolean changed = SnapshotUtils.takeSnapshotAndCompare(getVersionsSnapshot(), etaExec, etlasExec, getEtaSpec(), getEtlasSpec());
    resolvedEtaInfo.set(fetchEtaInfo(etlas, etaExec, changed));
    versionsChanged.set(Boolean.valueOf(changed));
    setDidWork(changed);
}
Also used : ResolvedExecutable(com.typelead.gradle.utils.ResolvedExecutable) EtlasCommand(com.typelead.gradle.utils.EtlasCommand) TaskAction(org.gradle.api.tasks.TaskAction)

Example 2 with ResolvedExecutable

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

the class EtlasResolver method resolveRemote.

public ResolvedExecutable resolveRemote(String repo, String version) {
    Arch arch = getArch().valueOr(e -> {
        throw e;
    });
    EtlasCache cache = new EtlasCache(cacheDir);
    String etlasPath = cache.getBinaryPathForVersion(version, arch);
    boolean fresh = false;
    if (etlasPath == null) {
        etlasPath = cache.putBinaryForVersion(version, getEtlasUrl(repo, version, arch), arch);
        fresh = true;
    }
    return new ResolvedExecutable(etlasPath, version, false, fresh);
}
Also used : ResolvedExecutable(com.typelead.gradle.utils.ResolvedExecutable) Arch(com.typelead.gradle.utils.Arch)

Example 3 with ResolvedExecutable

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

the class EtlasResolver method resolveInSystemPath.

public ResolvedExecutable resolveInSystemPath() {
    String execExt = getArch().fold(x -> "", arch -> arch.execExt);
    File etlas = SystemPathUtil.findExecutable("etlas" + execExt);
    if (etlas == null) {
        throw new GradleException("Could not find etlas executable on system PATH.");
    }
    String etlasPath;
    try {
        etlasPath = etlas.getCanonicalPath();
    } catch (IOException e) {
        throw new GradleException("Failed to get canonical path for etlas '" + etlas.getPath() + "'", e);
    }
    return new ResolvedExecutable(etlasPath, null, true);
}
Also used : ResolvedExecutable(com.typelead.gradle.utils.ResolvedExecutable) GradleException(org.gradle.api.GradleException) IOException(java.io.IOException) File(java.io.File)

Example 4 with ResolvedExecutable

use of com.typelead.gradle.utils.ResolvedExecutable 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 5 with ResolvedExecutable

use of com.typelead.gradle.utils.ResolvedExecutable 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

ResolvedExecutable (com.typelead.gradle.utils.ResolvedExecutable)5 GradleException (org.gradle.api.GradleException)3 ExecutableSpec (com.typelead.gradle.utils.ExecutableSpec)2 NoSpec (com.typelead.gradle.utils.NoSpec)2 PathSpec (com.typelead.gradle.utils.PathSpec)2 SystemSpec (com.typelead.gradle.utils.SystemSpec)2 VersionSpec (com.typelead.gradle.utils.VersionSpec)2 EtlasResolver (com.typelead.gradle.eta.internal.EtlasResolver)1 Arch (com.typelead.gradle.utils.Arch)1 EtlasCommand (com.typelead.gradle.utils.EtlasCommand)1 File (java.io.File)1 IOException (java.io.IOException)1 TaskAction (org.gradle.api.tasks.TaskAction)1