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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations