Skip to content

Commit

Permalink
Upgrade to Maven 4.0.0-alpha-9
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Dec 4, 2023
1 parent 35757db commit 4e980bd
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 95 deletions.
47 changes: 28 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
<version>39</version>
<version>41</version>
</parent>

<artifactId>maven-resources-plugin</artifactId>
Expand Down Expand Up @@ -72,7 +72,8 @@ under the License.

<properties>
<mavenFilteringVersion>4.0.0-SNAPSHOT</mavenFilteringVersion>
<mavenVersion>4.0.0-alpha-5</mavenVersion>
<mavenVersion>4.0.0-alpha-9-SNAPSHOT</mavenVersion>
<mavenPluginPluginVersion>3.10.3-SNAPSHOT</mavenPluginPluginVersion>
<javaVersion>8</javaVersion>
<project.build.outputTimestamp>2023-03-21T12:01:37Z</project.build.outputTimestamp>
</properties>
Expand All @@ -86,46 +87,54 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<artifactId>maven-api-model</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<version>2.0.1</version>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interpolation</artifactId>
<version>1.26</version>
<scope>runtime</scope>
</dependency>
<!--
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<version>0.3.5</version>
<version>0.9.0.M2</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.5.1</version>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xml</artifactId>
<version>4.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId>
<version>${mavenFilteringVersion}</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
Expand All @@ -135,7 +144,7 @@ under the License.
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>4.0.0-alpha-1</version>
<version>4.0.0-alpha-3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -161,12 +170,12 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.8.1</version>
<version>${mavenPluginPluginVersion}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M8</version>
<version>3.2.1</version>
</plugin>
</plugins>
</build>
Expand All @@ -180,7 +189,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<configuration>
<debug>true</debug>
<postBuildHookScript>verify</postBuildHookScript>
Expand Down
2 changes: 1 addition & 1 deletion src/it/MRESOURCES-18/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ under the License.
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<version>3.2.1</version>
<configuration>
<systemProperties>
<!-- pass this system property through to the tests -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.apache.maven.api.plugin.annotations.Mojo;
import org.apache.maven.api.plugin.annotations.Parameter;
import org.apache.maven.shared.filtering.Resource;

/**
* Copy resources of the configured plugin attribute resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
*/
package org.apache.maven.plugins.resources;

