rfscholte commented on a change in pull request #286: [MNG-6656] Introduce base for build/consumer process URL: https://github.com/apache/maven/pull/286#discussion_r330265590
########## File path: maven-xml/src/main/java/org/apache/maven/xml/filter/BuildPomXMLFilterFactory.java ########## @@ -0,0 +1,95 @@ +package org.apache.maven.xml.filter; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.nio.file.Path; +import java.util.Optional; +import java.util.function.Function; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; + +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + +/** + * + * @author Robert Scholte + * + * @since 3.7.0 + */ +public abstract class BuildPomXMLFilterFactory +{ + public final BuildPomXMLFilter get( Path projectFile ) + throws SAXException, ParserConfigurationException + { + XMLReader parent = getParent(); + + if ( getDependencyKeyToVersionMapper() != null ) + { + ReactorDependencyXMLFilter reactorDependencyXMLFilter = + new ReactorDependencyXMLFilter( getDependencyKeyToVersionMapper() ); + reactorDependencyXMLFilter.setParent( parent ); + parent = reactorDependencyXMLFilter; + } + + if ( getRelativePathMapper() != null ) + { + ParentXMLFilter parentFilter = new ParentXMLFilter( getRelativePathMapper() ); + parentFilter.setProjectPath( projectFile.getParent() ); + parentFilter.setParent( parent ); + parent = parentFilter; + } + + CiFriendlyXMLFilter ciFriendlyFilter = new CiFriendlyXMLFilter(); + getChangelist().ifPresent( ciFriendlyFilter::setChangelist ); + getRevision().ifPresent( ciFriendlyFilter::setRevision ); + getSha1().ifPresent( ciFriendlyFilter::setSha1 ); + + if ( ciFriendlyFilter.isSet() ) + { + ciFriendlyFilter.setParent( parent ); + parent = ciFriendlyFilter; + } + + return new BuildPomXMLFilter( parent ); + } + + protected XMLReader getParent() throws SAXException, ParserConfigurationException + { + XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); + xmlReader.setFeature( "http://xml.org/sax/features/namespaces", true ); Review comment: Ah, I see. The problem is: even though it looks like a URL, it is just the key of this feature. Not including it will mean namespaces will be ignored. Some unittests will show you the issue. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
