Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSHARED-1080] Parent POM 36, Java8, drop legacy. #38

Merged
merged 6 commits into from Jun 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
91 changes: 51 additions & 40 deletions pom.xml
Expand Up @@ -23,7 +23,8 @@
<parent>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-components</artifactId>
<version>34</version>
<version>36</version>
<relativePath/>
</parent>

<artifactId>maven-filtering</artifactId>
Expand Down Expand Up @@ -54,8 +55,10 @@
</distributionManagement>

<properties>
<javaVersion>8</javaVersion>
<mavenVersion>3.2.5</mavenVersion>
<javaVersion>7</javaVersion>
<slf4jVersion>1.7.36</slf4jVersion>
<plexusBuildApiVersion>0.0.7</plexusBuildApiVersion>
<project.build.outputTimestamp>2020-08-05T15:18:01Z</project.build.outputTimestamp>
</properties>

Expand All @@ -66,39 +69,43 @@
</contributors>

<dependencies>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4jVersion}</version>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>${plexusBuildApiVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<version>${mavenVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<version>0.3.0.M1</version><!-- Maven 3.2.5 -->
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>3.3.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.3.0</version><!-- Java 7 -->
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand All @@ -108,25 +115,13 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version><!-- Java 7 -->
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
<scope>test</scope>
<classifier>tests</classifier>
<version>2.11.0</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.28.2</version><!-- Java 7 -->
<version>4.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -141,21 +136,37 @@
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4jVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>${plexusBuildApiVersion}</version>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<executions>
<execution>
<goals>
<goal>generate-metadata</goal>
</goals>
</execution>
</executions>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
michael-o marked this conversation as resolved.
Show resolved Hide resolved
</plugin>
</plugins>
</build>
Expand Down
26 changes: 15 additions & 11 deletions src/main/java/org/apache/maven/shared/filtering/BaseFilter.java
Expand Up @@ -32,8 +32,6 @@
import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.shared.utils.io.FileUtils;
import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
import org.codehaus.plexus.interpolation.Interpolator;
import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor;
Expand All @@ -44,15 +42,21 @@
import org.codehaus.plexus.interpolation.SingleResponseValueSource;
import org.codehaus.plexus.interpolation.ValueSource;
import org.codehaus.plexus.interpolation.multi.MultiDelimiterStringSearchInterpolator;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class BaseFilter
extends AbstractLogEnabled
implements DefaultFilterInfo
{
private final Logger logger = LoggerFactory.getLogger( getClass() );

protected Logger getLogger()
{
return logger;
}

@Override
public List<FileUtils.FilterWrapper> getDefaultFilterWrappers( final MavenProject mavenProject,
public List<FilterWrapper> getDefaultFilterWrappers( final MavenProject mavenProject,
List<String> filters,
final boolean escapedBackslashesInFilePath,
MavenSession mavenSession,
Expand All @@ -73,7 +77,7 @@ public List<FileUtils.FilterWrapper> getDefaultFilterWrappers( final MavenProjec
}

@Override
public List<FileUtils.FilterWrapper> getDefaultFilterWrappers( final AbstractMavenFilteringRequest request )
public List<FilterWrapper> getDefaultFilterWrappers( final AbstractMavenFilteringRequest request )
throws MavenFilteringException
{
// backup values
Expand Down Expand Up @@ -158,7 +162,7 @@ public List<FileUtils.FilterWrapper> getDefaultFilterWrappers( final AbstractMav
filterProperties.putAll( request.getAdditionalProperties() );
}

List<FileUtils.FilterWrapper> defaultFilterWrappers = new ArrayList<>( request.getDelimiters().size() + 1 );
List<FilterWrapper> defaultFilterWrappers = new ArrayList<>( request.getDelimiters().size() + 1 );

if ( getLogger().isDebugEnabled() )
{
Expand All @@ -171,7 +175,7 @@ public List<FileUtils.FilterWrapper> getDefaultFilterWrappers( final AbstractMav

final ValueSource propertiesValueSource = new PropertiesBasedValueSource( filterProperties );

FileUtils.FilterWrapper wrapper =
FilterWrapper wrapper =
new Wrapper( request.getDelimiters(), request.getMavenProject(), request.getMavenSession(),
propertiesValueSource, request.getProjectStartExpressions(), request.getEscapeString(),
request.isEscapeWindowsPaths(), request.isSupportMultiLineFiltering() );
Expand All @@ -195,14 +199,14 @@ void loadProperties( Properties filterProperties, File basedir, List<String> pro

for ( String filterFile : propertiesFilePaths )
{
if ( StringUtils.isEmpty( filterFile ) )
if ( filterFile == null || filterFile.trim().isEmpty() )
{
// skip empty file name
continue;
}
try
{
File propFile = FileUtils.resolveFile( basedir, filterFile );
File propFile = FilteringUtils.resolveFile( basedir, filterFile );
Properties properties = PropertyUtils.loadPropertyFile( propFile, workProperties, getLogger() );
filterProperties.putAll( properties );
workProperties.putAll( properties );
Expand All @@ -216,7 +220,7 @@ void loadProperties( Properties filterProperties, File basedir, List<String> pro
}

private static final class Wrapper
extends FileUtils.FilterWrapper
extends FilterWrapper
{

private LinkedHashSet<String> delimiters;
Expand Down
Expand Up @@ -23,7 +23,6 @@

import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.utils.io.FileUtils;

/**
* @author Kristian Rosenvold
Expand All @@ -41,7 +40,7 @@ public interface DefaultFilterInfo
* @return {@link java.util.List} of FileUtils.FilterWrapper
* @since 1.0-beta-2
*/
List<FileUtils.FilterWrapper> getDefaultFilterWrappers( MavenProject mavenProject, List<String> filters,
List<FilterWrapper> getDefaultFilterWrappers( MavenProject mavenProject, List<String> filters,
boolean escapedBackslashesInFilePath,
MavenSession mavenSession,
MavenResourcesExecution mavenResourcesExecution )
Expand All @@ -53,6 +52,6 @@ List<FileUtils.FilterWrapper> getDefaultFilterWrappers( MavenProject mavenProjec
* @return {@link java.util.List} of FileUtils.FilterWrapper
* @since 1.0-beta-3
*/
List<FileUtils.FilterWrapper> getDefaultFilterWrappers( AbstractMavenFilteringRequest request )
List<FilterWrapper> getDefaultFilterWrappers( AbstractMavenFilteringRequest request )
throws MavenFilteringException;
}
Expand Up @@ -19,32 +19,36 @@
* under the License.
*/

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.sonatype.plexus.build.incremental.BuildContext;

import static java.util.Objects.requireNonNull;

/**
* @author Olivier Lamy
*/
@Component( role = org.apache.maven.shared.filtering.MavenFileFilter.class, hint = "default" )
@Singleton
@Named
public class DefaultMavenFileFilter
extends BaseFilter
implements MavenFileFilter
{
private final BuildContext buildContext;

@Requirement
private MavenReaderFilter readerFilter;
michael-o marked this conversation as resolved.
Show resolved Hide resolved

@Requirement
private BuildContext buildContext;
@Inject
public DefaultMavenFileFilter( BuildContext buildContext )
{
this.buildContext = requireNonNull( buildContext );
}

@Override
public void copyFile( File from, File to, boolean filtering, MavenProject mavenProject, List<String> filters,
Expand All @@ -58,7 +62,7 @@ public void copyFile( File from, File to, boolean filtering, MavenProject mavenP
mre.setMavenSession( mavenSession );
mre.setInjectProjectBuildFilters( true );

List<FileUtils.FilterWrapper> filterWrappers = getDefaultFilterWrappers( mre );
List<FilterWrapper> filterWrappers = getDefaultFilterWrappers( mre );
copyFile( from, to, filtering, filterWrappers, encoding );
}

Expand All @@ -73,7 +77,7 @@ public void copyFile( MavenFileFilterRequest mavenFileFilterRequest )
}

@Override
public void copyFile( File from, File to, boolean filtering, List<FileUtils.FilterWrapper> filterWrappers,
public void copyFile( File from, File to, boolean filtering, List<FilterWrapper> filterWrappers,
String encoding )
throws MavenFilteringException
{
Expand All @@ -82,7 +86,7 @@ public void copyFile( File from, File to, boolean filtering, List<FileUtils.Filt
}

@Override
public void copyFile( File from, File to, boolean filtering, List<FileUtils.FilterWrapper> filterWrappers,
public void copyFile( File from, File to, boolean filtering, List<FilterWrapper> filterWrappers,
String encoding, boolean overwrite )
throws MavenFilteringException
{
Expand All @@ -95,15 +99,15 @@ public void copyFile( File from, File to, boolean filtering, List<FileUtils.Filt
getLogger().debug( "filtering " + from.getPath() + " to " + to.getPath() );
}
FilterWrapper[] array = filterWrappers.toArray( new FilterWrapper[0] );
FileUtils.copyFile( from, to, encoding, array, false );
FilteringUtils.copyFile( from, to, encoding, array, false );
}
else
{
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "copy " + from.getPath() + " to " + to.getPath() );
}
FileUtils.copyFile( from, to, encoding, new FileUtils.FilterWrapper[0], overwrite );
FilteringUtils.copyFile( from, to, encoding, new FilterWrapper[0], overwrite );
}

buildContext.refresh( to );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't something used by m2e? or not anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from a repo that is last touched 12 years ago, and is archived. IMHO is dead, parrot dead, but we can tinker about it if you want 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a quick search on github shows this https://github.com/search?q=org%3Aeclipse-m2e+BuildContext&type=code
for sure this very old repo is just interface which doesn't need much changes so that's probably the reason.

disclaimer i'm not using m2e so... 🤣

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing the point: this parrot is dead. Very. Also, whatever it is, this was first attempt to implement incremental build, followed by two other attempts (by same person), that finally materialized in something completely different. So, yes, this may look "stable", the very same way dead parrot looks "stable" (well, not moving, is it?), but is superseded by several other attempts...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe but I can see references of it in the m2e code.
Is it really used or not? I have no idea as I'm not a contributor of m2e.
My opinion is just it worth to ask those folks as we may or not break something.
if not perfect but it worth the courtesy of simply asking.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not a rant. you point to a repo mentioning it's the logical successor.
whereas my point is by removing this you will affect all m2e users which is probably hundreds thousands even million(s) of users.
By pointing the repo I'm just saying m2e has a lot of contribution/maintenance and users compared to the repo you mention.
Even if I agree this was a bad idea/design (and as the guy who started the maven-filtering I didn't like it long time ago neither but it has been done...) but now it's here and use by a lot of people.
so we live with that or we discuss with m2e folks a replacement solution or at least ask them what are the impacts removing this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I get it correctly, what you say is "buildcontext prevails over takari/incrementalbuild as m2e has more commits"? 🦘 LOL, well, I am about to stop here.... 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I get it correctly, what you say is "buildcontext prevails over takari/incrementalbuild as m2e has more commits"? 🦘 LOL, well, I am about to stop here.... 😆

no sorry but you do not read correctly, the most important is the number of users impacted.
and here in m2e is a lot!
what is better it's not the question here.
again I'm just saying the impacted users number is really huge!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frankly looking at commit history m2e has more maintenance than https://github.com/takari/io.takari.incrementalbuild (last commit almost 2 yo ago).

And who said this then?

Anyway, lets bury the boomerang, sisu build api is raised from the dead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and my 5 cents to whole this topic: I never saw a "plain" (explained later) Maven project that is fairly more complex than "hello world" and works OOTB in m2e. Work, as in no "tweaks", "m2e profile in POM" needed etc. OTOH, I did saw Maven project using takari lifecycle that WORK perfectly and OOTB in m2e.

But alas, takari lifecycle use the "inferior" incrementalbuild and not buildcontext API. Oh, and it also replaces many things from Maven itself, and even ditches this maven-filtering and replaces it's with it's own to be functional 😄

("plain" as Maven build w/o any extension, while takari-lifecycle is an extension and replaces a LOT from maven, like core copmponets but also shared stuff like this maven-filtering and many plugins as well)

Expand Down
Expand Up @@ -19,19 +19,21 @@
* under the License.
*/

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.Reader;
import java.util.Collections;
import java.util.List;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper;
import org.codehaus.plexus.component.annotations.Component;

/**
* @author Kristian Rosenvold
*/
@Component( role = org.apache.maven.shared.filtering.MavenReaderFilter.class, hint = "default" )
@Singleton
@Named
public class DefaultMavenReaderFilter
extends BaseFilter
implements MavenReaderFilter
Expand Down