use of com.typelead.gradle.utils.PackageInfo in project gradle-eta by typelead.
the class EtlasMavenRepository method writePomFile.
private void writePomFile(PackageInfo packageInfo, ImmutableDAG<String, PackageInfo> graph) {
final StringBuilder sb = new StringBuilder();
println(sb, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
println(sb, "<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\" xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">");
println(sb, " <modelVersion>4.0.0</modelVersion>");
print(sb, " <groupId>");
print(sb, getGroupId());
println(sb, "</groupId>");
print(sb, " <artifactId>");
print(sb, packageInfo.getName());
println(sb, "</artifactId>");
print(sb, " <version>");
print(sb, packageInfo.getFullVersion());
println(sb, "</version>");
println(sb, " <dependencies>");
for (PackageInfo dependency : graph.getNodeValues(packageInfo.getName())) {
println(sb, " <dependency>");
print(sb, " <groupId>");
print(sb, getGroupId());
println(sb, "</groupId>");
print(sb, " <artifactId>");
print(sb, dependency.getName());
println(sb, "</artifactId>");
print(sb, " <version>");
print(sb, dependency.getFullVersion());
println(sb, "</version>");
println(sb, " </dependency>");
}
for (String mavenDependency : packageInfo.getMavenDependencies()) {
String[] parts = mavenDependency.split(":");
println(sb, " <dependency>");
print(sb, " <groupId>");
print(sb, parts[0]);
println(sb, "</groupId>");
print(sb, " <artifactId>");
print(sb, parts[1]);
println(sb, "</artifactId>");
print(sb, " <version>");
print(sb, parts[2]);
println(sb, "</version>");
println(sb, " </dependency>");
}
println(sb, " </dependencies>");
println(sb, "</project>");
try {
final File packageVersionDirectory = getPackageVersionDirectory(packageInfo);
packageVersionDirectory.mkdirs();
Files.write(packageVersionDirectory.toPath().resolve(getPomFileName(packageInfo)), sb.toString().getBytes(StandardCharsets.UTF_8));
} catch (IOException ie) {
throw new GradleException("Failed to write pom file for " + packageInfo.getIdentifier(), ie);
}
}
use of com.typelead.gradle.utils.PackageInfo 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 '" + parentConfiguration.getIncoming().getPath() + "'");
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);
}
Aggregations