diff --git a/pom/plugin.jelly b/pom/plugin.jelly index bfbc5a4b..d3d8ed29 100644 --- a/pom/plugin.jelly +++ b/pom/plugin.jelly @@ -65,15 +65,20 @@ - - + + + + + + - + *** WARNING *** - *** The current pom extends + *** The current pom extends ${parent} *** This parent pom has to be validated separately! @@ -93,7 +98,7 @@ - + Using xsd file: ${xsd} diff --git a/pom/project.xml b/pom/project.xml index 3fab9c3f..7af839c6 100644 --- a/pom/project.xml +++ b/pom/project.xml @@ -18,7 +18,7 @@ */ --> - + ../plugin-parent/project.xml 3 maven-pom-plugin diff --git a/pom/src/main/org/apache/maven/PomUtils.java b/pom/src/main/org/apache/maven/PomUtils.java new file mode 100644 index 00000000..5bfac0f8 --- /dev/null +++ b/pom/src/main/org/apache/maven/PomUtils.java @@ -0,0 +1,96 @@ +package org.apache.maven; + +/* ==================================================================== + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +import java.io.*; +import javax.xml.parsers.*; +import org.w3c.dom.*; +import org.xml.sax.*; + +/** + * Some utility methods. + * @author Lukas Theussl + */ +public class PomUtils +{ + private File file; + private String parent; + + /** The parent. + * @return The parent + */ + public String getParent() + { + return parent; + } + + /** The file. + * @return The file + */ + public File getFile() + { + return file; + } + + /** + * Sets the file. + * @param newFile The file to set + */ + public void setFile(File newFile) + { + this.file = newFile; + } + + /** The file. + * @return True if the file contains . + */ + public boolean extend() + { + Document doc = parseXmlFile(file, false); + NodeList list = doc.getElementsByTagName("extend"); + boolean extend = false; + if ( list.getLength() > 0 ) + { + extend = true; + Element element = (Element) list.item(0); + try + { + Node firstChild = element.getFirstChild(); + parent = firstChild.getNodeValue(); + } catch (DOMException e) { + } + } + return extend; + } + + private Document parseXmlFile(File filename, boolean validating) + { + try + { + DocumentBuilderFactory factory = + DocumentBuilderFactory.newInstance(); + factory.setValidating(validating); + Document doc = factory.newDocumentBuilder().parse(filename); + return doc; + } catch (SAXException e) { + } catch (ParserConfigurationException e) { + } catch (IOException e) { + } + return null; + } +} diff --git a/pom/src/plugin-resources/xsd/pom-strict-3.xsd b/pom/src/plugin-resources/xsd/pom-strict-3.xsd index 8ad14d86..98eb977a 100644 --- a/pom/src/plugin-resources/xsd/pom-strict-3.xsd +++ b/pom/src/plugin-resources/xsd/pom-strict-3.xsd @@ -18,6 +18,7 @@ --> + 3.0.0+