use of org.codehaus.plexus.util.xml.Xpp3Dom in project tycho by eclipse.
the class OsgiSourceMojo method isRelevantProjectImpl.
protected static boolean isRelevantProjectImpl(MavenProject project, BuildPropertiesParser buildPropertiesParser) {
String packaging = project.getPackaging();
boolean relevant = PackagingType.TYPE_ECLIPSE_PLUGIN.equals(packaging) || PackagingType.TYPE_ECLIPSE_TEST_PLUGIN.equals(packaging);
if (!relevant) {
return false;
}
// this assumes that sources generation has to be explicitly enabled in pom.xml
Plugin plugin = project.getPlugin("org.eclipse.tycho:tycho-source-plugin");
if (plugin == null) {
return false;
}
for (PluginExecution execution : plugin.getExecutions()) {
if (execution.getGoals().contains(GOAL)) {
boolean requireSourceRoots = Boolean.parseBoolean(getParameterValue(execution, "requireSourceRoots", "false"));
if (requireSourceRoots) {
return true;
}
boolean hasAdditionalFilesets = getConfigurationElement((Xpp3Dom) execution.getConfiguration(), "additionalFileSets") != null;
if (hasAdditionalFilesets) {
return true;
}
BuildProperties buildProperties = buildPropertiesParser.parse(project.getBasedir());
if (buildProperties.getJarToSourceFolderMap().size() > 0 || buildProperties.getSourceIncludes().size() > 0) {
return true;
}
}
}
return false;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project tycho by eclipse.
the class OsgiSourceMojoTest method createStubProject.
private MavenProject createStubProject(String packaging, String testResourceFolder, boolean enableSourePlugin, boolean requireSourceRoots) {
MavenProject stubProject = new MavenProject();
stubProject.setPackaging(packaging);
if (enableSourePlugin) {
Build build = new Build();
stubProject.setBuild(build);
Plugin tychoSourcePlugin = new Plugin();
tychoSourcePlugin.setGroupId("org.eclipse.tycho");
tychoSourcePlugin.setArtifactId("tycho-source-plugin");
PluginExecution execution = new PluginExecution();
execution.setGoals(asList("plugin-source"));
if (requireSourceRoots) {
Xpp3Dom config = new Xpp3Dom("configuration");
Xpp3Dom requireSourceRootsDom = new Xpp3Dom("requireSourceRoots");
requireSourceRootsDom.setValue("true");
config.addChild(requireSourceRootsDom);
execution.setConfiguration(config);
}
tychoSourcePlugin.setExecutions(asList(execution));
build.setPlugins(asList(tychoSourcePlugin));
}
stubProject.setFile(new File("src/test/resources/sourceMojo/" + testResourceFolder + "/pom.xml"));
return stubProject;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project tycho by eclipse.
the class AbstractTychoMojoTestCase method lookupMojoWithDefaultConfiguration.
/**
* Returns a mojo configured with the mojo's default configuration.
*/
// workaround for MPLUGINTESTING-46 - see http://jira.codehaus.org/browse/MPLUGINTESTING-46
protected Mojo lookupMojoWithDefaultConfiguration(MavenProject project, MavenSession session, String goal) throws Exception {
MojoExecution mojoExecution = newMojoExecution(goal);
Xpp3Dom defaultConfiguration = mojoExecution.getConfiguration();
// the ResolverExpressionEvaluatorStub of lookupMojo is not sufficient to evaluate the variables in the default configuration
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, mojoExecution);
ComponentConfigurator configurator = getContainer().lookup(ComponentConfigurator.class, "basic");
Mojo mojo = lookupEmptyMojo(goal, project.getFile());
configurator.configureComponent(mojo, new XmlPlexusConfiguration(defaultConfiguration), expressionEvaluator, getContainer().getContainerRealm(), null);
return mojo;
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project mule by mulesoft.
the class DeployableMavenClassLoaderModelLoader method exportSharedLibrariesResourcesAndPackages.
private void exportSharedLibrariesResourcesAndPackages(File applicationFolder, ClassLoaderModelBuilder classLoaderModelBuilder, Set<BundleDependency> dependencies) {
Model model = loadPomModel(applicationFolder);
Build build = model.getBuild();
if (build != null) {
List<Plugin> plugins = build.getPlugins();
if (plugins != null) {
Optional<Plugin> packagingPluginOptional = plugins.stream().filter(plugin -> plugin.getArtifactId().equals(MULE_MAVEN_PLUGIN_ARTIFACT_ID) && plugin.getGroupId().equals(MULE_MAVEN_PLUGIN_GROUP_ID)).findFirst();
packagingPluginOptional.ifPresent(packagingPlugin -> {
Object configuration = packagingPlugin.getConfiguration();
if (configuration != null) {
Xpp3Dom sharedLibrariesDom = ((Xpp3Dom) configuration).getChild("sharedLibraries");
if (sharedLibrariesDom != null) {
Xpp3Dom[] sharedLibraries = sharedLibrariesDom.getChildren("sharedLibrary");
if (sharedLibraries != null) {
FileJarExplorer fileJarExplorer = new FileJarExplorer();
for (Xpp3Dom sharedLibrary : sharedLibraries) {
String groupId = getSharedLibraryAttribute(applicationFolder, sharedLibrary, "groupId");
String artifactId = getSharedLibraryAttribute(applicationFolder, sharedLibrary, "artifactId");
Optional<BundleDependency> bundleDependencyOptional = dependencies.stream().filter(bundleDependency -> bundleDependency.getDescriptor().getArtifactId().equals(artifactId) && bundleDependency.getDescriptor().getGroupId().equals(groupId)).findFirst();
bundleDependencyOptional.map(bundleDependency -> {
JarInfo jarInfo = fileJarExplorer.explore(bundleDependency.getBundleUri());
classLoaderModelBuilder.exportingPackages(jarInfo.getPackages());
classLoaderModelBuilder.exportingResources(jarInfo.getResources());
return bundleDependency;
}).orElseThrow(() -> new MuleRuntimeException(I18nMessageFactory.createStaticMessage(format("Dependency %s:%s could not be found within the artifact %s. It must be declared within the maven dependencies of the artifact.", groupId, artifactId, applicationFolder.getName()))));
}
}
}
}
});
}
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project mule by mulesoft.
the class DeployableMavenClassLoaderModelLoader method getSharedLibraryAttribute.
private String getSharedLibraryAttribute(File applicationFolder, Xpp3Dom sharedLibraryDom, String attributeName) {
Xpp3Dom attributeDom = sharedLibraryDom.getChild(attributeName);
checkState(attributeDom != null, format("%s element was not defined within the shared libraries declared in the pom file of the artifact %s", attributeName, applicationFolder.getName()));
String attributeValue = attributeDom.getValue().trim();
checkState(!isEmpty(attributeValue), format("%s was defined but has an empty value within the shared libraries declared in the pom file of the artifact %s", attributeName, applicationFolder.getName()));
return attributeValue;
}
Aggregations