use of org.codehaus.plexus.util.xml.Xpp3Dom in project tesb-studio-se by Talend.
the class CreateMavenDataServicePom method addFeaturesMavenPlugin.
private Plugin addFeaturesMavenPlugin() {
Plugin plugin = new Plugin();
plugin.setGroupId("org.apache.karaf.tooling");
plugin.setArtifactId("karaf-maven-plugin");
plugin.setVersion("4.2.10");
Xpp3Dom configuration = new Xpp3Dom("configuration");
Xpp3Dom resourcesDir = new Xpp3Dom("resourcesDir");
resourcesDir.setValue("${project.build.directory}/bin");
Xpp3Dom featuresFile = new Xpp3Dom("featuresFile");
featuresFile.setValue("${basedir}/src/main/resources/feature/feature.xml");
configuration.addChild(resourcesDir);
configuration.addChild(featuresFile);
List<PluginExecution> pluginExecutions = new ArrayList<PluginExecution>();
PluginExecution pluginExecution = new PluginExecution();
pluginExecution.setId("create-kar");
pluginExecution.addGoal("kar");
pluginExecution.setConfiguration(configuration);
pluginExecutions.add(pluginExecution);
plugin.setExecutions(pluginExecutions);
List<Dependency> dependencies = new ArrayList<Dependency>();
Dependency mavensharedDep = new Dependency();
mavensharedDep.setGroupId("org.apache.maven.shared");
mavensharedDep.setArtifactId("maven-shared-utils");
mavensharedDep.setVersion("3.3.3");
Dependency commonsioDep = new Dependency();
commonsioDep.setGroupId("commons-io");
commonsioDep.setArtifactId("commons-io");
commonsioDep.setVersion("2.8.0");
Dependency httpclientDep = new Dependency();
httpclientDep.setGroupId("org.apache.httpcomponents");
httpclientDep.setArtifactId("httpclient");
httpclientDep.setVersion("4.5.13");
Dependency httpcoreDep = new Dependency();
httpcoreDep.setGroupId("org.apache.httpcomponents");
httpcoreDep.setArtifactId("httpcore");
httpcoreDep.setVersion("4.4.13");
Dependency istackDep = new Dependency();
istackDep.setGroupId("com.sun.istack");
istackDep.setArtifactId("istack-commons-runtime");
istackDep.setVersion("3.0.10");
Dependency xzDep = new Dependency();
xzDep.setGroupId("org.tukaani");
xzDep.setArtifactId("xz");
xzDep.setVersion("1.8");
Dependency junitDep = new Dependency();
junitDep.setGroupId("junit");
junitDep.setArtifactId("junit");
junitDep.setVersion("4.13.2");
Dependency mavenCoreDep = new Dependency();
mavenCoreDep.setGroupId("org.apache.maven");
mavenCoreDep.setArtifactId("maven-core");
mavenCoreDep.setVersion("3.8.3");
Dependency mavenCompatDep = new Dependency();
mavenCompatDep.setGroupId("org.apache.maven");
mavenCompatDep.setArtifactId("maven-compat");
mavenCompatDep.setVersion("3.8.3");
Dependency mavenSettingsDep = new Dependency();
mavenSettingsDep.setGroupId("org.apache.maven");
mavenSettingsDep.setArtifactId("maven-settings");
mavenSettingsDep.setVersion("3.8.3");
Dependency mavenSettingsBdDep = new Dependency();
mavenSettingsBdDep.setGroupId("org.apache.maven");
mavenSettingsBdDep.setArtifactId("maven-settings-builder");
mavenSettingsBdDep.setVersion("3.8.3");
Dependency plexusArchiverDep = new Dependency();
plexusArchiverDep.setGroupId("org.codehaus.plexus");
plexusArchiverDep.setArtifactId("plexus-archiver");
plexusArchiverDep.setVersion("3.6.0");
Dependency commonsCompressDep = new Dependency();
commonsCompressDep.setGroupId("org.apache.commons");
commonsCompressDep.setArtifactId("commons-compress");
commonsCompressDep.setVersion("1.21");
Dependency jsoupDep = new Dependency();
jsoupDep.setGroupId("org.jsoup");
jsoupDep.setArtifactId("jsoup");
jsoupDep.setVersion("1.14.2");
Dependency mavenModelDep = new Dependency();
mavenModelDep.setGroupId("org.apache.maven");
mavenModelDep.setArtifactId("maven-model");
mavenModelDep.setVersion("3.8.3");
Dependency commonsCodecDep = new Dependency();
commonsCodecDep.setGroupId("commons-codec");
commonsCodecDep.setArtifactId("commons-codec");
commonsCodecDep.setVersion("1.15");
dependencies.add(mavensharedDep);
dependencies.add(commonsioDep);
dependencies.add(httpclientDep);
dependencies.add(httpcoreDep);
dependencies.add(istackDep);
dependencies.add(xzDep);
dependencies.add(junitDep);
dependencies.add(mavenCoreDep);
dependencies.add(mavenCompatDep);
dependencies.add(mavenSettingsDep);
dependencies.add(mavenSettingsBdDep);
dependencies.add(plexusArchiverDep);
dependencies.add(commonsCompressDep);
dependencies.add(jsoupDep);
dependencies.add(mavenModelDep);
dependencies.add(commonsCodecDep);
plugin.setDependencies(dependencies);
return plugin;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project antlr4 by antlr.
the class Antlr4MojoTest method importsCustomLayout.
@Test
public void importsCustomLayout() throws Exception {
Path baseDir = resources.getBasedir("importsCustom").toPath();
Path antlrDir = baseDir.resolve("src/main/antlr4");
Path generatedSources = baseDir.resolve("src/main/java");
Path genTestLexer = generatedSources.resolve("foo/TestLexer.java");
Path genTestParser = generatedSources.resolve("foo/TestParser.java");
Path genHello = generatedSources.resolve("foo/HelloParser.java");
Path baseGrammar = antlrDir.resolve("imports/TestBaseLexer.g4");
Path lexerGrammar = antlrDir.resolve("TestLexer.g4");
Path parserGrammar = antlrDir.resolve("TestParser.g4");
Xpp3Dom outputDirectory = TestMavenRuntime.newParameter("outputDirectory", "src/main/java/foo");
Xpp3Dom arguments = new Xpp3Dom("arguments");
arguments.addChild(TestMavenRuntime.newParameter("argument", "-package"));
arguments.addChild(TestMavenRuntime.newParameter("argument", "foo"));
MavenProject project = maven.readMavenProject(baseDir.toFile());
MavenSession session = maven.newMavenSession(project);
MojoExecution exec = maven.newMojoExecution("antlr4", outputDirectory, arguments);
// //////////////////////////////////////////////////////////////////////
// 1st - all grammars have to be processed
// //////////////////////////////////////////////////////////////////////
assertFalse(Files.exists(genHello));
assertFalse(Files.exists(genTestParser));
assertFalse(Files.exists(genTestLexer));
maven.executeMojo(session, project, exec);
assertTrue(Files.exists(genHello));
assertTrue(Files.exists(genTestParser));
assertTrue(Files.exists(genTestLexer));
// //////////////////////////////////////////////////////////////////////
// 2nd - nothing has been modified, no grammars have to be processed
// //////////////////////////////////////////////////////////////////////
{
byte[] testLexerSum = checksum(genTestLexer);
byte[] testParserSum = checksum(genTestParser);
byte[] helloSum = checksum(genHello);
maven.executeMojo(session, project, exec);
assertTrue(Arrays.equals(testLexerSum, checksum(genTestLexer)));
assertTrue(Arrays.equals(testParserSum, checksum(genTestParser)));
assertTrue(Arrays.equals(helloSum, checksum(genHello)));
}
// modify the grammar to make checksum comparison detect a change
try (Change change = Change.of(baseGrammar, "DOT: '.' ;")) {
byte[] testLexerSum = checksum(genTestLexer);
byte[] testParserSum = checksum(genTestParser);
byte[] helloSum = checksum(genHello);
maven.executeMojo(session, project, exec);
assertFalse(Arrays.equals(testLexerSum, checksum(genTestLexer)));
assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
assertTrue(Arrays.equals(helloSum, checksum(genHello)));
}
// modify the grammar to make checksum comparison detect a change
try (Change change = Change.of(lexerGrammar, "fragment DOT : '.';")) {
byte[] testLexerSum = checksum(genTestLexer);
byte[] testParserSum = checksum(genTestParser);
byte[] helloSum = checksum(genHello);
maven.executeMojo(session, project, exec);
assertFalse(Arrays.equals(testLexerSum, checksum(genTestLexer)));
assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
assertTrue(Arrays.equals(helloSum, checksum(genHello)));
}
// modify the grammar to make checksum comparison detect a change
try (Change change = Change.of(parserGrammar, " t : WS* ;")) {
byte[] testLexerSum = checksum(genTestLexer);
byte[] testParserSum = checksum(genTestParser);
byte[] helloSum = checksum(genHello);
maven.executeMojo(session, project, exec);
assertTrue(Arrays.equals(testLexerSum, checksum(genTestLexer)));
assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
assertTrue(Arrays.equals(helloSum, checksum(genHello)));
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project xtext-xtend by eclipse.
the class AbstractXtendCompilerMojo method getBootClassPath.
private String getBootClassPath() {
Toolchain toolchain = toolchainManager.getToolchainFromBuildContext("jdk", session);
if (toolchain instanceof DefaultJavaToolChain) {
DefaultJavaToolChain javaToolChain = (DefaultJavaToolChain) toolchain;
getLog().info("Using toolchain " + javaToolChain);
if (javaSourceVersion != null) {
JavaVersion version = JavaVersion.fromQualifier(javaSourceVersion);
if (version.isAtLeast(JavaVersion.JAVA9)) {
// bootclasspath only supported on Java8 and older
return "";
}
}
String[] includes = { "jre/lib/*", "jre/lib/ext/*", "jre/lib/endorsed/*" };
String[] excludes = new String[0];
Xpp3Dom config = (Xpp3Dom) javaToolChain.getModel().getConfiguration();
if (config != null) {
Xpp3Dom bootClassPath = config.getChild("bootClassPath");
if (bootClassPath != null) {
Xpp3Dom includeParent = bootClassPath.getChild("includes");
if (includeParent != null) {
includes = getValues(includeParent.getChildren("include"));
}
Xpp3Dom excludeParent = bootClassPath.getChild("excludes");
if (excludeParent != null) {
excludes = getValues(excludeParent.getChildren("exclude"));
}
}
}
return scanBootclasspath(javaToolChain.getJavaHome(), includes, excludes);
}
return "";
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project gradle by gradle.
the class Maven2Gradle method globalExclusions.
private void globalExclusions(MavenProject project, BuildScriptBuilder builder) {
Plugin enforcerPlugin = plugin("maven-enforcer-plugin", project);
PluginExecution enforceGoal = pluginGoal("enforce", enforcerPlugin);
if (enforceGoal != null) {
Xpp3Dom configuration = (Xpp3Dom) enforceGoal.getConfiguration();
Xpp3Dom bannedDependencies = configuration.getChild("rules").getChild("bannedDependencies");
if (bannedDependencies != null) {
Xpp3Dom[] children = bannedDependencies.getChild("excludes").getChildren();
ScriptBlockBuilder block = builder.block(null, "configurations.all");
if (children != null) {
for (Xpp3Dom exclude : children) {
String[] tokens = exclude.getValue().split(":");
Map<String, String> params = new LinkedHashMap<>();
params.put("group", tokens[0]);
if (tokens.length > 1 && !tokens[1].equals("*")) {
params.put("module", tokens[1]);
}
block.methodInvocation(null, "exclude", params);
}
}
}
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project gradle by gradle.
the class Maven2Gradle method compilerSettings.
private void compilerSettings(MavenProject project, BuildScriptBuilder builder) {
String source = "1.8";
String target = "1.8";
Plugin compilerPlugin = plugin("maven-compiler-plugin", project);
if (compilerPlugin != null) {
Xpp3Dom configuration = (Xpp3Dom) compilerPlugin.getConfiguration();
if (configuration != null) {
Xpp3Dom configuredSource = configuration.getChild("source");
Xpp3Dom configuredTarget = configuration.getChild("target");
if (configuredSource != null && !configuredSource.getValue().trim().isEmpty()) {
source = configuredSource.getValue();
}
if (configuredTarget != null && !configuredTarget.getValue().trim().isEmpty()) {
target = configuredTarget.getValue();
}
}
}
builder.propertyAssignment(null, "java.sourceCompatibility", JavaVersion.toVersion(source));
if (!target.equals(source)) {
builder.propertyAssignment(null, "java.targetCompatibility", JavaVersion.toVersion(target));
}
String encoding = (String) project.getProperties().get("project.build.sourceEncoding");
if (StringUtils.isNotEmpty(encoding)) {
builder.taskPropertyAssignment(null, "JavaCompile", "options.encoding", encoding);
}
}
Aggregations