use of com.typelead.gradle.eta.api.SourceRepository in project gradle-eta by typelead.
the class DependencyUtils method foldEtaDependencies.
public static void foldEtaDependencies(final Project project, Collection<EtaDependency> dependencies, BiConsumer<List<String>, List<String>> directProjectConsumer, Consumer<Set<SourceRepository>> gitConsumer) {
List<String> directDependencies = new ArrayList<>();
List<String> projectDependencies = new ArrayList<>();
Set<SourceRepository> gitDependencies = new LinkedHashSet<>();
for (EtaDependency dependency : dependencies) {
if (dependency instanceof EtaDirectDependency) {
directDependencies.add(((EtaDirectDependency) dependency).toString());
} else if (dependency instanceof EtaProjectDependency) {
final Project targetProject = ((EtaProjectDependency) dependency).getProject(project);
if (isEtaProject(targetProject)) {
projectDependencies.add(targetProject.getName());
}
} else if (dependency instanceof EtaGitDependency) {
gitDependencies.add(((EtaGitDependency) dependency).getSourceRepository());
}
}
if (directProjectConsumer != null) {
directProjectConsumer.accept(directDependencies, projectDependencies);
}
if (gitConsumer != null) {
gitConsumer.accept(gitDependencies);
}
}
use of com.typelead.gradle.eta.api.SourceRepository in project gradle-eta by typelead.
the class DefaultEtaGitDependency method create.
public static DefaultEtaGitDependency create(Project project, Map<String, String> attributes) {
validateAttributes(attributes);
String packageName = attributes.get(PACKAGE_ATTRIBUTE);
String location = attributes.get(LOCATION_ATTRIBUTE);
String commit = attributes.get(COMMIT_ATTRIBUTE);
String branch = attributes.get(BRANCH_ATTRIBUTE);
String tag = attributes.get(TAG_ATTRIBUTE);
CommitIdentifierType commitIdType;
String commitId;
if (commit != null) {
commitIdType = COMMIT;
commitId = commit;
} else if (tag != null) {
commitIdType = TAG;
commitId = tag;
} else {
commitIdType = BRANCH;
commitId = branch;
}
return new DefaultEtaGitDependency(project, packageName, new SourceRepository(location, commitIdType, commitId));
}
use of com.typelead.gradle.eta.api.SourceRepository in project gradle-eta by typelead.
the class CabalHelper method generateCabalProjectFile.
public static WriteResult generateCabalProjectFile(final Set<SourceRepository> sourceRepositories, final Collection<File> packageDBs, final File workingDir) {
StringBuilder sb = new StringBuilder();
println(sb, "packages: .");
if (Collections.isNonEmpty(packageDBs)) {
println(sb, "package-dbs:");
for (File packageDB : packageDBs) {
print(sb, " ");
println(sb, packageDB.getAbsolutePath());
}
print(sb, NEWLINE);
}
if (Collections.isNonEmpty(sourceRepositories)) {
for (SourceRepository sourceRepository : sourceRepositories) {
println(sb, "source-repository-package");
println(sb, " type: git");
println(sb, " location: " + sourceRepository.getLocation());
switch(sourceRepository.getCommitIdentifierType()) {
case BRANCH:
print(sb, " branch: ");
break;
case TAG:
print(sb, " tag: ");
break;
case COMMIT:
print(sb, " commit: ");
break;
}
println(sb, sourceRepository.getCommitIdentifier());
}
}
return snapshotWrite(new File(workingDir, "cabal.project"), sb.toString(), new File(workingDir, "cabal.project.snapshot"));
}
use of com.typelead.gradle.eta.api.SourceRepository in project gradle-eta by typelead.
the class DependencyUtils method foldEtaDependencies.
public static void foldEtaDependencies(final Project project, final Collection<EtaDependency> dependencies, final QuadConsumer<List<String>, List<String>, List<String>, Set<SourceRepository>> directProjectConsumer) {
List<String> directDependencies = new ArrayList<>();
List<String> projectDependencies = new ArrayList<>();
List<String> gitStringDependencies = new ArrayList<>();
Set<SourceRepository> gitDependencies = new LinkedHashSet<>();
for (EtaDependency dependency : dependencies) {
if (dependency instanceof EtaDirectDependency) {
directDependencies.add(((EtaDirectDependency) dependency).toString());
} else if (dependency instanceof EtaProjectDependency) {
final Project targetProject = ((EtaProjectDependency) dependency).getProject(project);
if (isEtaProject(targetProject)) {
projectDependencies.add(NamingScheme.getPackageName(targetProject, SourceSet.MAIN_SOURCE_SET_NAME));
}
} else if (dependency instanceof EtaGitDependency) {
final EtaGitDependency gitDep = (EtaGitDependency) dependency;
gitDependencies.add(gitDep.getSourceRepository());
gitStringDependencies.add(gitDep.getPackageName());
}
}
if (directProjectConsumer != null) {
directProjectConsumer.accept(directDependencies, projectDependencies, gitStringDependencies, gitDependencies);
}
}
Aggregations