[ https://issues.apache.org/jira/browse/MNG-6656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17538442#comment-17538442 ]
ASF GitHub Bot commented on MNG-6656: ------------------------------------- gnodet commented on code in PR #286: URL: https://github.com/apache/maven/pull/286#discussion_r875216366 ########## maven-xml/src/main/java/org/apache/maven/xml/sax/filter/FastForwardFilter.java: ########## @@ -0,0 +1,128 @@ +package org.apache.maven.xml.sax.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.util.ArrayDeque; +import java.util.Deque; + +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; +import org.xml.sax.XMLFilter; +import org.xml.sax.XMLReader; +import org.xml.sax.ext.LexicalHandler; + +/** + * This filter will skip all following filters and write directly to the output. + * Should be used in case of a DOM that should not be effected by other filters, even though the elements match + * + * @author Robert Scholte + * @since 3.7.0 + */ +class FastForwardFilter extends AbstractSAXFilter +{ + /** + * DOM elements of pom + * + * <ul> + * <li>execution.configuration</li> + * <li>plugin.configuration</li> + * <li>plugin.goals</li> + * <li>profile.reports</li> + * <li>project.reports</li> + * <li>reportSet.configuration</li> + * <ul> + */ + private final Deque<String> state = new ArrayDeque<>(); + + private int domDepth = 0; + + private ContentHandler originalHandler; + + FastForwardFilter() + { + super(); + } + + <T extends XMLReader & LexicalHandler> FastForwardFilter( T parent ) + { + super( parent ); + } + + @Override + public void startElement( String uri, String localName, String qName, Attributes atts ) + throws SAXException + { + super.startElement( uri, localName, qName, atts ); + if ( domDepth > 0 ) + { + domDepth++; + } + else + { + final String key = state.peek() + '.' + localName; + switch ( key ) + { + case "execution.configuration": + case "plugin.configuration": + case "plugin.goals": + case "profile.reports": + case "project.reports": + case "reportSet.configuration": + domDepth++; + + originalHandler = getContentHandler(); + + ContentHandler outputContentHandler = getContentHandler(); Review Comment: There's a call to `enable()` / `disable()` on the delegate parser. I'll have to add a unit test in order to debug what is happening and see where the problem is ... > Introduce base for build/consumer process > ----------------------------------------- > > Key: MNG-6656 > URL: https://issues.apache.org/jira/browse/MNG-6656 > Project: Maven > Issue Type: New Feature > Components: POM > Reporter: Robert Scholte > Assignee: Robert Scholte > Priority: Major > Fix For: 4.0.0-alpha-1, 4.0.0 > > Attachments: MNG-6656.zip > > Time Spent: 10m > Remaining Estimate: 0h > > The pom.xml as we know it has reached it limits, but it is quite hard to do > improvements as long as the local pom (as part of the sources) is exactly the > same as the file being published. > For the Maven eco system it is important that the published file will still > be a model 4.0.0 to ensure other projects can still depend on these artifacts. > This will be a first step to separate the local pom from the remote pom. The > process to come to the effective pom will change a little bit > pre-build > pom.xml (raw model) -> BuildPomXMLFilter -> inheritence -> effective pom/model > This means that we can enrich the pom to make it a valid effective pom again. > In this case we can do the following: > - resolve the [cifriendly > placeholders|https://maven.apache.org/maven-ci-friendly.html], so it will > work in multimodules too. > - resolve parent-version. By removing the version from the parent, the filter > will get the version based on the relativePath. If the groupId and artifactId > don't match, the version can't be solved and Maven will fail with a missing > version for the parent. > - resolve reactor versions. By removing the versions from reactor > dependencies, the filter will look up the matching version. If there's no > version for the groupId+artifactId, the version can't be solved and Maven > will fail with a missing version for the dependency. > pre-distribution (install/deploy) > pom.xml -> BuildPomXMLFilter -> ConsumerPomXMLFilter -> consumer pom > This means that the XML used to build build the effective pom is used, and > can be adjusted during copy/upload. > In this case we can do the following: > - Remove the modules -elements, since this is local path information and not > useful after building > - Remove the relativePath-element, since this is local path information and > not useful after building > This PoC has the following goals: > - It will give us experience with manipuating files before build AND during > install/deploy. > - We can see IDEs and CI servers can handle this and how we can move forward. > This feature will at first be disabled by default and can be activated with > the System property {{maven.experimental.buildconsumer=true}} -- This message was sent by Atlassian Jira (v8.20.7#820007)