/**
* @author Olivier Lamy
* @since 2.3
*
*/
public class Resource extends org.apache.maven.model.Resource {
// nothing to do here just a class prevent users adding an implementation attribute
// in the mojo configuration
import org.apache.maven.shared.filtering.Resource;

public Resource() {}
class ResourceUtils {

public Resource(org.apache.maven.api.model.Resource delegate) {
super(delegate);
static Resource newResource(org.apache.maven.api.model.Resource res) {
Resource resource = new Resource();
resource.setDirectory(res.getDirectory());
resource.setFiltering(res.isFiltering());
resource.setExcludes(res.getExcludes());
resource.setIncludes(res.getIncludes());
resource.setMergeId(res.getMergeId());
resource.setTargetPath(res.getTargetPath());
return resource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.maven.plugins.resources;

import javax.inject.Inject;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -30,18 +28,18 @@
import java.util.Properties;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import jakarta.inject.Inject;
import org.apache.maven.api.Project;
import org.apache.maven.api.Session;
import org.apache.maven.api.plugin.Log;
import org.apache.maven.api.plugin.MojoException;
import org.apache.maven.api.plugin.annotations.Component;
import org.apache.maven.api.plugin.annotations.LifecyclePhase;
import org.apache.maven.api.plugin.annotations.Mojo;
import org.apache.maven.api.plugin.annotations.Parameter;
import org.apache.maven.shared.filtering.MavenFilteringException;
import org.apache.maven.shared.filtering.MavenResourcesExecution;
import org.apache.maven.shared.filtering.MavenResourcesFiltering;
import org.apache.maven.shared.filtering.Resource;

/**
* Copy resources for the main source code to the main output directory. Always uses the project.build.resources element
Expand All @@ -52,7 +50,7 @@
* @author Andreas Hoheneder
* @author William Ferguson
*/
@Mojo(name = "resources", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, requiresProject = true)
@Mojo(name = "resources", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, projectRequired = true)
public class ResourcesMojo implements org.apache.maven.api.plugin.Mojo {

/**
Expand Down Expand Up @@ -85,7 +83,7 @@ public class ResourcesMojo implements org.apache.maven.api.plugin.Mojo {
/**
*
*/
@Parameter(defaultValue = "${project}", readonly = true, required = true)
@Inject
protected Project project;

/**
Expand Down Expand Up @@ -127,19 +125,19 @@ public class ResourcesMojo implements org.apache.maven.api.plugin.Mojo {
/**
*
*/
@Component(role = MavenResourcesFiltering.class, hint = "default")
@Inject
protected MavenResourcesFiltering mavenResourcesFiltering;

/**
*
*/
@Component(role = MavenResourcesFiltering.class)
@Inject
protected Map<String, MavenResourcesFiltering> mavenResourcesFilteringMap;

/**
*
*/
@Parameter(defaultValue = "${session}", readonly = true, required = true)
@Inject
protected Session session;

/**
Expand Down Expand Up @@ -300,15 +298,15 @@ public void execute() throws MojoException {

if (resources == null) {
resources = project.getBuild().getResources().stream()
.map(Resource::new)
.map(ResourceUtils::newResource)
.collect(Collectors.toList());
}

doExecute();
}

protected void doExecute() throws MojoException {
if (StringUtils.isBlank(encoding) && isFilteringEnabled(getResources())) {
if ((encoding == null || encoding.isEmpty()) && isFilteringEnabled(getResources())) {
getLog().warn("File encoding has not been set, using platform encoding "
+ System.getProperty("file.encoding")
+ ". Build is platform dependent!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.maven.api.plugin.annotations.LifecyclePhase;
import org.apache.maven.api.plugin.annotations.Mojo;
import org.apache.maven.api.plugin.annotations.Parameter;
import org.apache.maven.shared.filtering.Resource;

/**
* Copy resources for the test source code to the test output directory.
Expand All @@ -34,7 +35,7 @@
* @author <a href="[email protected]">Michal Maczka</a>
* @author <a href="mailto:[email protected]">Jason van Zyl</a>
*/
@Mojo(name = "testResources", defaultPhase = LifecyclePhase.PROCESS_TEST_RESOURCES, requiresProject = true)
@Mojo(name = "testResources", defaultPhase = LifecyclePhase.PROCESS_TEST_RESOURCES, projectRequired = true)
public class TestResourcesMojo extends ResourcesMojo {
/**
* The output directory into which to copy the resources.
Expand Down Expand Up @@ -67,7 +68,7 @@ public void execute() throws MojoException {

if (resources == null) {
resources = project.getBuild().getTestResources().stream()
.map(Resource::new)
.map(ResourceUtils::newResource)
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
import java.util.Collections;

import com.google.inject.Provides;
import org.apache.maven.api.Session;
import org.apache.maven.api.Project;
import org.apache.maven.api.plugin.testing.InjectMojo;
import org.apache.maven.api.plugin.testing.MojoTest;
import org.apache.maven.api.plugin.testing.stubs.ProjectStub;
import org.apache.maven.api.plugin.testing.stubs.SessionStub;
import org.apache.maven.internal.impl.InternalSession;
import org.apache.maven.plugins.resources.stub.MavenProjectResourcesStub;
import org.apache.maven.shared.filtering.Resource;
import org.codehaus.plexus.util.FileUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -84,7 +87,14 @@ public void testCopyWithoutFiltering(ResourcesMojo mojo) throws Exception {
@Provides
@Singleton
@SuppressWarnings("unused")
private Session getMockSession() {
private InternalSession getMockSession() {
return SessionStub.getMockSession(LOCAL_REPO);
}

@Provides
@Singleton
@SuppressWarnings("unused")
private Project createProject() {
return new ProjectStub();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,6 @@
*/
package org.apache.maven.plugins.resources;

/*
* 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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -51,12 +32,14 @@

import com.google.inject.Provides;
import com.google.inject.Singleton;
import org.apache.maven.api.Session;
import org.apache.maven.api.Project;
import org.apache.maven.api.plugin.testing.InjectMojo;
import org.apache.maven.api.plugin.testing.MojoTest;
import org.apache.maven.api.plugin.testing.stubs.ProjectStub;
import org.apache.maven.api.plugin.testing.stubs.SessionStub;
import org.apache.maven.model.Resource;
import org.apache.maven.internal.impl.InternalSession;
import org.apache.maven.plugins.resources.stub.MavenProjectResourcesStub;
import org.apache.maven.shared.filtering.Resource;
import org.junit.jupiter.api.Test;

import static org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject;
Expand Down Expand Up @@ -630,11 +613,20 @@ private void assertContent(String fileName, String data) throws IOException {
@Provides
@Singleton
@SuppressWarnings("unused")
private Session getMockSession() {
private InternalSession getMockSession() {
return SessionStub.getMockSession(LOCAL_REPO);
}

@Provides
@Singleton
@SuppressWarnings("unused")
private Project createProject() {
return new ProjectStub();
}

private List<Resource> getResources(MavenProjectResourcesStub project) {
return project.getBuild().getResources().stream().map(Resource::new).collect(Collectors.toList());
return project.getBuild().getResources().stream()
.map(ResourceUtils::newResource)
.collect(Collectors.toList());
}
}
Loading

0 comments on commit 4e980bd

Please sign in to comment.