use of com.typelead.gradle.eta.api.EtaConfiguration in project gradle-eta by typelead.
the class DefaultEtaConfiguration method doResolve.
public void doResolve(final Project project, final DependencyHandler handler, final ImmutableDAG<String, PackageInfo> dependencyGraph, Set<String> resolvedDependencies) {
final Logger logger = project.getLogger();
final String configurationName = parentConfiguration.getName();
Set<String> resolvedDeps = new HashSet<String>();
for (Configuration configuration : parentConfiguration.getExtendsFrom()) {
DefaultEtaConfiguration etaConfiguration = ExtensionHelper.getExtension(configuration, DefaultEtaConfiguration.class);
etaConfiguration.doResolve(project, handler, dependencyGraph, resolvedDeps);
}
List<String> keys = new ArrayList<String>();
for (EtaDependency dep : dependencies) {
if (dep instanceof HasPackageName) {
keys.add(((HasPackageName) dep).getPackageName());
}
}
if (!resolved.get() && resolved.compareAndSet(false, true)) {
logger.info("Resolving Eta Configuration '" + configurationName + "'");
List<PackageInfo> packageInfos = dependencyGraph.differenceClosure(keys, resolvedDeps);
if (packageInfos.size() > 0) {
mavenRepository.installPackages(packageInfos, dependencyGraph);
resolvedMavenDependencies = packageInfos.stream().filter(packageInfo -> keys.contains(packageInfo.getName())).map(mavenRepository::getMavenDependency).collect(Collectors.toList());
for (String mavenDep : resolvedMavenDependencies) {
handler.add(configurationName, mavenDep);
logger.info("Injecting maven dependency '" + mavenDep + "'");
}
} else {
resolvedMavenDependencies = Collections.emptyList();
}
}
resolvedDependencies.addAll(resolvedDeps);
resolvedDependencies.addAll(keys);
}
use of com.typelead.gradle.eta.api.EtaConfiguration in project gradle-eta by typelead.
the class DefaultEtaConfiguration method getAllDependencies.
@Override
public Set<EtaDependency> getAllDependencies() {
Set<EtaDependency> allDependencies = new LinkedHashSet<>();
allDependencies.addAll(dependencies);
for (Configuration configuration : parentConfiguration.getExtendsFrom()) {
EtaConfiguration etaConfiguration = ExtensionHelper.getExtension(configuration, EtaConfiguration.class);
allDependencies.addAll(etaConfiguration.getAllDependencies());
}
return allDependencies;
}
use of com.typelead.gradle.eta.api.EtaConfiguration in project gradle-eta by typelead.
the class EtaInstallDependencies method installDependencies.
@TaskAction
public void installDependencies() {
final EtaOptions etaOptions = getOptions();
etaOptions.validate(etaInfo.get());
final File workingDir = getDestinationDir();
copyFreezeConfigIfChanged(workingDir);
/* Calculate all the modules */
final List<String> modules = getModules();
/* Determine if it's an executable */
String exec = executable.getOrNull();
if (exec != null && exec.length() <= 0) {
exec = null;
}
final String executableSpec = exec;
/* Generate the .cabal & cabal.project files. */
final WriteResult[] writeResults = new WriteResult[2];
final String targetConfigurationName = getTargetConfiguration();
Set<File> packageDBs = ConfigurationUtils.getEtaConfiguration(ConfigurationUtils.getConfiguration(project, targetConfigurationName)).getAllArtifacts(project).stream().map(Provider::get).collect(Collectors.toSet());
DependencyUtils.foldEtaDependencies(project, dependencies.get(), (directDeps, projectDeps) -> {
/* Include the project dependencies in the Etlas
dependency list. */
directDeps.addAll(projectDeps);
writeResults[0] = CabalHelper.generateCabalFile(project.getName(), project.getVersion().toString(), executableSpec, getSourceDirs().getFiles().stream().map(File::getAbsolutePath).collect(Collectors.toList()), modules, etaOptions, directDeps, workingDir);
}, gitDeps -> {
writeResults[1] = CabalHelper.generateCabalProjectFile(gitDeps, packageDBs, workingDir);
});
/* Delete existing *.cabal files to avoid errors when changing the project
name. */
final File oldCabalFile = writeResults[0].getFile();
project.delete(project.fileTree(workingDir, fileTree -> {
fileTree.include("*.cabal");
fileTree.exclude(fileTreeElement -> {
try {
return fileTreeElement.getFile().getCanonicalPath().equals(oldCabalFile.getCanonicalPath());
} catch (IOException e) {
return true;
}
});
}));
/* Fork an etlas process to install the dependencies. */
final EtlasCommand etlas = new EtlasCommand(project);
etlas.getWorkingDirectory().set(workingDir);
boolean isUpToDate = etlas.deps(dependencyGraph -> {
/* Inject the dependencies into the respective configurations. */
DependencyHandler dependencies = project.getDependencies();
final EtaConfiguration targetEtaConfiguration = ConfigurationUtils.getEtaConfiguration(project, getTargetConfiguration());
targetEtaConfiguration.resolve(project, dependencies, dependencyGraph);
});
setDidWork(!isUpToDate);
}
use of com.typelead.gradle.eta.api.EtaConfiguration in project gradle-eta by typelead.
the class DefaultEtaConfiguration method getAllArtifacts.
@Override
public Set<Provider<File>> getAllArtifacts(final Project project) {
Set<Provider<File>> allArtifacts = new LinkedHashSet<Provider<File>>();
allArtifacts.addAll(artifacts);
for (EtaDependency dependency : getDependencies()) {
if (dependency instanceof EtaProjectDependency) {
final EtaProjectDependency projectDependency = ((EtaProjectDependency) dependency);
final EtaConfiguration etaConfiguration = ConfigurationUtils.getEtaConfiguration(projectDependency.getProject(project), projectDependency.getTargetConfiguration());
if (etaConfiguration != null) {
allArtifacts.addAll(etaConfiguration.getAllArtifacts(project));
}
}
}
for (Configuration configuration : parentConfiguration.getExtendsFrom()) {
final EtaConfiguration etaConfiguration = ExtensionHelper.getExtension(configuration, EtaConfiguration.class);
allArtifacts.addAll(etaConfiguration.getAllArtifacts(project));
}
return allArtifacts;
}
Aggregations