Java Code Examples for org.codehaus.plexus.util.xml.Xpp3Dom#setAttribute()
The following examples show how to use
org.codehaus.plexus.util.xml.Xpp3Dom#setAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DescriptorConverter.java From helidon-build-tools with Apache License 2.0 | 6 votes |
static void convert(ArchetypeDescriptor descriptor, Writer writer) { Xpp3Dom properties = new Xpp3Dom("requiredProperties"); for (Property p : descriptor.properties()) { if (!p.isExported()) { continue; } Xpp3Dom prop = new Xpp3Dom("requiredProperty"); prop.setAttribute("key", p.id()); if (p.value().isPresent()) { Xpp3Dom defaultValue = new Xpp3Dom("defaultValue"); defaultValue.setValue(p.value().get()); prop.addChild(defaultValue); } properties.addChild(prop); } Xpp3Dom root = new Xpp3Dom("archetype-descriptor"); root.addChild(properties); Xpp3DomWriter.write(writer, root); }
Example 2
Source File: MavenExecutionResultHandler.java From pipeline-maven-plugin with MIT License | 6 votes |
@Override protected boolean _handle(MavenExecutionResult result) { Xpp3Dom root = new Xpp3Dom("MavenExecutionResult"); root.setAttribute("class", result.getClass().getName()); for (MavenProject project : result.getTopologicallySortedProjects()) { BuildSummary summary = result.getBuildSummary(project); if (summary == null) { Xpp3Dom comment = new Xpp3Dom("comment"); comment.setValue("No build summary found for maven project: " + project); root.addChild(comment); } else { Xpp3Dom buildSummary = newElement("buildSummary", project); root.addChild(buildSummary); buildSummary.setAttribute("class", summary.getClass().getName()); buildSummary.setAttribute("time", Long.toString(summary.getTime())); } } reporter.print(root); return true; }
Example 3
Source File: ProjectStartedExecutionHandler.java From pipeline-maven-plugin with MIT License | 6 votes |
@Override protected void addDetails(@Nonnull ExecutionEvent executionEvent, @Nonnull Xpp3Dom root) { super.addDetails(executionEvent, root); MavenProject parentProject = executionEvent.getProject().getParent(); if (parentProject == null) { // nothing to do } else { Xpp3Dom parentProjectElt = new Xpp3Dom("parentProject"); root.addChild(parentProjectElt); parentProjectElt.setAttribute("name", parentProject.getName()); parentProjectElt.setAttribute("groupId", parentProject.getGroupId()); parentProjectElt.setAttribute("artifactId", parentProject.getArtifactId()); parentProjectElt.setAttribute("version", parentProject.getVersion()); } }
Example 4
Source File: AbstractMavenEventHandler.java From pipeline-maven-plugin with MIT License | 6 votes |
public Xpp3Dom newElement(@Nonnull String name, @Nullable Throwable t) { Xpp3Dom rootElt = new Xpp3Dom(name); if (t == null) { return rootElt; } rootElt.setAttribute("class", t.getClass().getName()); Xpp3Dom messageElt = new Xpp3Dom("message"); rootElt.addChild(messageElt); messageElt.setValue(removeAnsiColor(t.getMessage())); Xpp3Dom stackTraceElt = new Xpp3Dom("stackTrace"); rootElt.addChild(stackTraceElt); StringWriter stackTrace = new StringWriter(); t.printStackTrace(new PrintWriter(stackTrace, true)); stackTraceElt.setValue(removeAnsiColor(stackTrace.toString())); return rootElt; }
Example 5
Source File: ArtifactDeployedEventHandler.java From pipeline-maven-plugin with MIT License | 6 votes |
protected Xpp3Dom newElement(@Nonnull String name, @Nullable org.eclipse.aether.artifact.Artifact artifact) { Xpp3Dom element = new Xpp3Dom(name); if (artifact == null) { return element; } element.setAttribute("id", artifact.toString()); element.setAttribute("groupId", artifact.getGroupId()); element.setAttribute("artifactId", artifact.getArtifactId()); element.setAttribute("baseVersion", artifact.getBaseVersion()); element.setAttribute("version", artifact.getVersion()); element.setAttribute("classifier", artifact.getClassifier()); element.setAttribute("snapshot", String.valueOf(artifact.isSnapshot())); element.setAttribute("file", artifact.getFile().getAbsolutePath()); element.setAttribute("extension", artifact.getExtension()); return element; }
Example 6
Source File: ArtifactDeployedEventHandler.java From pipeline-maven-plugin with MIT License | 5 votes |
protected Xpp3Dom newElement(String name, @Nullable org.eclipse.aether.repository.ArtifactRepository repository) { Xpp3Dom element = new Xpp3Dom(name); if (repository == null) { return element; } element.setAttribute("id", repository.getId()); element.setAttribute("layout", repository.getContentType()); String repoString = repository.toString(); element.setAttribute("url", repoString.substring(repoString.indexOf("(") + 1, repoString.indexOf(","))); return element; }
Example 7
Source File: ArtifactDeployedEventHandler.java From pipeline-maven-plugin with MIT License | 5 votes |
protected Xpp3Dom newElement(@Nullable org.eclipse.aether.RepositoryEvent event) { Xpp3Dom element = new Xpp3Dom("RepositoryEvent"); if (event == null) { return element; } element.setAttribute("class", event.getClass().getName()); element.setAttribute("type", event.getType().toString()); element.addChild(newElement("artifact", event.getArtifact())); element.addChild(newElement("repository", event.getRepository())); return element; }
Example 8
Source File: AbstractMavenEventHandler.java From pipeline-maven-plugin with MIT License | 5 votes |
public Xpp3Dom newElement(@Nonnull String name, @Nullable Artifact artifact) { Xpp3Dom element = new Xpp3Dom(name); if (artifact == null) { return element; } element.setAttribute("groupId", artifact.getGroupId()); element.setAttribute("artifactId", artifact.getArtifactId()); element.setAttribute("baseVersion", artifact.getBaseVersion()); element.setAttribute("version", artifact.getVersion()); element.setAttribute("snapshot", String.valueOf(artifact.isSnapshot())); if (artifact.getClassifier() != null) { element.setAttribute("classifier", artifact.getClassifier()); } element.setAttribute("type", artifact.getType()); element.setAttribute("id", artifact.getId()); ArtifactHandler artifactHandler = artifact.getArtifactHandler(); String extension; if (artifactHandler == null) { extension = artifact.getType(); } else { extension = artifactHandler.getExtension(); } element.setAttribute("extension", extension); return element; }
Example 9
Source File: MojoUtils.java From quarkus with Apache License 2.0 | 5 votes |
public Xpp3Dom toDom() { Xpp3Dom dom = new Xpp3Dom(name); if (text != null) { dom.setValue(text); } for (Element e : children) { dom.addChild(e.toDom()); } for (Attribute attribute : attributes.attributes) { dom.setAttribute(attribute.name, attribute.value); } return dom; }
Example 10
Source File: MavenExecutionRequestHandler.java From pipeline-maven-plugin with MIT License | 5 votes |
@Override protected boolean _handle(MavenExecutionRequest request) { Xpp3Dom root = new Xpp3Dom("MavenExecutionRequest"); root.setAttribute("class", request.getClass().getName()); root.addChild(newElement("pom", request.getPom())); root.addChild(newElement("globalSettingsFile", request.getGlobalSettingsFile())); root.addChild(newElement("userSettingsFile", request.getUserSettingsFile())); root.addChild(newElement("baseDirectory", request.getBaseDirectory())); reporter.print(root); return true; }
Example 11
Source File: DefaultSettingsBuildingRequestHandler.java From pipeline-maven-plugin with MIT License | 5 votes |
@Override public boolean _handle(DefaultSettingsBuildingRequest request) { Xpp3Dom root = new Xpp3Dom("DefaultSettingsBuildingRequest"); root.setAttribute("class", request.getClass().getName()); root.addChild(newElement("userSettingsFile", request.getUserSettingsFile())); root.addChild(newElement("globalSettings", request.getGlobalSettingsFile())); reporter.print(root); return true; }
Example 12
Source File: MojoExecutionService.java From jkube with Eclipse Public License 2.0 | 5 votes |
private Xpp3Dom toXpp3Dom(PlexusConfiguration config) { Xpp3Dom result = new Xpp3Dom(config.getName()); result.setValue(config.getValue(null)); for (String name : config.getAttributeNames()) { result.setAttribute(name, config.getAttribute(name)); } for (PlexusConfiguration child : config.getChildren()) { result.addChild(toXpp3Dom(child)); } return result; }
Example 13
Source File: DependencyResolutionRequestHandler.java From pipeline-maven-plugin with MIT License | 5 votes |
@Override protected boolean _handle(DependencyResolutionRequest request) { Xpp3Dom root = new Xpp3Dom("DependencyResolutionRequest"); root.setAttribute("class", request.getClass().getName()); root.addChild(newElement("project", request.getMavenProject())); reporter.print(root); return true; }
Example 14
Source File: AppengineEnhancerMojo.java From appengine-maven-plugin with Apache License 2.0 | 5 votes |
private Xpp3Dom convertPlexusConfiguration(PlexusConfiguration config) { Xpp3Dom xpp3DomElement = new Xpp3Dom(config.getName()); xpp3DomElement.setValue(config.getValue()); for (String name : config.getAttributeNames()) { xpp3DomElement.setAttribute(name, config.getAttribute(name)); } for (PlexusConfiguration child : config.getChildren()) { xpp3DomElement.addChild(convertPlexusConfiguration(child)); } return xpp3DomElement; }
Example 15
Source File: MavenHelper.java From sarl with Apache License 2.0 | 5 votes |
/** Convert a Plexus configuration to its XML equivalent. * * @param config the Plexus configuration. * @return the XML configuration. * @throws PlexusConfigurationException in case of problem. * @since 0.8 */ public Xpp3Dom toXpp3Dom(PlexusConfiguration config) throws PlexusConfigurationException { final Xpp3Dom result = new Xpp3Dom(config.getName()); result.setValue(config.getValue(null)); for (final String name : config.getAttributeNames()) { result.setAttribute(name, config.getAttribute(name)); } for (final PlexusConfiguration child : config.getChildren()) { result.addChild(toXpp3Dom(child)); } return result; }
Example 16
Source File: AppengineEnhancerMojo.java From gcloud-maven-plugin with Apache License 2.0 | 5 votes |
private Xpp3Dom convertPlexusConfiguration(PlexusConfiguration config) { Xpp3Dom xpp3DomElement = new Xpp3Dom(config.getName()); xpp3DomElement.setValue(config.getValue()); for (String name : config.getAttributeNames()) { xpp3DomElement.setAttribute(name, config.getAttribute(name)); } for (PlexusConfiguration child : config.getChildren()) { xpp3DomElement.addChild(convertPlexusConfiguration(child)); } return xpp3DomElement; }
Example 17
Source File: MojoExecutionService.java From docker-maven-plugin with Apache License 2.0 | 5 votes |
private Xpp3Dom toXpp3Dom(PlexusConfiguration config) { Xpp3Dom result = new Xpp3Dom(config.getName()); result.setValue(config.getValue(null)); for (String name : config.getAttributeNames()) { result.setAttribute(name, config.getAttribute(name)); } for (PlexusConfiguration child : config.getChildren()) { result.addChild(toXpp3Dom(child)); } return result; }
Example 18
Source File: FileMavenEventReporter.java From pipeline-maven-plugin with MIT License | 4 votes |
@Override public synchronized void print(Xpp3Dom element) { element.setAttribute("_time", new Timestamp(System.currentTimeMillis()).toString()); Xpp3DomWriter.write(xmlWriter, element); XmlWriterUtil.writeLineBreak(xmlWriter); }
Example 19
Source File: AbstractExecutionHandler.java From pipeline-maven-plugin with MIT License | 4 votes |
@Override public boolean _handle(@Nonnull ExecutionEvent executionEvent) { List<String> configurationParameters = getConfigurationParametersToReport(executionEvent); Xpp3Dom root = new Xpp3Dom("ExecutionEvent"); root.setAttribute("class", executionEvent.getClass().getName()); root.setAttribute("type", executionEvent.getType().name()); root.addChild(newElement("project", executionEvent.getProject())); MojoExecution execution = executionEvent.getMojoExecution(); if (execution == null) { root.addChild(new Xpp3Dom("no-execution-found")); } else { Xpp3Dom plugin = new Xpp3Dom("plugin"); root.addChild(plugin); plugin.setAttribute("groupId", execution.getGroupId()); plugin.setAttribute("artifactId", execution.getArtifactId()); plugin.setAttribute("goal", execution.getGoal()); plugin.setAttribute("version", execution.getVersion()); if (execution.getExecutionId() != null) { // See JENKINS-47508, caused by plugin being declared and invoked by the <reports> section plugin.setAttribute("executionId", execution.getExecutionId()); } if (execution.getLifecyclePhase() != null) { // protect against null lifecyclePhase. cause is NOT clear plugin.setAttribute("lifecyclePhase", execution.getLifecyclePhase()); } for (String configurationParameter : configurationParameters) { Xpp3Dom element = fullClone(configurationParameter, execution.getConfiguration().getChild(configurationParameter)); if (element != null) { plugin.addChild(element); } } } addDetails(executionEvent, root); if(executionEvent.getException() != null) { root.addChild(newElement("exception", executionEvent.getException())); } reporter.print(root); return true; }
Example 20
Source File: DependencyResolutionResultHandler.java From pipeline-maven-plugin with MIT License | 4 votes |
@Override protected boolean _handle(DependencyResolutionResult result) { Xpp3Dom root = new Xpp3Dom("DependencyResolutionResult"); root.setAttribute("class", result.getClass().getName()); Xpp3Dom dependenciesElt = new Xpp3Dom("resolvedDependencies"); root.addChild(dependenciesElt); for (Dependency dependency : result.getResolvedDependencies()) { Artifact artifact = dependency.getArtifact(); if ( !includedScopes.contains(dependency.getScope())) { continue; } if (!includeSnapshots && artifact.isSnapshot()) { continue; } if(!includeReleases && !artifact.isSnapshot()) { continue; } Xpp3Dom dependencyElt = new Xpp3Dom("dependency"); dependencyElt.addChild(newElement("file", artifact.getFile().getAbsolutePath())); dependencyElt.setAttribute("name", artifact.getFile().getName()); dependencyElt.setAttribute("groupId", artifact.getGroupId()); dependencyElt.setAttribute("artifactId", artifact.getArtifactId()); dependencyElt.setAttribute("version", artifact.getVersion()); dependencyElt.setAttribute("baseVersion", artifact.getBaseVersion()); if (artifact.getClassifier() != null) { dependencyElt.setAttribute("classifier", artifact.getClassifier()); } dependencyElt.setAttribute("type", artifact.getExtension()); dependencyElt.setAttribute("id", artifact.getArtifactId()); dependencyElt.setAttribute("extension", artifact.getExtension()); dependencyElt.setAttribute("scope", dependency.getScope()); dependencyElt.setAttribute("optional", Boolean.toString(dependency.isOptional())); dependencyElt.setAttribute("snapshot", Boolean.toString(artifact.isSnapshot())); dependenciesElt.addChild(dependencyElt); } reporter.print(root); return true; }