本文整理汇总了Java中org.codehaus.plexus.util.xml.pull.XmlPullParserException类的典型用法代码示例。如果您正苦于以下问题:Java XmlPullParserException类的具体用法?Java XmlPullParserException怎么用?Java XmlPullParserException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlPullParserException类属于org.codehaus.plexus.util.xml.pull包,在下文中一共展示了XmlPullParserException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putMapping
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
/**
* Store a particular action mapping.
* @param mapp an action mapping model
* @param project a Maven project
* @param config a configuration of that project
* @throws IOException in case of trouble
* @since 2.19
*/
public static void putMapping(NetbeansActionMapping mapp, Project project, ProjectConfiguration config) throws IOException {
M2Configuration cfg = (M2Configuration) config;
ActionToGoalMapping mapping;
try {
mapping = new NetbeansBuildActionXpp3Reader().read(new StringReader(cfg.getRawMappingsAsString()));
} catch (XmlPullParserException x) {
throw new IOException(x);
}
NetbeansActionMapping existing = null;
for (NetbeansActionMapping m : mapping.getActions()) {
if (m.getActionName().equals(mapp.getActionName())) {
existing = m;
break;
}
}
if (existing != null) {
mapping.getActions().set(mapping.getActions().indexOf(existing), mapp);
} else {
mapping.addAction(mapp);
}
CustomizerProviderImpl.writeNbActionsModel(project, mapping, M2Configuration.getFileNameExt(cfg.getId()));
}
示例2: findMapAction
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
private NetbeansActionMapping findMapAction(Map<String, String> replaceMap, Project project, String actionName) throws XmlPullParserException, IOException {
// TODO need some caching really badly here..
Reader read = performDynamicSubstitutions(replaceMap, getRawMappingsAsString());
ActionToGoalMapping mapping = reader.read(read);
Iterator<NetbeansActionMapping> it = mapping.getActions().iterator();
NetbeansActionMapping action = null;
NbMavenProject mp = project.getLookup().lookup(NbMavenProject.class);
String prjPack = mp.getPackagingType();
while (it.hasNext()) {
NetbeansActionMapping elem = it.next();
if (actionName.equals(elem.getActionName()) &&
(elem.getPackagings().contains(prjPack.trim()) ||
elem.getPackagings().contains("*") || elem.getPackagings().isEmpty())) {//NOI18N
action = elem;
break;
}
}
return action;
}
示例3: getIntegerValue
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
/**
* Method getIntegerValue.
*
* @param s
* @param strict
* @param parser
* @param attribute
* @throws XmlPullParserException
* @return int
*/
public int getIntegerValue(String s, String attribute, XmlPullParser parser, boolean strict)
throws XmlPullParserException
{
if ( s != null )
{
try
{
return Integer.valueOf( s ).intValue();
}
catch ( NumberFormatException e )
{
if ( strict )
{
throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, null );
}
}
}
return 0;
}
示例4: getLongValue
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
/**
* Method getLongValue.
*
* @param s
* @param strict
* @param parser
* @param attribute
* @throws XmlPullParserException
* @return long
*/
public long getLongValue(String s, String attribute, XmlPullParser parser, boolean strict)
throws XmlPullParserException
{
if ( s != null )
{
try
{
return Long.valueOf( s ).longValue();
}
catch ( NumberFormatException e )
{
if ( strict )
{
throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, null );
}
}
}
return 0;
}
示例5: changeVersionTest
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void changeVersionTest() throws IOException, XmlPullParserException {
Model pomModelBeforeChange = getOriginalPomModel("pom.xml");
assertEquals(pomModelBeforeChange.getParent().getVersion(), "1.0");
PomChangeParent pomChangeParent = new PomChangeParent("2.0").relative("pom.xml");
assertNull(pomChangeParent.getGroupId());
assertNull(pomChangeParent.getArtifactId());
assertEquals(pomChangeParent.getVersion(), "2.0");
TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);
assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file pom.xml");
assertNull(executionResult.getException());
Model pomModelAfterChange = getTransformedPomModel("pom.xml");
assertEquals(pomModelAfterChange.getParent().getVersion(), "2.0");
}
示例6: changeParentTest
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void changeParentTest() throws IOException, XmlPullParserException {
Model pomModelBeforeChange = getOriginalPomModel("pom.xml");
assertEquals(pomModelBeforeChange.getParent().getGroupId(), "com.test");
assertEquals(pomModelBeforeChange.getParent().getArtifactId(), "foo-parent");
assertEquals(pomModelBeforeChange.getParent().getVersion(), "1.0");
PomChangeParent pomChangeParent = new PomChangeParent().setGroupId("com.newgroupid").setArtifactId("newartifactid").setVersion("2.0").relative("pom.xml");
assertEquals(pomChangeParent.getGroupId(), "com.newgroupid");
assertEquals(pomChangeParent.getArtifactId(), "newartifactid");
assertEquals(pomChangeParent.getVersion(), "2.0");
TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);
assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file pom.xml");
assertNull(executionResult.getException());
Model pomModelAfterChange = getTransformedPomModel("pom.xml");
assertEquals(pomModelAfterChange.getParent().getGroupId(), "com.newgroupid");
assertEquals(pomModelAfterChange.getParent().getArtifactId(), "newartifactid");
assertEquals(pomModelAfterChange.getParent().getVersion(), "2.0");
}
示例7: failTest
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void failTest() throws IOException, XmlPullParserException, CloneNotSupportedException {
Model pomModelBeforeChange = getOriginalPomModel("/src/main/resources/no_parent_pom.xml");
assertNull(pomModelBeforeChange.getParent());
PomChangeParent pomChangeParent = new PomChangeParent("2.0").relative("/src/main/resources/no_parent_pom.xml");
assertNull(pomChangeParent.getGroupId());
assertNull(pomChangeParent.getArtifactId());
assertEquals(pomChangeParent.getVersion(), "2.0");
TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR);
assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file /src/main/resources/no_parent_pom.xml");
assertEquals(executionResult.getException().getClass(), TransformationOperationException.class);
assertEquals(executionResult.getException().getMessage(), "Pom file /src/main/resources/no_parent_pom.xml does not have a parent");
Model pomModelAfterChange = getTransformedPomModel("/src/main/resources/no_parent_pom.xml");
assertNull(pomModelAfterChange.getParent());
executionResult = pomChangeParent.clone().failIfNotPresent().execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR);
}
示例8: noOpTest
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void noOpTest() throws IOException, XmlPullParserException {
Model pomModelBeforeChange = getOriginalPomModel("/src/main/resources/no_parent_pom.xml");
assertNull(pomModelBeforeChange.getParent());
PomChangeParent pomChangeParent = new PomChangeParent("2.0").relative("/src/main/resources/no_parent_pom.xml").noOpIfNotPresent();
assertNull(pomChangeParent.getGroupId());
assertNull(pomChangeParent.getArtifactId());
assertEquals(pomChangeParent.getVersion(), "2.0");
TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.NO_OP);
assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file /src/main/resources/no_parent_pom.xml");
assertNull(executionResult.getException());
Model pomModelAfterChange = getTransformedPomModel("/src/main/resources/no_parent_pom.xml");
assertNull(pomModelAfterChange.getParent());
}
示例9: warnTest
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void warnTest() throws IOException, XmlPullParserException {
Model pomModelBeforeChange = getOriginalPomModel("/src/main/resources/no_parent_pom.xml");
assertNull(pomModelBeforeChange.getParent());
PomChangeParent pomChangeParent = new PomChangeParent("2.0").relative("/src/main/resources/no_parent_pom.xml").warnIfNotPresent();
assertNull(pomChangeParent.getGroupId());
assertNull(pomChangeParent.getArtifactId());
assertEquals(pomChangeParent.getVersion(), "2.0");
TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.WARNING);
assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file /src/main/resources/no_parent_pom.xml");
assertNull(executionResult.getException());
assertEquals(executionResult.getWarnings().size(), 1);
assertEquals(executionResult.getWarnings().get(0).getClass(), TransformationOperationException.class);
assertEquals(executionResult.getWarnings().get(0).getMessage(), "Pom file /src/main/resources/no_parent_pom.xml does not have a parent");
Model pomModelAfterChange = getTransformedPomModel("/src/main/resources/no_parent_pom.xml");
assertNull(pomModelAfterChange.getParent());
}
示例10: invalidOperationTest
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void invalidOperationTest() throws IOException, XmlPullParserException {
// You have to either set the version only, or the group id AND artifact id AND version.
// Here only the group id is being set
PomChangeParent pomChangeParent = new PomChangeParent().setGroupId("com.test").relative("pom.xml");
assertEquals(pomChangeParent.getGroupId(), "com.test");
assertNull(pomChangeParent.getArtifactId());
assertNull(pomChangeParent.getVersion());
TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR);
assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file pom.xml");
assertEquals(executionResult.getException().getClass(), TransformationOperationException.class);
assertEquals(executionResult.getException().getMessage(), "Invalid POM parent transformation operation");
Model pomModelAfterChange = getTransformedPomModel("pom.xml");
assertEquals(pomModelAfterChange.getParent().getGroupId(), "com.test");
assertEquals(pomModelAfterChange.getParent().getArtifactId(), "foo-parent");
assertEquals(pomModelAfterChange.getParent().getVersion(), "1.0");
}
示例11: addPluginWithVersionTest
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void addPluginWithVersionTest() throws IOException, XmlPullParserException {
Model pomModelBeforeChange = getOriginalPomModel("pom.xml");
assertEquals(pomModelBeforeChange.getBuild().getPlugins().size(), 1);
assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getGroupId(), "org.codehaus.mojo");
assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getArtifactId(), "cobertura-maven-plugin");
PomAddPlugin pomAddPlugin = new PomAddPlugin("org.apache.maven.plugins", "maven-javadoc-plugin", "2.10.4").relative("pom.xml");
TOExecutionResult executionResult = pomAddPlugin.execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);
Model pomModelAfterChange = getTransformedPomModel("pom.xml");
assertEquals(pomModelAfterChange.getBuild().getPlugins().size(), 2);
Plugin plugin = new Plugin();
plugin.setGroupId("org.apache.maven.plugins");
plugin.setArtifactId("maven-javadoc-plugin");
assertTrue(pomModelAfterChange.getBuild().getPlugins().contains(plugin));
assertEquals(pomModelAfterChange.getBuild().getPluginsAsMap().get("org.apache.maven.plugins:maven-javadoc-plugin").getVersion(), "2.10.4");
}
示例12: addPluginWithoutVersionTest
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void addPluginWithoutVersionTest() throws IOException, XmlPullParserException {
Model pomModelBeforeChange = getOriginalPomModel("pom.xml");
assertEquals(pomModelBeforeChange.getBuild().getPlugins().size(), 1);
assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getGroupId(), "org.codehaus.mojo");
assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getArtifactId(), "cobertura-maven-plugin");
PomAddPlugin pomAddPlugin = new PomAddPlugin("org.apache.maven.plugins", "maven-javadoc-plugin").relative("pom.xml");
TOExecutionResult executionResult = pomAddPlugin.execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);
Model pomModelAfterChange = getTransformedPomModel("pom.xml");
assertEquals(pomModelAfterChange.getBuild().getPlugins().size(), 2);
Plugin plugin = new Plugin();
plugin.setGroupId("org.apache.maven.plugins");
plugin.setArtifactId("maven-javadoc-plugin");
assertTrue(pomModelAfterChange.getBuild().getPlugins().contains(plugin));
assertNull(pomModelAfterChange.getBuild().getPluginsAsMap().get("org.apache.maven.plugins:maven-javadoc-plugin").getVersion());
}
示例13: defaultIfPresentTest
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void defaultIfPresentTest() throws IOException, XmlPullParserException {
Model pomModelBeforeChange = getOriginalPomModel("pom.xml");
assertEquals(pomModelBeforeChange.getBuild().getPlugins().size(), 1);
assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getGroupId(), "org.codehaus.mojo");
assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getArtifactId(), "cobertura-maven-plugin");
// Trying to add the same plugin
PomAddPlugin pomAddPlugin = new PomAddPlugin().setArtifact("org.codehaus.mojo:cobertura-maven-plugin").relative("pom.xml");
TOExecutionResult executionResult = pomAddPlugin.execution(transformedAppFolder, transformationContext);
assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR);
assertNull(executionResult.getDetails());
assertEquals(executionResult.getException().getMessage(), "Plugin org.codehaus.mojo:cobertura-maven-plugin is already present in pom.xml");
Model pomModelAfterChange = getTransformedPomModel("pom.xml");
assertEquals(pomModelAfterChange.getBuild().getPlugins().size(), 1);
assertEquals(pomModelAfterChange.getBuild().getPlugins().size(), 1);
assertEquals(pomModelAfterChange.getBuild().getPlugins().get(0).getGroupId(), "org.codehaus.mojo");
assertEquals(pomModelAfterChange.getBuild().getPlugins().get(0).getArtifactId(), "cobertura-maven-plugin");
}
示例14: fromPom
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
public static CarnotzetModuleCoordinates fromPom(@NonNull Path pom) {
Model result;
try {
BufferedReader in = new BufferedReader(Files.newBufferedReader(pom, StandardCharsets.UTF_8));
MavenXpp3Reader reader = new MavenXpp3Reader();
result = reader.read(in);
}
catch (XmlPullParserException | IOException e) {
throw new CarnotzetDefinitionException(e);
}
String groupId = result.getGroupId();
String version = result.getVersion();
if (groupId == null) {
groupId = result.getParent().getGroupId();
}
if (version == null) {
version = result.getParent().getVersion();
}
return new CarnotzetModuleCoordinates(groupId, result.getArtifactId(), version, null);
}
示例15: getEnforcerPlugin
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
public Plugin getEnforcerPlugin(MavenProject project)
throws MavenExecutionException {
StringBuilder configString = new StringBuilder()
.append("<configuration><rules>")
.append("<requireReleaseDeps><message>No Snapshots Allowed!</message><excludes><exclude>"+project.getGroupId()+":*</exclude></excludes></requireReleaseDeps>")
.append("</rules></configuration>");
Xpp3Dom config = null;
try {
config = Xpp3DomBuilder.build(new StringReader(configString.toString()));
} catch (XmlPullParserException | IOException ex) {
throw new MavenExecutionException("Issue creating cofig for enforcer plugin", ex);
}
PluginExecution execution = new PluginExecution();
execution.setId("no-snapshot-deps");
execution.addGoal("enforce");
execution.setConfiguration(config);
Plugin result = new Plugin();
result.setArtifactId("maven-enforcer-plugin");
result.setVersion("1.4.1");
result.addExecution(execution);
return result;
}