blob: f281bc4d7da360c7e6d409ba4f1f0e192cc6a646 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.dev.builder;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.TreeSet;
/**
* @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen Hult</a>
*/
public class PomFileGenerator {
public static void main(String[] args) throws IOException {
Model model = new Model();
model.setModelVersion("4.0.0");
model.setGroupId("com.yahoo.vespa");
model.setArtifactId("container-dev");
model.setVersion(args[0]);
model.getProperties().setProperty("project.build.sourceEncoding", StandardCharsets.UTF_8.name());
for (String str : new TreeSet<>(Arrays.asList(args).subList(1, args.length))) {
Dependency dependency = newDependency(str);
if (dependency == null) {
continue;
}
if (dependency.getGroupId().equals(model.getGroupId()) &&
dependency.getArtifactId().equals(model.getArtifactId())) {
continue;
}
model.addDependency(dependency);
}
new MavenXpp3Writer().write(System.out, model);
}
private static Dependency newDependency(String str) {
String[] arr = str.split(":");
if (arr.length != 5) {
return null;
}
Dependency out = new Dependency();
out.setGroupId(arr[0]);
out.setArtifactId(arr[1]);
out.setVersion(arr[3]);
return out;
}
}
|