From 74de49339e406eaee5519fe050ef362a83f18519 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 30 Jan 2023 20:21:35 +0100 Subject: [PATCH 01/92] [MINVOKER-313] Get rid of maven-artifact-transfer - InstallMojo refactor - refactor InstallMojo to use Resolver API - add possibility to configure scope for installing artifacts - remove maven-artifact-transfer and maven-common-artifact-filters from dependencies --- pom.xml | 13 - .../invoker.properties | 18 + .../staging-dependencies-test-scope/pom.xml | 71 ++ .../verify.bsh | 65 ++ src/it/staging-dependencies/pom.xml | 6 + src/it/staging-dependencies/verify.bsh | 8 + src/it/staging-pom/pom.xml | 11 + src/it/staging-pom/verify.bsh | 3 + src/it/staging-reactor/verify.bsh | 1 - .../maven/plugins/invoker/InstallMojo.java | 617 +++++++----------- .../maven/plugins/invoker/MetadataUtils.java | 146 ----- 11 files changed, 413 insertions(+), 546 deletions(-) create mode 100644 src/it/staging-dependencies-test-scope/invoker.properties create mode 100644 src/it/staging-dependencies-test-scope/pom.xml create mode 100644 src/it/staging-dependencies-test-scope/verify.bsh delete mode 100644 src/main/java/org/apache/maven/plugins/invoker/MetadataUtils.java diff --git a/pom.xml b/pom.xml index 4bb9610a..26641448 100644 --- a/pom.xml +++ b/pom.xml @@ -183,18 +183,6 @@ under the License. 1.4 - - org.apache.maven.shared - maven-artifact-transfer - 0.13.1 - - - org.apache.maven.shared - maven-common-artifact-filters - 3.2.0 - compile - - ${beanshell-groupId} ${beanshell-artifactId} @@ -411,7 +399,6 @@ under the License. ${project.build.directory}/local-repo src/it/settings.xml -Djava.io.tmpdir=${project.build.directory} - true ${maven.compiler.source} ${maven.compiler.target} diff --git a/src/it/staging-dependencies-test-scope/invoker.properties b/src/it/staging-dependencies-test-scope/invoker.properties new file mode 100644 index 00000000..353946b6 --- /dev/null +++ b/src/it/staging-dependencies-test-scope/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = verify diff --git a/src/it/staging-dependencies-test-scope/pom.xml b/src/it/staging-dependencies-test-scope/pom.xml new file mode 100644 index 00000000..b130f77a --- /dev/null +++ b/src/it/staging-dependencies-test-scope/pom.xml @@ -0,0 +1,71 @@ + + + + + + 4.0.0 + + test + staging-dependencies-test-scope + 1.0-SNAPSHOT + + + Test to check for staging of test scope dependencies. + + + + + + org.slf4j + slf4j-api + 1.7.36 + + + + + org.slf4j + slf4j-simple + 1.7.36 + test + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it-repo + test + + + + integration-test + + install + + + + + + + diff --git a/src/it/staging-dependencies-test-scope/verify.bsh b/src/it/staging-dependencies-test-scope/verify.bsh new file mode 100644 index 00000000..9b32cff2 --- /dev/null +++ b/src/it/staging-dependencies-test-scope/verify.bsh @@ -0,0 +1,65 @@ +/* + * 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.*; +import java.util.*; +import java.util.regex.*; + +import org.codehaus.plexus.util.*; +import org.codehaus.plexus.util.xml.*; + +try +{ + File itRepoDir = new File( basedir, "target/it-repo" ); + System.out.println( "Checking for existence of: " + itRepoDir ); + if ( !itRepoDir.isDirectory() ) + { + System.out.println( "FAILED!" ); + return false; + } + + String[] files = { + "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar", + "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.pom", + "org/slf4j/slf4j-api/maven-metadata-local.xml", + "org/slf4j/slf4j-parent/1.7.36/slf4j-parent-1.7.36.pom", + "org/slf4j/slf4j-parent/maven-metadata-local.xml", + "org/slf4j/slf4j-simple/1.7.36/slf4j-simple-1.7.36.jar", + "org/slf4j/slf4j-simple/1.7.36/slf4j-simple-1.7.36.pom", + "org/slf4j/slf4j-simple/maven-metadata-local.xml", + "test/staging-dependencies-test-scope/1.0-SNAPSHOT/staging-dependencies-test-scope-1.0-SNAPSHOT.pom", + "test/staging-dependencies-test-scope/1.0-SNAPSHOT/staging-dependencies-test-scope-1.0-SNAPSHOT.jar" + }; + for ( String file : files ) + { + File stagedFile = new File( itRepoDir, file ); + System.out.println( "Checking for existence of: " + stagedFile ); + if ( !stagedFile.isFile() ) + { + throw new IllegalStateException( "Missing: " + stagedFile ); + } + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/it/staging-dependencies/pom.xml b/src/it/staging-dependencies/pom.xml index 3aa0840a..31cca75c 100644 --- a/src/it/staging-dependencies/pom.xml +++ b/src/it/staging-dependencies/pom.xml @@ -62,6 +62,12 @@ under the License. dep 2.0 + + org.slf4j + slf4j-simple + 1.7.36 + test + diff --git a/src/it/staging-dependencies/verify.bsh b/src/it/staging-dependencies/verify.bsh index ceb7f022..7e43c8ba 100644 --- a/src/it/staging-dependencies/verify.bsh +++ b/src/it/staging-dependencies/verify.bsh @@ -56,6 +56,8 @@ try "org/apache/maven/its/dep/2.0/dep-2.0.pom", "org/apache/maven/its/dep/2.0/dep-2.0.jar", "org/apache/maven/its/dep/maven-metadata-local.xml", + "test/staging-dependencies/1.0-SNAPSHOT/staging-dependencies-1.0-SNAPSHOT.jar", + "test/staging-dependencies/1.0-SNAPSHOT/staging-dependencies-1.0-SNAPSHOT.pom" }; for ( String file : files ) { @@ -67,6 +69,12 @@ try } } + File stagedTestScope = new File(itRepoDir, "org/slf4j/slf4j-simple"); + if ( stagedTestScope.exists() ) + { + throw new IllegalStateException( "Test scope dependencies should not exists" ); + } + Reader reader = ReaderFactory.newXmlReader( new File( itRepoDir, "org/apache/maven/its/dep/maven-metadata-local.xml" ) ); Xpp3Dom dom = Xpp3DomBuilder.build( reader ); IOUtil.close( reader ); diff --git a/src/it/staging-pom/pom.xml b/src/it/staging-pom/pom.xml index 443a3fc6..e9582c67 100644 --- a/src/it/staging-pom/pom.xml +++ b/src/it/staging-pom/pom.xml @@ -22,6 +22,13 @@ under the License. 4.0.0 + + org.apache.maven.plugins + maven-plugins + 39 + + + test pom-packaging 1.0-SNAPSHOT @@ -31,6 +38,10 @@ under the License. Test to check for MINVOKER-51, i.e. NPE when packaging is pom. + + true + + diff --git a/src/it/staging-pom/verify.bsh b/src/it/staging-pom/verify.bsh index 8565933f..c49ef782 100644 --- a/src/it/staging-pom/verify.bsh +++ b/src/it/staging-pom/verify.bsh @@ -33,6 +33,9 @@ try String[] files = { "test/pom-packaging/1.0-SNAPSHOT/pom-packaging-1.0-SNAPSHOT.pom", + "org/apache/maven/plugins/maven-plugins/39/maven-plugins-39.pom", + "org/apache/maven/maven-parent/39/maven-parent-39.pom", + "org/apache/apache/29/apache-29.pom" }; for ( String file : files ) { diff --git a/src/it/staging-reactor/verify.bsh b/src/it/staging-reactor/verify.bsh index 19f6fa83..9a684fc7 100644 --- a/src/it/staging-reactor/verify.bsh +++ b/src/it/staging-reactor/verify.bsh @@ -44,7 +44,6 @@ try "test/mod2/1.0-SNAPSHOT/maven-metadata-local.xml", "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.pom", "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.jar", - "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT-sources.jar", "test/mod2-parent/maven-metadata-local.xml", "test/mod2-parent/1.0-SNAPSHOT/maven-metadata-local.xml", "test/mod2-parent/1.0-SNAPSHOT/mod2-parent-1.0-SNAPSHOT.pom", diff --git a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java index 1e482873..8c2000d4 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java @@ -19,18 +19,18 @@ package org.apache.maven.plugins.invoker; import java.io.File; -import java.io.IOException; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; +import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.RepositoryUtils; import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.plugin.AbstractMojo; @@ -41,53 +41,60 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter; -import org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller; -import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; -import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; -import org.apache.maven.shared.transfer.repository.RepositoryManager; -import org.codehaus.plexus.util.FileUtils; +import org.apache.maven.project.artifact.ProjectArtifact; +import org.eclipse.aether.DefaultRepositoryCache; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.ArtifactType; +import org.eclipse.aether.artifact.ArtifactTypeRegistry; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.installation.InstallRequest; +import org.eclipse.aether.installation.InstallationException; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.LocalRepositoryManager; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.resolution.ArtifactDescriptorException; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.ArtifactResult; +import org.eclipse.aether.resolution.DependencyRequest; +import org.eclipse.aether.resolution.DependencyResolutionException; +import org.eclipse.aether.resolution.DependencyResult; +import org.eclipse.aether.util.artifact.JavaScopes; +import org.eclipse.aether.util.artifact.SubArtifact; +import org.eclipse.aether.util.filter.DependencyFilterUtils; /** * Installs the project artifacts of the main build into the local repository as a preparation to run the sub projects. * More precisely, all artifacts of the project itself, all its locally reachable parent POMs and all its dependencies * from the reactor will be installed to the local repository. * - * @since 1.2 * @author Paul Gier * @author Benjamin Bentmann - * + * @since 1.2 */ -// CHECKSTYLE_OFF: LineLength @Mojo( name = "install", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, - requiresDependencyResolution = ResolutionScope.RUNTIME, + requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) -// CHECKSTYLE_ON: LineLength public class InstallMojo extends AbstractMojo { - /** - * Maven artifact install component to copy artifacts to the local repository. - */ - @Component - private ArtifactInstaller installer; + // components used in Mojo @Component - private RepositoryManager repositoryManager; + private RepositorySystem repositorySystem; - /** - * The component used to create artifacts. - */ - @Component - private ArtifactFactory artifactFactory; + @Parameter(defaultValue = "${session}", readonly = true, required = true) + private MavenSession session; - /** - */ - @Parameter(property = "localRepository", required = true, readonly = true) - private ArtifactRepository localRepository; + @Parameter(defaultValue = "${project}", readonly = true, required = true) + private MavenProject project; /** * The path to the local repository into which the project artifacts should be installed for the integration tests. @@ -101,21 +108,6 @@ public class InstallMojo extends AbstractMojo { required = true) private File localRepositoryPath; - /** - * The current Maven project. - */ - @Parameter(defaultValue = "${project}", readonly = true, required = true) - private MavenProject project; - - @Parameter(defaultValue = "${session}", readonly = true, required = true) - private MavenSession session; - - /** - * The set of Maven projects in the reactor build. - */ - @Parameter(defaultValue = "${reactorProjects}", readonly = true) - private Collection reactorProjects; - /** * A flag used to disable the installation procedure. This is primarily intended for usage from the command line to * occasionally adjust the build. @@ -126,32 +118,23 @@ public class InstallMojo extends AbstractMojo { private boolean skipInstallation; /** - * The identifiers of already installed artifacts, used to avoid multiple installation of the same artifact. - */ - private Collection installedArtifacts; - - /** - * The identifiers of already copied artifacts, used to avoid multiple installation of the same artifact. - */ - private Collection copiedArtifacts; - - /** - * Extra dependencies that need to be installed on the local repository.
+ * Extra dependencies that need to be installed on the local repository. + *

* Format: - * *

      * groupId:artifactId:version:type:classifier
      * 
- * + *

* Examples: - * *

      * org.apache.maven.plugins:maven-clean-plugin:2.4:maven-plugin
      * org.apache.maven.plugins:maven-clean-plugin:2.4:jar:javadoc
      * 
- * + *

* If the type is 'maven-plugin' the plugin will try to resolve the artifact using plugin remote repositories, * instead of using artifact remote repositories. + *

+ * NOTICE all dependencies will be resolved with transitive dependencies in runtime scope. * * @since 1.6 */ @@ -159,19 +142,12 @@ public class InstallMojo extends AbstractMojo { private String[] extraArtifacts; /** + * Scope to resolve project artifacts. + * + * @since 3.5.0 */ - @Component - private DependencyResolver resolver; - - /** - * if the local repository is not used as test repo, the parameter can force get artifacts from local repo - * if available instead of download the artifacts again. - * @since 3.2.1 - */ - @Parameter(property = "invoker.useLocalRepository", defaultValue = "false") - private boolean useLocalRepository; - - private ProjectBuildingRequest projectBuildingRequest; + @Parameter(property = "invoker.install.scope", defaultValue = "runtime") + private String scope; /** * Performs this mojo's tasks. @@ -184,377 +160,246 @@ public void execute() throws MojoExecutionException { return; } - createTestRepository(); - - installedArtifacts = new HashSet<>(); - copiedArtifacts = new HashSet<>(); + Collection resolvedArtifacts = new ArrayList<>(); - installProjectDependencies(project, reactorProjects); - installProjectParents(project); - installProjectArtifacts(project); + try { - installExtraArtifacts(extraArtifacts); + resolveProjectArtifacts(resolvedArtifacts); + resolveProjectPoms(project, resolvedArtifacts); + resolveProjectDependencies(resolvedArtifacts); + resolveExtraArtifacts(resolvedArtifacts); + installArtifacts(resolvedArtifacts); + + } catch (DependencyResolutionException + | InstallationException + | ArtifactDescriptorException + | ArtifactResolutionException e) { + throw new MojoExecutionException(e.getMessage(), e); + } } - /** - * Creates the local repository for the integration tests. If the user specified a custom repository location, the - * custom repository will have the same identifier, layout and policies as the real local repository. That means - * apart from the location, the custom repository will be indistinguishable from the real repository such that its - * usage is transparent to the integration tests. - * - * @throws MojoExecutionException If the repository could not be created. - */ - private void createTestRepository() throws MojoExecutionException { + private void resolveProjectArtifacts(Collection resolvedArtifacts) { - if (!localRepositoryPath.exists() && !localRepositoryPath.mkdirs()) { - throw new MojoExecutionException("Failed to create directory: " + localRepositoryPath); + // pom packaging doesn't have a main artifact + if (project.getArtifact() != null && project.getArtifact().getFile() != null) { + resolvedArtifacts.add(RepositoryUtils.toArtifact(project.getArtifact())); } - projectBuildingRequest = - repositoryManager.setLocalRepositoryBasedir(session.getProjectBuildingRequest(), localRepositoryPath); + + resolvedArtifacts.addAll(project.getAttachedArtifacts().stream() + .map(RepositoryUtils::toArtifact) + .collect(Collectors.toList())); } - /** - * Installs the specified artifact to the local repository. Note: This method should only be used for artifacts that - * originate from the current (reactor) build. Artifacts that have been grabbed from the user's local repository - * should be installed to the test repository via {@link #copyArtifact(File, Artifact)}. - * - * @param file The file associated with the artifact, must not be null. This is in most cases the value - * of artifact.getFile() with the exception of the main artifact from a project with - * packaging "pom". Projects with packaging "pom" have no main artifact file. They have however artifact - * metadata (e.g. site descriptors) which needs to be installed. - * @param artifact The artifact to install, must not be null. - * @throws MojoExecutionException If the artifact could not be installed (e.g. has no associated file). - */ - private void installArtifact(File file, Artifact artifact) throws MojoExecutionException { - try { - if (file == null) { - throw new IllegalStateException("Artifact has no associated file: " + artifact.getId()); - } - if (!file.isFile()) { - throw new IllegalStateException("Artifact is not fully assembled: " + file); - } + private void resolveProjectPoms(MavenProject project, Collection resolvedArtifacts) + throws ArtifactResolutionException { - if (installedArtifacts.add(artifact.getId())) { - artifact.setFile(file); - installer.install(projectBuildingRequest, localRepositoryPath, Collections.singletonList(artifact)); - } else { - getLog().debug("Not re-installing " + artifact + ", " + file); - } - } catch (Exception e) { - throw new MojoExecutionException("Failed to install artifact: " + artifact, e); + if (project == null) { + return; + } + + Artifact projectPom = RepositoryUtils.toArtifact(new ProjectArtifact(project)); + if (projectPom.getFile() != null) { + resolvedArtifacts.add(projectPom); + } else { + Artifact artifact = resolveArtifact(projectPom, project.getRemoteProjectRepositories()); + resolvedArtifacts.add(artifact); } + resolveProjectPoms(project.getParent(), resolvedArtifacts); } - /** - * Installs the specified artifact to the local repository. This method serves basically the same purpose as - * {@link #installArtifact(File, Artifact)} but is meant for artifacts that have been resolved - * from the user's local repository (and not the current build outputs). The subtle difference here is that - * artifacts from the repository have already undergone transformations and these manipulations should not be redone - * by the artifact installer. For this reason, this method performs plain copy operations to install the artifacts. - * - * @param file The file associated with the artifact, must not be null. - * @param artifact The artifact to install, must not be null. - * @throws MojoExecutionException If the artifact could not be installed (e.g. has no associated file). - */ - private void copyArtifact(File file, Artifact artifact) throws MojoExecutionException { - try { - if (file == null) { - throw new IllegalStateException("Artifact has no associated file: " + artifact.getId()); - } - if (!file.isFile()) { - throw new IllegalStateException("Artifact is not fully assembled: " + file); - } + private void resolveProjectDependencies(Collection resolvedArtifacts) + throws ArtifactResolutionException, MojoExecutionException, DependencyResolutionException { - if (copiedArtifacts.add(artifact.getId())) { - File destination = new File( - localRepositoryPath, - repositoryManager.getPathForLocalArtifact(projectBuildingRequest, artifact)); + DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(scope); - getLog().debug("Installing " + file + " to " + destination); + ArtifactTypeRegistry artifactTypeRegistry = + session.getRepositorySession().getArtifactTypeRegistry(); - copyFileIfDifferent(file, destination); + List managedDependencies = Optional.ofNullable(project.getDependencyManagement()) + .map(DependencyManagement::getDependencies) + .orElseGet(Collections::emptyList) + .stream() + .map(d -> RepositoryUtils.toDependency(d, artifactTypeRegistry)) + .collect(Collectors.toList()); - MetadataUtils.createMetadata(destination, artifact); - } else { - getLog().debug("Not re-installing " + artifact + ", " + file); - } - } catch (Exception e) { - throw new MojoExecutionException("Failed to stage artifact: " + artifact, e); - } - } + List dependencies = project.getDependencies().stream() + .map(d -> RepositoryUtils.toDependency(d, artifactTypeRegistry)) + .collect(Collectors.toList()); - private void copyFileIfDifferent(File src, File dst) throws IOException { - if (src.lastModified() != dst.lastModified() || src.length() != dst.length()) { - FileUtils.copyFile(src, dst); - dst.setLastModified(src.lastModified()); - } - } + CollectRequest collectRequest = new CollectRequest(); + collectRequest.setRootArtifact(RepositoryUtils.toArtifact(project.getArtifact())); + collectRequest.setDependencies(dependencies); + collectRequest.setManagedDependencies(managedDependencies); - /** - * Installs the main artifact and any attached artifacts of the specified project to the local repository. - * - * @param mvnProject The project whose artifacts should be installed, must not be null. - * @throws MojoExecutionException If any artifact could not be installed. - */ - private void installProjectArtifacts(MavenProject mvnProject) throws MojoExecutionException { - try { - // Install POM (usually attached as metadata but that happens only as a side effect of the Install Plugin) - installProjectPom(mvnProject); + collectRequest.setRepositories(project.getRemoteProjectRepositories()); - // Install the main project artifact (if the project has one, e.g. has no "pom" packaging) - Artifact mainArtifact = mvnProject.getArtifact(); - if (mainArtifact.getFile() != null) { - installArtifact(mainArtifact.getFile(), mainArtifact); - } + DependencyRequest request = new DependencyRequest(collectRequest, classpathFilter); - // Install any attached project artifacts - Collection attachedArtifacts = mvnProject.getAttachedArtifacts(); - for (Artifact attachedArtifact : attachedArtifacts) { - installArtifact(attachedArtifact.getFile(), attachedArtifact); - } - } catch (Exception e) { - throw new MojoExecutionException("Failed to install project artifacts: " + mvnProject, e); - } - } + DependencyResult dependencyResult = + repositorySystem.resolveDependencies(session.getRepositorySession(), request); - /** - * Installs the (locally reachable) parent POMs of the specified project to the local repository. The parent POMs - * from the reactor must be installed or the forked IT builds will fail when using a clean repository. - * - * @param mvnProject The project whose parent POMs should be installed, must not be null. - * @throws MojoExecutionException If any POM could not be installed. - */ - private void installProjectParents(MavenProject mvnProject) throws MojoExecutionException { - try { - for (MavenProject parent = mvnProject.getParent(); parent != null; parent = parent.getParent()) { - if (parent.getFile() == null) { - copyParentPoms(parent.getGroupId(), parent.getArtifactId(), parent.getVersion()); - break; - } - installProjectPom(parent); - } - } catch (Exception e) { - throw new MojoExecutionException("Failed to install project parents: " + mvnProject, e); - } - } + List artifacts = dependencyResult.getArtifactResults().stream() + .map(ArtifactResult::getArtifact) + .collect(Collectors.toList()); - /** - * Installs the POM of the specified project to the local repository. - * - * @param mvnProject The project whose POM should be installed, must not be null. - * @throws MojoExecutionException If the POM could not be installed. - */ - private void installProjectPom(MavenProject mvnProject) throws MojoExecutionException { - try { - Artifact pomArtifact = null; - if ("pom".equals(mvnProject.getPackaging())) { - pomArtifact = mvnProject.getArtifact(); - } - if (pomArtifact == null) { - pomArtifact = artifactFactory.createProjectArtifact( - mvnProject.getGroupId(), mvnProject.getArtifactId(), mvnProject.getVersion()); - } - installArtifact(mvnProject.getFile(), pomArtifact); - } catch (Exception e) { - throw new MojoExecutionException("Failed to install POM: " + mvnProject, e); - } + resolvedArtifacts.addAll(artifacts); + resolvePomsForArtifacts(artifacts, resolvedArtifacts, collectRequest.getRepositories()); } /** - * Installs the dependent projects from the reactor to the local repository. The dependencies on other modules from - * the reactor must be installed or the forked IT builds will fail when using a clean repository. + * Resolve extra artifacts. * - * @param mvnProject The project whose dependent projects should be installed, must not be null. - * @param reactorProjects The set of projects in the reactor build, must not be null. - * @throws MojoExecutionException If any dependency could not be installed. + * @return */ - private void installProjectDependencies(MavenProject mvnProject, Collection reactorProjects) - throws MojoExecutionException { - // ... into dependencies that were resolved from reactor projects ... - Collection dependencyProjects = new LinkedHashSet<>(); - collectAllProjectReferences(mvnProject, dependencyProjects); - - // index available reactor projects - Map projects = new HashMap<>(reactorProjects.size()); - for (MavenProject reactorProject : reactorProjects) { - String projectId = reactorProject.getGroupId() - + ':' - + reactorProject.getArtifactId() - + ':' - + reactorProject.getVersion(); - - projects.put(projectId, reactorProject); - } - - // group transitive dependencies (even those that don't contribute to the class path like POMs) ... - Collection artifacts = mvnProject.getArtifacts(); - // ... and those that were resolved from the (local) repo - Collection dependencyArtifacts = new LinkedHashSet<>(); + private void resolveExtraArtifacts(Collection resolvedArtifacts) + throws MojoExecutionException, DependencyResolutionException, ArtifactDescriptorException, + ArtifactResolutionException { - for (Artifact artifact : artifacts) { - // workaround for MNG-2961 to ensure the base version does not contain a timestamp - artifact.isSnapshot(); + if (extraArtifacts == null) { + return; + } - String projectId = artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion(); + DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME); - if (!projects.containsKey(projectId)) { - dependencyArtifacts.add(artifact); + for (String extraArtifact : extraArtifacts) { + String[] gav = extraArtifact.split(":"); + if (gav.length < 3 || gav.length > 5) { + throw new MojoExecutionException("Invalid artifact " + extraArtifact); } - } - // install dependencies - try { - // copy dependencies that where resolved from the local repo - for (Artifact artifact : dependencyArtifacts) { - copyArtifact(artifact); - } + String groupId = gav[0]; + String artifactId = gav[1]; + String version = gav[2]; - // install dependencies that were resolved from the reactor - for (String projectId : dependencyProjects) { - MavenProject dependencyProject = projects.get(projectId); - if (dependencyProject == null) { - getLog().warn("skip dependencyProject null for projectId=" + projectId); - continue; - } - installProjectArtifacts(dependencyProject); - installProjectParents(dependencyProject); + String type = "jar"; + if (gav.length > 3) { + type = gav[3]; } - } catch (Exception e) { - throw new MojoExecutionException("Failed to install project dependencies: " + mvnProject, e); - } - } - protected void collectAllProjectReferences(MavenProject project, Collection dependencyProjects) { - for (MavenProject reactorProject : project.getProjectReferences().values()) { - String projectId = reactorProject.getGroupId() - + ':' - + reactorProject.getArtifactId() - + ':' - + reactorProject.getVersion(); - if (dependencyProjects.add(projectId)) { - collectAllProjectReferences(reactorProject, dependencyProjects); + String classifier = null; + if (gav.length == 5) { + classifier = gav[4]; } - } - } - private void copyArtifact(Artifact artifact) throws MojoExecutionException { - copyPoms(artifact); + ArtifactType artifactType = + session.getRepositorySession().getArtifactTypeRegistry().get(type); - Artifact depArtifact = artifactFactory.createArtifactWithClassifier( - artifact.getGroupId(), - artifact.getArtifactId(), - artifact.getBaseVersion(), - artifact.getType(), - artifact.getClassifier()); + List remoteRepositories = + artifactType != null && "maven-plugin".equals(artifactType.getId()) + ? project.getRemotePluginRepositories() + : project.getRemoteProjectRepositories(); - File artifactFile = artifact.getFile(); + Artifact artifact = new DefaultArtifact(groupId, artifactId, classifier, null, version, artifactType); - copyArtifact(artifactFile, depArtifact); - } + resolvePomsForArtifacts(Collections.singletonList(artifact), resolvedArtifacts, remoteRepositories); + + CollectRequest collectRequest = new CollectRequest(); + Dependency root = new Dependency(artifact, JavaScopes.COMPILE); + collectRequest.setRoot(root); + collectRequest.setRepositories(remoteRepositories); - private void copyPoms(Artifact artifact) throws MojoExecutionException { - Artifact pomArtifact = artifactFactory.createProjectArtifact( - artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion()); + DependencyRequest request = new DependencyRequest(collectRequest, classpathFilter); + DependencyResult dependencyResult = + repositorySystem.resolveDependencies(session.getRepositorySession(), request); - File pomFile = new File(localRepository.getBasedir(), localRepository.pathOf(pomArtifact)); + List artifacts = dependencyResult.getArtifactResults().stream() + .map(ArtifactResult::getArtifact) + .collect(Collectors.toList()); - if (pomFile.isFile()) { - copyArtifact(pomFile, pomArtifact); - copyParentPoms(pomFile); + resolvedArtifacts.addAll(artifacts); + resolvePomsForArtifacts(artifacts, resolvedArtifacts, collectRequest.getRepositories()); } } - /** - * Installs all parent POMs of the specified POM file that are available in the local repository. - * - * @param pomFile The path to the POM file whose parents should be installed, must not be null. - * @throws MojoExecutionException If any (existing) parent POM could not be installed. - */ - private void copyParentPoms(File pomFile) throws MojoExecutionException { - Model model = PomUtils.loadPom(pomFile); - Parent parent = model.getParent(); - if (parent != null) { - copyParentPoms(parent.getGroupId(), parent.getArtifactId(), parent.getVersion()); + private void resolvePomsForArtifacts( + List artifacts, Collection resolvedArtifacts, List remoteRepositories) + throws ArtifactResolutionException, MojoExecutionException { + + for (Artifact a : artifacts) { + Artifact artifactResult = resolveArtifact(new SubArtifact(a, "", "pom"), remoteRepositories); + resolvePomWithParents(artifactResult, resolvedArtifacts, remoteRepositories); } } - /** - * Installs the specified POM and all its parent POMs to the local repository. - * - * @param groupId The group id of the POM which should be installed, must not be null. - * @param artifactId The artifact id of the POM which should be installed, must not be null. - * @param version The version of the POM which should be installed, must not be null. - * @throws MojoExecutionException If any (existing) parent POM could not be installed. - */ - private void copyParentPoms(String groupId, String artifactId, String version) throws MojoExecutionException { - Artifact pomArtifact = artifactFactory.createProjectArtifact(groupId, artifactId, version); + private void resolvePomWithParents( + Artifact artifact, Collection resolvedArtifacts, List remoteRepositories) + throws MojoExecutionException, ArtifactResolutionException { - if (installedArtifacts.contains(pomArtifact.getId()) || copiedArtifacts.contains(pomArtifact.getId())) { - getLog().debug("Not re-installing " + pomArtifact); + if (resolvedArtifacts.contains(artifact)) { return; } - File pomFile = new File(localRepository.getBasedir(), localRepository.pathOf(pomArtifact)); - if (pomFile.isFile()) { - copyArtifact(pomFile, pomArtifact); - copyParentPoms(pomFile); + Model model = PomUtils.loadPom(artifact.getFile()); + Parent parent = model.getParent(); + if (parent != null) { + DefaultArtifact pom = + new DefaultArtifact(parent.getGroupId(), parent.getArtifactId(), "", "pom", parent.getVersion()); + Artifact resolvedPom = resolveArtifact(pom, remoteRepositories); + resolvePomWithParents(resolvedPom, resolvedArtifacts, remoteRepositories); } + + resolvedArtifacts.add(artifact); } - private void installExtraArtifacts(String[] extraArtifacts) throws MojoExecutionException { - if (extraArtifacts == null) { - return; - } + private Artifact resolveArtifact(Artifact artifact, List remoteRepositories) + throws ArtifactResolutionException { - for (String extraArtifact : extraArtifacts) { - String[] gav = extraArtifact.split(":"); - if (gav.length < 3 || gav.length > 5) { - throw new MojoExecutionException("Invalid artifact " + extraArtifact); - } + ArtifactRequest request = new ArtifactRequest(); + request.setArtifact(artifact); + request.setRepositories(remoteRepositories); + ArtifactResult artifactResult = repositorySystem.resolveArtifact(session.getRepositorySession(), request); + return artifactResult.getArtifact(); + } - String groupId = gav[0]; - String artifactId = gav[1]; - String version = gav[2]; + /** + * Install list of artifacts into local repository. + */ + private void installArtifacts(Collection resolvedArtifacts) throws InstallationException { - String type = "jar"; - if (gav.length > 3) { - type = gav[3]; - } + // we can have on dependency two artifacts with the same groupId:artifactId + // with different version, in such case when we install both in one request + // metadata will contain only one version - String classifier = null; - if (gav.length == 5) { - classifier = gav[4]; - } + Map> collect = resolvedArtifacts.stream() + .collect(Collectors.groupingBy( + a -> String.format("%s:%s:%s", a.getGroupId(), a.getArtifactId(), a.getVersion()), + LinkedHashMap::new, + Collectors.toList())); + + RepositorySystemSession systemSessionForLocalRepo = createSystemSessionForLocalRepo(); + + for (List artifacts : collect.values()) { + InstallRequest request = new InstallRequest(); + request.setArtifacts(artifacts); + repositorySystem.install(systemSessionForLocalRepo, request); + } + } - DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate(); - try { - coordinate.setGroupId(groupId); - coordinate.setArtifactId(artifactId); - coordinate.setVersion(version); - coordinate.setType(type); - coordinate.setClassifier(classifier); - - if (!localRepository.getBasedir().equals(localRepositoryPath.getPath()) && useLocalRepository) { - String previousId = localRepository.getId(); - try { - // using another request with the correct target repo - ProjectBuildingRequest projectBuildingRequest = repositoryManager.setLocalRepositoryBasedir( - session.getProjectBuildingRequest(), localRepositoryPath); - projectBuildingRequest.setRemoteRepositories(Collections.singletonList(localRepository)); - resolver.resolveDependencies( - projectBuildingRequest, - coordinate, - new PatternExclusionsFilter(Collections.emptyList())); - } finally { - localRepository.setId(previousId); - } - } else { - resolver.resolveDependencies( - projectBuildingRequest, coordinate, new PatternExclusionsFilter(Collections.emptyList())); - } - } catch (DependencyResolverException e) { - throw new MojoExecutionException("Unable to resolve dependencies for: " + coordinate, e); + /** + * Create a new {@link RepositorySystemSession} connected with local repo. + */ + private RepositorySystemSession createSystemSessionForLocalRepo() { + RepositorySystemSession repositorySystemSession = session.getRepositorySession(); + if (localRepositoryPath != null) { + // "clone" repository session and replace localRepository + DefaultRepositorySystemSession newSession = + new DefaultRepositorySystemSession(session.getRepositorySession()); + // Clear cache, since we're using a new local repository + newSession.setCache(new DefaultRepositoryCache()); + // keep same repositoryType + String contentType = newSession.getLocalRepository().getContentType(); + if ("enhanced".equals(contentType)) { + contentType = "default"; } + LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager( + newSession, new LocalRepository(localRepositoryPath, contentType)); + + newSession.setLocalRepositoryManager(localRepositoryManager); + repositorySystemSession = newSession; + getLog().debug("localRepoPath: " + + localRepositoryManager.getRepository().getBasedir()); } + + return repositorySystemSession; } } diff --git a/src/main/java/org/apache/maven/plugins/invoker/MetadataUtils.java b/src/main/java/org/apache/maven/plugins/invoker/MetadataUtils.java deleted file mode 100644 index 13d2c4a4..00000000 --- a/src/main/java/org/apache/maven/plugins/invoker/MetadataUtils.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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. - */ -package org.apache.maven.plugins.invoker; - -import java.io.File; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.text.SimpleDateFormat; -import java.util.Collection; -import java.util.Date; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.TimeZone; - -import org.apache.maven.artifact.Artifact; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.WriterFactory; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.codehaus.plexus.util.xml.Xpp3DomBuilder; -import org.codehaus.plexus.util.xml.Xpp3DomUtils; -import org.codehaus.plexus.util.xml.Xpp3DomWriter; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -/** - * Provides utility methods for artifact metadata processing. - * - * @author Benjamin Bentmann - */ -class MetadataUtils { - - /** - * Creates local metadata files for the specified artifact. The goal is to simulate the installation of the artifact - * by a local build, thereby decoupling the forked builds from the inderministic collection of remote repositories - * that are available to the main build and from which the artifact was originally resolved. - * - * @param file The artifact's file in the local test repository, must not be null. - * @param artifact The artifact to create metadata for, must not be null. - * @throws IOException If the metadata could not be created. - */ - public static void createMetadata(File file, Artifact artifact) throws IOException { - TimeZone tz = java.util.TimeZone.getTimeZone("UTC"); - SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss"); - fmt.setTimeZone(tz); - String timestamp = fmt.format(new Date()); - - if (artifact.isSnapshot()) { - File metadataFile = new File(file.getParentFile(), "maven-metadata-local.xml"); - - Xpp3Dom metadata = new Xpp3Dom("metadata"); - addChild(metadata, "groupId", artifact.getGroupId()); - addChild(metadata, "artifactId", artifact.getArtifactId()); - addChild(metadata, "version", artifact.getBaseVersion()); - Xpp3Dom versioning = new Xpp3Dom("versioning"); - versioning.addChild(addChild(new Xpp3Dom("snapshot"), "localCopy", "true")); - addChild(versioning, "lastUpdated", timestamp); - metadata.addChild(versioning); - - writeMetadata(metadataFile, metadata); - } - - File metadataFile = new File(file.getParentFile().getParentFile(), "maven-metadata-local.xml"); - - Set allVersions = new LinkedHashSet<>(); - - Xpp3Dom metadata = readMetadata(metadataFile); - - if (metadata != null) { - Xpp3Dom versioning = metadata.getChild("versioning"); - if (versioning != null) { - Xpp3Dom versions = versioning.getChild("versions"); - if (versions != null) { - - Xpp3Dom[] children = versions.getChildren("version"); - for (Xpp3Dom aChildren : children) { - allVersions.add(aChildren.getValue()); - } - } - } - } - - allVersions.add(artifact.getBaseVersion()); - - metadata = new Xpp3Dom("metadata"); - addChild(metadata, "groupId", artifact.getGroupId()); - addChild(metadata, "artifactId", artifact.getArtifactId()); - Xpp3Dom versioning = new Xpp3Dom("versioning"); - versioning.addChild(addChildren(new Xpp3Dom("versions"), "version", allVersions)); - addChild(versioning, "lastUpdated", timestamp); - metadata.addChild(versioning); - - metadata = Xpp3DomUtils.mergeXpp3Dom(metadata, readMetadata(metadataFile)); - - writeMetadata(metadataFile, metadata); - } - - private static Xpp3Dom addChild(Xpp3Dom parent, String childName, String childValue) { - Xpp3Dom child = new Xpp3Dom(childName); - child.setValue(childValue); - parent.addChild(child); - return parent; - } - - private static Xpp3Dom addChildren(Xpp3Dom parent, String childName, Collection childValues) { - for (String childValue : childValues) { - addChild(parent, childName, childValue); - } - return parent; - } - - private static Xpp3Dom readMetadata(File metadataFile) throws IOException { - if (!metadataFile.isFile()) { - return null; - } - - try (Reader reader = ReaderFactory.newXmlReader(metadataFile)) { - return Xpp3DomBuilder.build(reader); - } catch (XmlPullParserException e) { - throw new IOException(e.getMessage(), e); - } - } - - private static void writeMetadata(File metadataFile, Xpp3Dom metadata) throws IOException { - metadataFile.getParentFile().mkdirs(); - - try (Writer writer = WriterFactory.newXmlWriter(metadataFile)) { - Xpp3DomWriter.write(writer, metadata); - } - } -} From 6bb7c6b013d27a9c97e558bdfcaae5920365fc38 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 31 Jan 2023 18:18:12 +0100 Subject: [PATCH 02/92] Bump project version to 3.5.0-SNAPSHOT --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 26641448..3ea75bc4 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.4.1-SNAPSHOT + 3.5.0-SNAPSHOT maven-plugin Apache Maven Invoker Plugin @@ -66,7 +66,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2022-12-15T01:19:19Z + 2023-01-31T17:17:20Z 4.0.6 From 7024027bde6c816ac4a0fb43358478b49e1d6393 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 23:13:33 +0100 Subject: [PATCH 03/92] [MINVOKER-322] Bump assertj-core from 3.23.1 to 3.24.2 (#168) Bumps assertj-core from 3.23.1 to 3.24.2. --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3ea75bc4..537836ab 100644 --- a/pom.xml +++ b/pom.xml @@ -266,7 +266,7 @@ under the License. org.assertj assertj-core - 3.23.1 + 3.24.2 test From 29da34c0bb723de4a25941b1c41b8521d03ed894 Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Fri, 10 Feb 2023 09:47:31 -0500 Subject: [PATCH 04/92] [MINVOKER-324] Temporary File Information Disclosure (#152) This fixes temporary file information disclosure vulnerability due to the use of the vulnerable `File.createTempFile()` method. The vulnerability is fixed by using the `Files.createTempFile()` method which sets the correct posix permissions. Weakness: CWE-377: Insecure Temporary File Severity: Medium CVSSS: 5.5 Detection: CodeQL & OpenRewrite (https://public.moderne.io/recipes/org.openrewrite.java.security.SecureTempFileCreation) Reported-by: Jonathan Leitschuh Bug-tracker: https://github.com/JLLeitschuh/security-research/issues/18 Co-authored-by: Moderne Co-authored-by: Guillaume Nodet --- .../org/apache/maven/plugins/invoker/AbstractInvokerMojo.java | 2 +- .../apache/maven/plugins/invoker/InvokerPropertiesTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index aa59f786..4a3bd354 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -1398,7 +1398,7 @@ private File mergeSettings(File interpolatedSettingsFile) throws MojoExecutionEx private File writeMergedSettingsFile(Settings mergedSettings) throws IOException { File mergedSettingsFile; - mergedSettingsFile = File.createTempFile("invoker-settings", ".xml"); + mergedSettingsFile = Files.createTempFile("invoker-settings", ".xml").toFile(); SettingsXpp3Writer settingsWriter = new SettingsXpp3Writer(); diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java index eb357c8b..2ba1d78c 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java @@ -19,6 +19,7 @@ package org.apache.maven.plugins.invoker; import java.io.File; +import java.nio.file.Files; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -188,7 +189,7 @@ public void testConfigureRequestProject() throws Exception { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); - File tempPom = File.createTempFile("maven-invoker-plugin-test", ".pom"); + File tempPom = Files.createTempFile("maven-invoker-plugin-test", ".pom").toFile(); try { File tempDir = tempPom.getParentFile(); when(request.getBaseDirectory()).thenReturn(tempDir); From 7c884d2025258fb629159e2922d4eda4264d20e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Feb 2023 15:48:34 +0100 Subject: [PATCH 05/92] [MINVOKER-325] Bump groovy-bom from 4.0.6 to 4.0.9 (#176) Bumps [groovy-bom](https://github.com/apache/groovy) from 4.0.6 to 4.0.9. - [Release notes](https://github.com/apache/groovy/releases) - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 537836ab..9b6a2095 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ under the License. bsh 2.0b6 2023-01-31T17:17:20Z - 4.0.6 + 4.0.9 From bd4cd8b7cc04dd3297235ed7490e5a4858940258 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Feb 2023 15:49:20 +0100 Subject: [PATCH 06/92] [MINVOKER-326] Bump doxia-sink-api from 1.11.1 to 1.12.0 (#166) Bumps [doxia-sink-api](https://github.com/apache/maven-doxia) from 1.11.1 to 1.12.0. - [Release notes](https://github.com/apache/maven-doxia/releases) - [Commits](https://github.com/apache/maven-doxia/compare/doxia-1.11.1...doxia-1.12.0) --- updated-dependencies: - dependency-name: org.apache.maven.doxia:doxia-sink-api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9b6a2095..120c5395 100644 --- a/pom.xml +++ b/pom.xml @@ -168,7 +168,7 @@ under the License. org.apache.maven.doxia doxia-sink-api - 1.11.1 + 1.12.0 From 56ae7e22b99f83d869803ed610969be8399b2c15 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 12 Feb 2023 20:26:15 +0100 Subject: [PATCH 07/92] [maven-release-plugin] prepare release maven-invoker-plugin-3.5.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 120c5395..4c212c10 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.5.0-SNAPSHOT + 3.5.0 maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git - HEAD + maven-invoker-plugin-3.5.0 https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -66,7 +66,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2023-01-31T17:17:20Z + 2023-02-12T19:25:44Z 4.0.9 From c7fcdbf516edd69369e4249d10955762708e9480 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 12 Feb 2023 20:26:23 +0100 Subject: [PATCH 08/92] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 4c212c10..eeed3750 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.5.0 + 3.5.1-SNAPSHOT maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git - maven-invoker-plugin-3.5.0 + HEAD https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -66,7 +66,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2023-02-12T19:25:44Z + 2023-02-12T19:26:23Z 4.0.9 From de1dbbf47da0d6bc48d2986651aa547ca8fa5a8f Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 25 Feb 2023 12:22:13 +0100 Subject: [PATCH 09/92] [MINVOKER-328] Skip install artifacts with the same source and target path When user not specified localRepositoryPath we can not reinstall artifact with the same source and target path --- .../invoker.properties | 18 ++++++ src/it/MINVOKER-328_install-default/pom.xml | 63 +++++++++++++++++++ .../verify.groovy | 20 ++++++ .../maven/plugins/invoker/InstallMojo.java | 27 +++++++- 4 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 src/it/MINVOKER-328_install-default/invoker.properties create mode 100644 src/it/MINVOKER-328_install-default/pom.xml create mode 100644 src/it/MINVOKER-328_install-default/verify.groovy diff --git a/src/it/MINVOKER-328_install-default/invoker.properties b/src/it/MINVOKER-328_install-default/invoker.properties new file mode 100644 index 00000000..353946b6 --- /dev/null +++ b/src/it/MINVOKER-328_install-default/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = verify diff --git a/src/it/MINVOKER-328_install-default/pom.xml b/src/it/MINVOKER-328_install-default/pom.xml new file mode 100644 index 00000000..8b2718b3 --- /dev/null +++ b/src/it/MINVOKER-328_install-default/pom.xml @@ -0,0 +1,63 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + minvoker328 + 1.0-SNAPSHOT + pom + + https://issues.apache.org/jira/browse/MINVOKER-328 + install with default configuration + + + UTF-8 + + + + + org.slf4j + slf4j-api + 1.7.36 + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + + + install + + + + + + + + diff --git a/src/it/MINVOKER-328_install-default/verify.groovy b/src/it/MINVOKER-328_install-default/verify.groovy new file mode 100644 index 00000000..144091e7 --- /dev/null +++ b/src/it/MINVOKER-328_install-default/verify.groovy @@ -0,0 +1,20 @@ +/* + * 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. + */ +File buildLog = new File(basedir, 'build.log') +assert buildLog.text.contains('[DEBUG] Skip install the same target') \ No newline at end of file diff --git a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java index 8c2000d4..e9fc917a 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java @@ -19,12 +19,15 @@ package org.apache.maven.plugins.invoker; import java.io.File; +import java.io.IOException; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; @@ -356,18 +359,19 @@ private Artifact resolveArtifact(Artifact artifact, List remot */ private void installArtifacts(Collection resolvedArtifacts) throws InstallationException { + RepositorySystemSession systemSessionForLocalRepo = createSystemSessionForLocalRepo(); + // we can have on dependency two artifacts with the same groupId:artifactId // with different version, in such case when we install both in one request // metadata will contain only one version Map> collect = resolvedArtifacts.stream() + .filter(a -> !hasTheSamePathAsTarget(a, systemSessionForLocalRepo)) .collect(Collectors.groupingBy( a -> String.format("%s:%s:%s", a.getGroupId(), a.getArtifactId(), a.getVersion()), LinkedHashMap::new, Collectors.toList())); - RepositorySystemSession systemSessionForLocalRepo = createSystemSessionForLocalRepo(); - for (List artifacts : collect.values()) { InstallRequest request = new InstallRequest(); request.setArtifacts(artifacts); @@ -375,6 +379,25 @@ private void installArtifacts(Collection resolvedArtifacts) throws Ins } } + private boolean hasTheSamePathAsTarget(Artifact artifact, RepositorySystemSession systemSession) { + try { + LocalRepositoryManager lrm = systemSession.getLocalRepositoryManager(); + File targetBasedir = lrm.getRepository().getBasedir(); + if (targetBasedir == null) { + return false; + } + File targetFile = new File(targetBasedir, lrm.getPathForLocalArtifact(artifact)).getCanonicalFile(); + File sourceFile = artifact.getFile().getCanonicalFile(); + if (Objects.equals(targetFile, sourceFile)) { + getLog().debug("Skip install the same target " + sourceFile); + return true; + } + return false; + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + /** * Create a new {@link RepositorySystemSession} connected with local repo. */ From f46013fa0735648043174c5e474ee92d42e5524a Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 7 Mar 2023 23:29:36 +0100 Subject: [PATCH 10/92] Add optional dependency for install ITs --- src/it/staging-dependencies/pom.xml | 6 ++ src/it/staging-dependencies/verify.bsh | 5 +- src/it/staging-reactor/mod1/pom.xml | 8 ++- src/it/staging-reactor/mod3/pom.xml | 59 +++++++++++++++++++ .../mod3/src/main/resources/main.properties | 17 ++++++ src/it/staging-reactor/pom.xml | 1 + src/it/staging-reactor/verify.bsh | 3 + 7 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 src/it/staging-reactor/mod3/pom.xml create mode 100644 src/it/staging-reactor/mod3/src/main/resources/main.properties diff --git a/src/it/staging-dependencies/pom.xml b/src/it/staging-dependencies/pom.xml index 31cca75c..72e92ce0 100644 --- a/src/it/staging-dependencies/pom.xml +++ b/src/it/staging-dependencies/pom.xml @@ -68,6 +68,12 @@ under the License. 1.7.36 test + + org.slf4j + slf4j-api + 1.7.36 + true + diff --git a/src/it/staging-dependencies/verify.bsh b/src/it/staging-dependencies/verify.bsh index 7e43c8ba..5a1fb4bb 100644 --- a/src/it/staging-dependencies/verify.bsh +++ b/src/it/staging-dependencies/verify.bsh @@ -57,7 +57,10 @@ try "org/apache/maven/its/dep/2.0/dep-2.0.jar", "org/apache/maven/its/dep/maven-metadata-local.xml", "test/staging-dependencies/1.0-SNAPSHOT/staging-dependencies-1.0-SNAPSHOT.jar", - "test/staging-dependencies/1.0-SNAPSHOT/staging-dependencies-1.0-SNAPSHOT.pom" + "test/staging-dependencies/1.0-SNAPSHOT/staging-dependencies-1.0-SNAPSHOT.pom", + "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.pom", + "org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar", + "org/slf4j/slf4j-parent/1.7.36/slf4j-parent-1.7.36.pom" }; for ( String file : files ) { diff --git a/src/it/staging-reactor/mod1/pom.xml b/src/it/staging-reactor/mod1/pom.xml index fad9dc45..e1cb6a6e 100644 --- a/src/it/staging-reactor/mod1/pom.xml +++ b/src/it/staging-reactor/mod1/pom.xml @@ -29,7 +29,7 @@ under the License. ../mod1-parent - mod1 + mod1 1.0-SNAPSHOT jar @@ -47,6 +47,12 @@ under the License. mod2 1.0-SNAPSHOT + + test + mod3 + 1.0-SNAPSHOT + true + diff --git a/src/it/staging-reactor/mod3/pom.xml b/src/it/staging-reactor/mod3/pom.xml new file mode 100644 index 00000000..13f90a15 --- /dev/null +++ b/src/it/staging-reactor/mod3/pom.xml @@ -0,0 +1,59 @@ + + + + + + 4.0.0 + + + test + mod2-parent + 1.0-SNAPSHOT + + + mod3 + 1.0-SNAPSHOT + jar + + + Test to check for proper staging during a multi module build, i.e. artifacts from the reactor need to be considered. + + + + UTF-8 + + + + + + maven-source-plugin + @sourcePluginVersion@ + + + attach-resources + + jar + + + + + + + diff --git a/src/it/staging-reactor/mod3/src/main/resources/main.properties b/src/it/staging-reactor/mod3/src/main/resources/main.properties new file mode 100644 index 00000000..00ae6c00 --- /dev/null +++ b/src/it/staging-reactor/mod3/src/main/resources/main.properties @@ -0,0 +1,17 @@ +# 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. + diff --git a/src/it/staging-reactor/pom.xml b/src/it/staging-reactor/pom.xml index ae0a279c..62ae2f34 100644 --- a/src/it/staging-reactor/pom.xml +++ b/src/it/staging-reactor/pom.xml @@ -34,6 +34,7 @@ under the License. mod1 mod2 + mod3 diff --git a/src/it/staging-reactor/verify.bsh b/src/it/staging-reactor/verify.bsh index 9a684fc7..bc88213d 100644 --- a/src/it/staging-reactor/verify.bsh +++ b/src/it/staging-reactor/verify.bsh @@ -44,6 +44,9 @@ try "test/mod2/1.0-SNAPSHOT/maven-metadata-local.xml", "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.pom", "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.jar", + "test/mod3/1.0-SNAPSHOT/maven-metadata-local.xml", + "test/mod3/1.0-SNAPSHOT/mod3-1.0-SNAPSHOT.pom", + "test/mod3/1.0-SNAPSHOT/mod3-1.0-SNAPSHOT.jar", "test/mod2-parent/maven-metadata-local.xml", "test/mod2-parent/1.0-SNAPSHOT/maven-metadata-local.xml", "test/mod2-parent/1.0-SNAPSHOT/mod2-parent-1.0-SNAPSHOT.pom", From 76ba6865ab48b12667e314b4b1e5af6cdea04d00 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 25 Mar 2023 10:09:34 +0100 Subject: [PATCH 11/92] [MINVOKER-329] Bump plexus-utils from 3.5.0 to 3.5.1 (#178) Bumps [plexus-utils](https://github.com/codehaus-plexus/plexus-utils) from 3.5.0 to 3.5.1. - [Release notes](https://github.com/codehaus-plexus/plexus-utils/releases) - [Commits](https://github.com/codehaus-plexus/plexus-utils/compare/plexus-utils-3.5.0...plexus-utils-3.5.1) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-utils dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eeed3750..2efd1629 100644 --- a/pom.xml +++ b/pom.xml @@ -209,7 +209,7 @@ under the License. org.codehaus.plexus plexus-utils - 3.5.0 + 3.5.1 org.codehaus.plexus From 82c5d7d7a06e70483b253a037b56b547e70a4f9b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 25 Mar 2023 10:50:04 +0100 Subject: [PATCH 12/92] [MINVOKER-331] Bump groovy-bom from 4.0.9 to 4.0.10 (#180) Bumps [groovy-bom](https://github.com/apache/groovy) from 4.0.9 to 4.0.10. - [Release notes](https://github.com/apache/groovy/releases) - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2efd1629..37b4f087 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ under the License. bsh 2.0b6 2023-02-12T19:26:23Z - 4.0.9 + 4.0.10 From 460582cf83dc184426d31360858303b4877d9c0b Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 25 Mar 2023 11:07:59 +0100 Subject: [PATCH 13/92] [MINVOKER-330] Allow relative path for mavenExecutable --- .../pom.xml | 60 +++++++++++++++++++ .../src/it/project/pom.xml | 28 +++++++++ .../plugins/invoker/AbstractInvokerMojo.java | 2 +- .../plugins/invoker/InvokerProperties.java | 6 +- .../invoker/InvokerPropertiesTest.java | 2 +- 5 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 src/it/MINVOKER-330-realative-mavenExacutable/pom.xml create mode 100644 src/it/MINVOKER-330-realative-mavenExacutable/src/it/project/pom.xml diff --git a/src/it/MINVOKER-330-realative-mavenExacutable/pom.xml b/src/it/MINVOKER-330-realative-mavenExacutable/pom.xml new file mode 100644 index 00000000..ae7d2cac --- /dev/null +++ b/src/it/MINVOKER-330-realative-mavenExacutable/pom.xml @@ -0,0 +1,60 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker.its + minvoker-330 + 1.0-SNAPSHOT + pom + + + Test to check for usage of relative path in mavenExecutable. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + + integration-test + initialize + + run + + + + + mvn + + + + + + diff --git a/src/it/MINVOKER-330-realative-mavenExacutable/src/it/project/pom.xml b/src/it/MINVOKER-330-realative-mavenExacutable/src/it/project/pom.xml new file mode 100644 index 00000000..e83b4293 --- /dev/null +++ b/src/it/MINVOKER-330-realative-mavenExacutable/src/it/project/pom.xml @@ -0,0 +1,28 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + minvoker-330 + 0.1-SNAPSHOT + pom + diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 4a3bd354..84bf5b79 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -429,7 +429,7 @@ public abstract class AbstractInvokerMojo extends AbstractMojo { * @since 1.8 */ @Parameter(property = "invoker.mavenExecutable") - private File mavenExecutable; + private String mavenExecutable; /** * The JAVA_HOME environment variable to use for forked Maven invocations. Defaults to the current Java diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java index 08721a0f..5901ad58 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java @@ -153,8 +153,10 @@ public void setDefaultProfiles(List defaultProfiles) { * Default value for mavenExecutable * @param defaultMavenExecutable a default value */ - public void setDefaultMavenExecutable(File defaultMavenExecutable) { - this.defaultMavenExecutable = defaultMavenExecutable; + public void setDefaultMavenExecutable(String defaultMavenExecutable) { + if (StringUtils.isNotBlank(defaultMavenExecutable)) { + this.defaultMavenExecutable = new File(defaultMavenExecutable); + } } /** diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java index 2ba1d78c..8db6c396 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java @@ -216,7 +216,7 @@ public void testConfigureRequestMavenExecutable() { InvokerProperties facade = new InvokerProperties(props); File aDefExecutable = new File("defExecutable"); - facade.setDefaultMavenExecutable(aDefExecutable); + facade.setDefaultMavenExecutable(aDefExecutable.toString()); props.setProperty("invoker.mavenExecutable", "aPropExecutable"); facade.configureInvocation(request, 0); From 3e4f3c93f03f8670f161eadb6c47132a1e5a3722 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 25 Mar 2023 11:36:04 +0100 Subject: [PATCH 14/92] [MINVOKER-332] Update plugins versions used in ITs --- pom.xml | 16 ++++++++-------- .../src/it/minvoker-142/verify.groovy | 2 +- .../src/it/minvoker-test/verify.groovy | 2 +- .../src/it/minvoker-test/verify.groovy | 2 +- .../src/it/minvoker-test/verify.groovy | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 37b4f087..0d325278 100644 --- a/pom.xml +++ b/pom.xml @@ -374,16 +374,16 @@ under the License. 3.1.0 3.2.0 - 3.10.1 - 3.1.0 - 3.3.0 - 3.1.0 + 3.11.0 + 3.2.1 + 3.4.0 + 3.1.1 3.3.0 - 3.7.0 - 3.3.0 + 3.8.1 + 3.3.1 3.12.1 3.2.1 - 3.0.0-M7 + 3.0.0 @@ -391,7 +391,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - 3.4.0 + 3.5.0 ${project.build.directory}/it setup diff --git a/src/it/invocation-debug/src/it/minvoker-142/verify.groovy b/src/it/invocation-debug/src/it/minvoker-142/verify.groovy index b1367e9c..a658496c 100644 --- a/src/it/invocation-debug/src/it/minvoker-142/verify.groovy +++ b/src/it/invocation-debug/src/it/minvoker-142/verify.groovy @@ -17,4 +17,4 @@ * under the License. */ File buildLog = new File( basedir, 'build.log' ) -assert buildLog.text.contains( '[DEBUG] Executing rule: org.apache.maven.plugins.enforcer.AlwaysPass' ) \ No newline at end of file +assert buildLog.text.contains( '[INFO] Rule 0: org.apache.maven.enforcer.rules.AlwaysPass passed' ) \ No newline at end of file diff --git a/src/it/spaces-should-work_non-windows/src/it/minvoker-test/verify.groovy b/src/it/spaces-should-work_non-windows/src/it/minvoker-test/verify.groovy index 963ad63a..07309798 100644 --- a/src/it/spaces-should-work_non-windows/src/it/minvoker-test/verify.groovy +++ b/src/it/spaces-should-work_non-windows/src/it/minvoker-test/verify.groovy @@ -21,6 +21,6 @@ File buildLog = new File( basedir, 'build.log' ) // if one of criteria matches if( buildLog.exists() ) { - assert buildLog.text.contains( '[DEBUG] Executing rule: org.apache.maven.plugins.enforcer.AlwaysPass' ) + assert buildLog.text.contains( '[INFO] Rule 0: org.apache.maven.enforcer.rules.AlwaysPass passed' ) } diff --git a/src/it/spaces-should-work_windows/src/it/minvoker-test/verify.groovy b/src/it/spaces-should-work_windows/src/it/minvoker-test/verify.groovy index 963ad63a..07309798 100644 --- a/src/it/spaces-should-work_windows/src/it/minvoker-test/verify.groovy +++ b/src/it/spaces-should-work_windows/src/it/minvoker-test/verify.groovy @@ -21,6 +21,6 @@ File buildLog = new File( basedir, 'build.log' ) // if one of criteria matches if( buildLog.exists() ) { - assert buildLog.text.contains( '[DEBUG] Executing rule: org.apache.maven.plugins.enforcer.AlwaysPass' ) + assert buildLog.text.contains( '[INFO] Rule 0: org.apache.maven.enforcer.rules.AlwaysPass passed' ) } diff --git a/src/it/special-characters-should-work/src/it/minvoker-test/verify.groovy b/src/it/special-characters-should-work/src/it/minvoker-test/verify.groovy index b1367e9c..a658496c 100644 --- a/src/it/special-characters-should-work/src/it/minvoker-test/verify.groovy +++ b/src/it/special-characters-should-work/src/it/minvoker-test/verify.groovy @@ -17,4 +17,4 @@ * under the License. */ File buildLog = new File( basedir, 'build.log' ) -assert buildLog.text.contains( '[DEBUG] Executing rule: org.apache.maven.plugins.enforcer.AlwaysPass' ) \ No newline at end of file +assert buildLog.text.contains( '[INFO] Rule 0: org.apache.maven.enforcer.rules.AlwaysPass passed' ) \ No newline at end of file From bb40a309114a0b3d0e16e482c8b9380ca18800f0 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 26 Mar 2023 13:39:56 +0200 Subject: [PATCH 15/92] [MINVOKER-333] Artifact should be installed once --- .../maven/plugins/invoker/InstallMojo.java | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java index e9fc917a..0a7ec02e 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java @@ -21,8 +21,6 @@ import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; -import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; @@ -68,6 +66,7 @@ import org.eclipse.aether.resolution.DependencyRequest; import org.eclipse.aether.resolution.DependencyResolutionException; import org.eclipse.aether.resolution.DependencyResult; +import org.eclipse.aether.util.artifact.ArtifactIdUtils; import org.eclipse.aether.util.artifact.JavaScopes; import org.eclipse.aether.util.artifact.SubArtifact; import org.eclipse.aether.util.filter.DependencyFilterUtils; @@ -163,7 +162,7 @@ public void execute() throws MojoExecutionException { return; } - Collection resolvedArtifacts = new ArrayList<>(); + Map resolvedArtifacts = new LinkedHashMap<>(); try { @@ -181,19 +180,20 @@ public void execute() throws MojoExecutionException { } } - private void resolveProjectArtifacts(Collection resolvedArtifacts) { + private void resolveProjectArtifacts(Map resolvedArtifacts) { // pom packaging doesn't have a main artifact if (project.getArtifact() != null && project.getArtifact().getFile() != null) { - resolvedArtifacts.add(RepositoryUtils.toArtifact(project.getArtifact())); + Artifact artifact = RepositoryUtils.toArtifact(project.getArtifact()); + resolvedArtifacts.put(ArtifactIdUtils.toId(artifact), artifact); } - resolvedArtifacts.addAll(project.getAttachedArtifacts().stream() + project.getAttachedArtifacts().stream() .map(RepositoryUtils::toArtifact) - .collect(Collectors.toList())); + .forEach(a -> resolvedArtifacts.put(ArtifactIdUtils.toId(a), a)); } - private void resolveProjectPoms(MavenProject project, Collection resolvedArtifacts) + private void resolveProjectPoms(MavenProject project, Map resolvedArtifacts) throws ArtifactResolutionException { if (project == null) { @@ -202,15 +202,15 @@ private void resolveProjectPoms(MavenProject project, Collection resol Artifact projectPom = RepositoryUtils.toArtifact(new ProjectArtifact(project)); if (projectPom.getFile() != null) { - resolvedArtifacts.add(projectPom); + resolvedArtifacts.put(projectPom.toString(), projectPom); } else { Artifact artifact = resolveArtifact(projectPom, project.getRemoteProjectRepositories()); - resolvedArtifacts.add(artifact); + resolvedArtifacts.put(ArtifactIdUtils.toId(artifact), artifact); } resolveProjectPoms(project.getParent(), resolvedArtifacts); } - private void resolveProjectDependencies(Collection resolvedArtifacts) + private void resolveProjectDependencies(Map resolvedArtifacts) throws ArtifactResolutionException, MojoExecutionException, DependencyResolutionException { DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(scope); @@ -245,7 +245,7 @@ private void resolveProjectDependencies(Collection resolvedArtifacts) .map(ArtifactResult::getArtifact) .collect(Collectors.toList()); - resolvedArtifacts.addAll(artifacts); + artifacts.forEach(a -> resolvedArtifacts.put(ArtifactIdUtils.toId(a), a)); resolvePomsForArtifacts(artifacts, resolvedArtifacts, collectRequest.getRepositories()); } @@ -254,7 +254,7 @@ private void resolveProjectDependencies(Collection resolvedArtifacts) * * @return */ - private void resolveExtraArtifacts(Collection resolvedArtifacts) + private void resolveExtraArtifacts(Map resolvedArtifacts) throws MojoExecutionException, DependencyResolutionException, ArtifactDescriptorException, ArtifactResolutionException { @@ -309,13 +309,15 @@ private void resolveExtraArtifacts(Collection resolvedArtifacts) .map(ArtifactResult::getArtifact) .collect(Collectors.toList()); - resolvedArtifacts.addAll(artifacts); + artifacts.forEach(a -> resolvedArtifacts.put(ArtifactIdUtils.toId(a), a)); resolvePomsForArtifacts(artifacts, resolvedArtifacts, collectRequest.getRepositories()); } } private void resolvePomsForArtifacts( - List artifacts, Collection resolvedArtifacts, List remoteRepositories) + List artifacts, + Map resolvedArtifacts, + List remoteRepositories) throws ArtifactResolutionException, MojoExecutionException { for (Artifact a : artifacts) { @@ -325,10 +327,10 @@ private void resolvePomsForArtifacts( } private void resolvePomWithParents( - Artifact artifact, Collection resolvedArtifacts, List remoteRepositories) + Artifact artifact, Map resolvedArtifacts, List remoteRepositories) throws MojoExecutionException, ArtifactResolutionException { - if (resolvedArtifacts.contains(artifact)) { + if (resolvedArtifacts.containsKey(ArtifactIdUtils.toId(artifact))) { return; } @@ -341,7 +343,7 @@ private void resolvePomWithParents( resolvePomWithParents(resolvedPom, resolvedArtifacts, remoteRepositories); } - resolvedArtifacts.add(artifact); + resolvedArtifacts.put(ArtifactIdUtils.toId(artifact), artifact); } private Artifact resolveArtifact(Artifact artifact, List remoteRepositories) @@ -357,7 +359,7 @@ private Artifact resolveArtifact(Artifact artifact, List remot /** * Install list of artifacts into local repository. */ - private void installArtifacts(Collection resolvedArtifacts) throws InstallationException { + private void installArtifacts(Map resolvedArtifacts) throws InstallationException { RepositorySystemSession systemSessionForLocalRepo = createSystemSessionForLocalRepo(); @@ -365,7 +367,7 @@ private void installArtifacts(Collection resolvedArtifacts) throws Ins // with different version, in such case when we install both in one request // metadata will contain only one version - Map> collect = resolvedArtifacts.stream() + Map> collect = resolvedArtifacts.values().stream() .filter(a -> !hasTheSamePathAsTarget(a, systemSessionForLocalRepo)) .collect(Collectors.groupingBy( a -> String.format("%s:%s:%s", a.getGroupId(), a.getArtifactId(), a.getVersion()), From c3dbd68c6d8a9f17fbdb2d9fc5599100008d6242 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 27 Mar 2023 22:03:14 +0200 Subject: [PATCH 16/92] [maven-release-plugin] prepare release maven-invoker-plugin-3.5.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 0d325278..764b6df3 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.5.1-SNAPSHOT + 3.5.1 maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git - HEAD + maven-invoker-plugin-3.5.1 https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -66,7 +66,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2023-02-12T19:26:23Z + 2023-03-27T20:02:51Z 4.0.10 From e42da3712ea63f777227781b3f2d6461c0266e8a Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 27 Mar 2023 22:03:23 +0200 Subject: [PATCH 17/92] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 764b6df3..8aa405f0 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.5.1 + 3.5.2-SNAPSHOT maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git - maven-invoker-plugin-3.5.1 + HEAD https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -66,7 +66,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2023-03-27T20:02:51Z + 2023-03-27T20:03:23Z 4.0.10 From 5c62df652844c98beffea77cbbe2ca6cf1e474c9 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Mon, 3 Apr 2023 19:46:21 +0000 Subject: [PATCH 18/92] [MNG-6825] Replace StringUtils with Commons Lang3 Co-authored-by: Moderne --- .../org/apache/maven/plugins/invoker/AbstractInvokerMojo.java | 2 +- .../org/apache/maven/plugins/invoker/InvokerProperties.java | 2 +- .../java/org/apache/maven/plugins/invoker/InvokerReport.java | 2 +- .../java/org/apache/maven/plugins/invoker/SelectorUtils.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 84bf5b79..be59fed8 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -49,6 +49,7 @@ import java.util.TreeSet; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; @@ -93,7 +94,6 @@ import org.codehaus.plexus.util.InterpolationFilterReader; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.ReflectionUtils; -import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.CommandLineUtils; diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java index 5901ad58..f4e510e9 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java @@ -31,8 +31,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.shared.invoker.InvocationRequest; -import org.codehaus.plexus.util.StringUtils; /** * Provides a convenient facade around the invoker.properties. diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java index bd3708de..0e08bbaf 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Locale; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; @@ -38,7 +39,6 @@ import org.apache.maven.reporting.MavenReportException; import org.codehaus.plexus.i18n.I18N; import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.XmlStreamReader; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; diff --git a/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java b/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java index fc062603..5cba3f4e 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java +++ b/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java @@ -32,12 +32,12 @@ import java.util.Properties; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.invoker.AbstractInvokerMojo.ToolchainPrivateManager; import org.apache.maven.project.MavenProject; import org.apache.maven.toolchain.MisconfiguredToolchainException; import org.apache.maven.toolchain.ToolchainPrivate; import org.codehaus.plexus.util.Os; -import org.codehaus.plexus.util.StringUtils; /** * Provides utility methods for selecting build jobs based on environmental conditions. From 9c3e913e04cbf3b930c537a07ee5946e3251c24e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 24 Apr 2023 11:51:59 +0200 Subject: [PATCH 19/92] configure notifications --- .asf.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.asf.yaml b/.asf.yaml index 8c718460..14864468 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -29,4 +29,9 @@ github: merge: false rebase: true autolink_jira: - - MINVOKER \ No newline at end of file + - MINVOKER +notifications: + commits: commits@maven.apache.org + issues: issues@maven.apache.org + pullrequests: issues@maven.apache.org + jira_options: link label comment From 4afec1d322e912b188982255de9801dcaf793186 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 14 May 2023 20:19:51 +0200 Subject: [PATCH 20/92] [MINVOKER-338] Bump groovy-bom from 4.0.10 to 4.0.12 (#188) Bumps [groovy-bom](https://github.com/apache/groovy) from 4.0.10 to 4.0.12. - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8aa405f0..7725f9bb 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ under the License. bsh 2.0b6 2023-03-27T20:03:23Z - 4.0.10 + 4.0.12 From 401c229952bce1842756fb72963ae9b343c2517f Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Mon, 22 May 2023 13:32:58 +0200 Subject: [PATCH 21/92] [MNG-6829] Replace StringUtils#isEmpty(String) and #isNotEmpty(String) (#189) Continuation of https://issues.apache.org/jira/browse/MNG-6829 Review requested of @elharo Use this link to re-run the recipe: https://public.moderne.io/recipes/org.openrewrite.java.migrate.apache.commons.lang.IsNotEmptyToJdk?organizationId=QXBhY2hlIE1hdmVu Co-authored-by: Moderne --- .../apache/maven/plugins/invoker/AbstractInvokerMojo.java | 6 +++--- .../org/apache/maven/plugins/invoker/InvokerReport.java | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index be59fed8..b297a2c4 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -754,7 +754,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { return; } - if (StringUtils.isEmpty(encoding)) { + if (encoding == null || encoding.isEmpty()) { getLog().warn("File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING + ", i.e. build is platform dependent!"); } @@ -1477,7 +1477,7 @@ private CharSequence resolveExternalJreVersion() { private File interpolatePomFile(File pomFile, File basedir) throws MojoExecutionException { File interpolatedPomFile = null; if (pomFile != null) { - if (StringUtils.isNotEmpty(filteredPomPrefix)) { + if (filteredPomPrefix != null && !filteredPomPrefix.isEmpty()) { interpolatedPomFile = new File(basedir, filteredPomPrefix + pomFile.getName()); buildInterpolatedFile(pomFile, interpolatedPomFile); } else { @@ -1640,7 +1640,7 @@ private MessageBuilder pad(BuildJob buildJob) { * @param interpolatedPomFile The interpolated pom file. */ private void deleteInterpolatedPomFile(File interpolatedPomFile) { - if (interpolatedPomFile != null && StringUtils.isNotEmpty(filteredPomPrefix)) { + if (interpolatedPomFile != null && (filteredPomPrefix != null && !filteredPomPrefix.isEmpty())) { interpolatedPomFile.delete(); } } diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java index 0e08bbaf..40cc33bd 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Locale; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; @@ -260,8 +259,8 @@ private void renderBuildJob(BuildJob buildJob) { private String getBuildJobReportName(BuildJob buildJob) { String buildJobName = buildJob.getName(); String buildJobDescription = buildJob.getDescription(); - boolean emptyJobName = StringUtils.isEmpty(buildJobName); - boolean emptyJobDescription = StringUtils.isEmpty(buildJobDescription); + boolean emptyJobName = buildJobName == null || buildJobName.isEmpty(); + boolean emptyJobDescription = buildJobDescription == null || buildJobDescription.isEmpty(); boolean isReportJobNameComplete = !emptyJobName && !emptyJobDescription; if (isReportJobNameComplete) { return getFormattedName(buildJobName, buildJobDescription); From 6c0c181e09c45c0d1e02c8ccfa51f503ad7751f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 May 2023 04:57:29 +0000 Subject: [PATCH 22/92] Bump maven-shared-utils from 3.3.4 to 3.4.1 Bumps [maven-shared-utils](https://github.com/apache/maven-shared-utils) from 3.3.4 to 3.4.1. - [Release notes](https://github.com/apache/maven-shared-utils/releases) - [Commits](https://github.com/apache/maven-shared-utils/compare/maven-shared-utils-3.3.4...maven-shared-utils-3.4.1) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-shared-utils dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7725f9bb..e2ebdfeb 100644 --- a/pom.xml +++ b/pom.xml @@ -230,7 +230,7 @@ under the License. org.apache.maven.shared maven-shared-utils - 3.3.4 + 3.4.1 From 26f2dcfcb76b8e23f986954f4670c189f3ead153 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 11 Jun 2023 13:23:20 +0200 Subject: [PATCH 23/92] [MINVOKER-341] Make elapsed time field type consistent with Maven Surefire This closes #191 --- .../plugins/invoker/AbstractInvokerMojo.java | 24 ++++++++++--------- src/main/mdo/invocation.mdo | 4 ++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index b297a2c4..bb51e1be 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -111,6 +111,8 @@ * @since 15-Aug-2009 09:09:29 */ public abstract class AbstractInvokerMojo extends AbstractMojo { + private static final float ONE_SECOND = 1000.0f; + /** * The zero-based column index where to print the invoker result. */ @@ -1534,7 +1536,7 @@ private void runBuild( try { int selection = getSelection(invokerProperties, actualJreVersion); if (selection == 0) { - long milliseconds = System.currentTimeMillis(); + long startTime = System.currentTimeMillis(); boolean executed; FileLogger buildLogger = setupBuildLogFile(basedir); @@ -1546,8 +1548,8 @@ private void runBuild( executed = runBuild( basedir, interpolatedPomFile, settingsFile, actualJavaHome, invokerProperties, buildLogger); } finally { - milliseconds = System.currentTimeMillis() - milliseconds; - buildJob.setTime(milliseconds / 1000.0); + long elapsedTime = System.currentTimeMillis() - startTime; + buildJob.setTime(elapsedTime / ONE_SECOND); if (buildLogger != null) { buildLogger.close(); @@ -1697,7 +1699,7 @@ private void writeJunitReport(BuildJob buildJob, String safeFileName) throws Moj File reportFile = new File(reportsDirectory, "TEST-" + safeFileName + ".xml"); Xpp3Dom testsuite = new Xpp3Dom("testsuite"); testsuite.setAttribute("name", junitPackageName + "." + safeFileName); - testsuite.setAttribute("time", Double.toString(buildJob.getTime())); + testsuite.setAttribute("time", Float.toString(buildJob.getTime())); // set default value for required attributes testsuite.setAttribute("tests", "1"); @@ -1729,7 +1731,7 @@ private void writeJunitReport(BuildJob buildJob, String safeFileName) throws Moj } testcase.setAttribute("classname", junitPackageName + "." + safeFileName); testcase.setAttribute("name", safeFileName); - testcase.setAttribute("time", Double.toString(buildJob.getTime())); + testcase.setAttribute("time", Float.toString(buildJob.getTime())); Xpp3Dom systemOut = new Xpp3Dom("system-out"); testcase.addChild(systemOut); @@ -1755,13 +1757,13 @@ private void writeJunitReport(BuildJob buildJob, String safeFileName) throws Moj } /** - * Formats the specified build duration time. + * Formats the specified elapsed time. * - * @param seconds The duration of the build. + * @param time The eapsed time of the build. * @return The formatted time, never null. */ - private String formatTime(double seconds) { - return secFormat.format(seconds); + private String formatTime(float time) { + return secFormat.format(time); } /** @@ -1882,8 +1884,8 @@ private boolean runBuild( int getParallelThreadsCount() { if (parallelThreads.endsWith("C")) { - double parallelThreadsMultiple = - Double.parseDouble(parallelThreads.substring(0, parallelThreads.length() - 1)); + float parallelThreadsMultiple = + Float.parseFloat(parallelThreads.substring(0, parallelThreads.length() - 1)); return (int) (parallelThreadsMultiple * Runtime.getRuntime().availableProcessors()); } else { return Integer.parseInt(parallelThreads); diff --git a/src/main/mdo/invocation.mdo b/src/main/mdo/invocation.mdo index 6529e7c6..f4af4252 100644 --- a/src/main/mdo/invocation.mdo +++ b/src/main/mdo/invocation.mdo @@ -86,7 +86,7 @@ under the License. time 1.0.0 true - double + float The number of seconds that this build job took to complete. @@ -126,7 +126,7 @@ under the License. /** * Creates a new build job with the specified project path. - * + * * @param project The path to the project. */ public BuildJob( String project ) From 3dff59f19ab1b810a4a300a7f06ee8d90b605782 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 11 Jun 2023 13:49:58 +0200 Subject: [PATCH 24/92] [MINVOKER-342] Use ChoiceFormat to selectively render elapsed time in AbstractInvokerMojo This closes #192 --- .../plugins/invoker/AbstractInvokerMojo.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index bb51e1be..26320208 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -31,8 +31,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -704,11 +703,6 @@ public abstract class AbstractInvokerMojo extends AbstractMojo { */ private String filteredPomPrefix = "interpolated-"; - /** - * The format for elapsed build time. - */ - private final DecimalFormat secFormat = new DecimalFormat("(0.0 s)", new DecimalFormatSymbols(Locale.ENGLISH)); - /** * The version of Maven which is used to run the builds */ @@ -1560,13 +1554,15 @@ private void runBuild( buildJob.setResult(BuildJob.Result.SUCCESS); if (!suppressSummaries) { - getLog().info(pad(buildJob).success("SUCCESS").a(' ') + formatTime(buildJob.getTime())); + getLog().info(pad(buildJob).success("SUCCESS").a(' ') + "(" + + formatElapsedTime(buildJob.getTime()) + ")"); } } else { buildJob.setResult(BuildJob.Result.SKIPPED); if (!suppressSummaries) { - getLog().info(pad(buildJob).warning("SKIPPED").a(' ') + formatTime(buildJob.getTime())); + getLog().info(pad(buildJob).warning("SKIPPED").a(' ') + "(" + + formatElapsedTime(buildJob.getTime()) + ")"); } } } else { @@ -1606,7 +1602,8 @@ private void runBuild( if (!suppressSummaries) { getLog().info(" " + e.getMessage()); - getLog().info(pad(buildJob).failure("FAILED").a(' ') + formatTime(buildJob.getTime())); + getLog().info(pad(buildJob).failure("FAILED").a(' ') + "(" + formatElapsedTime(buildJob.getTime()) + + ")"); } } finally { deleteInterpolatedPomFile(interpolatedPomFile); @@ -1762,8 +1759,15 @@ private void writeJunitReport(BuildJob buildJob, String safeFileName) throws Moj * @param time The eapsed time of the build. * @return The formatted time, never null. */ - private String formatTime(float time) { - return secFormat.format(time); + private String formatElapsedTime(float time) { + /* + * Rationale: The idea is to always display four digits for visually consistent output + * Important: Keep in sync with src/main/resources/invoker-report.properties + */ + final MessageFormat elapsedTimeFormat = new MessageFormat( + "{0,choice,0#0|0.0<{0,number,0.000}|10#{0,number,0.00}|100#{0,number,0.0}|1000#{0,number,0}} s", + Locale.ROOT); + return elapsedTimeFormat.format(new Object[] {time}); } /** From a154e5b13dd7d900829d1d951efff50c41f25738 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 11 Jun 2023 16:07:27 +0200 Subject: [PATCH 25/92] [MINVOKER-344] Move reporting rendering logic into a ReportRenderer class This closes #193 --- .../maven/plugins/invoker/InvokerReport.java | 254 ++---------------- .../invoker/InvokerReportRenderer.java | 210 +++++++++++++++ src/main/resources/invoker-report.properties | 37 ++- .../resources/invoker-report_de.properties | 33 ++- .../resources/invoker-report_fr.properties | 35 ++- 5 files changed, 281 insertions(+), 288 deletions(-) create mode 100644 src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java index 40cc33bd..339705a4 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java @@ -20,15 +20,10 @@ import java.io.File; import java.io.IOException; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.text.MessageFormat; -import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -52,12 +47,6 @@ @Mojo(name = "report", threadSafe = true) public class InvokerReport extends AbstractMavenReport { - /** - * Internationalization component. - */ - @Component - protected I18N i18n; - /** * Base directory where all build reports have been written to. */ @@ -65,58 +54,14 @@ public class InvokerReport extends AbstractMavenReport { private File reportsDirectory; /** - * The number format used to print percent values in the report locale. - */ - private NumberFormat percentFormat; - - /** - * The number format used to print time values in the report locale. - */ - private NumberFormat secondsFormat; - - /** - * The format used to print build name and description. + * Internationalization component */ - private MessageFormat nameAndDescriptionFormat; + @Component + protected I18N i18n; protected void executeReport(Locale locale) throws MavenReportException { - DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale); - percentFormat = new DecimalFormat(getText(locale, "report.invoker.format.percent"), symbols); - secondsFormat = new DecimalFormat(getText(locale, "report.invoker.format.seconds"), symbols); - nameAndDescriptionFormat = new MessageFormat(getText(locale, "report.invoker.format.name_with_description")); - - Sink sink = getSink(); - - sink.head(); - - sink.title(); - sink.text(getText(locale, "report.invoker.result.title")); - sink.title_(); - - sink.head_(); - - sink.body(); - - sink.section1(); - sink.sectionTitle1(); - sink.text(getText(locale, "report.invoker.result.title")); - sink.sectionTitle1_(); - sink.paragraph(); - sink.text(getText(locale, "report.invoker.result.description")); - sink.paragraph_(); - sink.section1_(); - - // ---------------------------------- - // build buildJob beans - // ---------------------------------- - File[] reportFiles = ReportUtils.getReportFiles(reportsDirectory); - if (reportFiles.length <= 0) { - getLog().info("no invoker report files found, skip report generation"); - return; - } - + File[] reportFiles = getReportFiles(); BuildJobXpp3Reader buildJobReader = new BuildJobXpp3Reader(); - List buildJobs = new ArrayList<>(reportFiles.length); for (File reportFile : reportFiles) { try (XmlStreamReader xmlReader = ReaderFactory.newXmlReader(reportFile)) { @@ -127,193 +72,38 @@ protected void executeReport(Locale locale) throws MavenReportException { throw new MavenReportException("Failed to read report file: " + reportFile, e); } } - - // ---------------------------------- - // summary - // ---------------------------------- - - constructSummarySection(buildJobs, locale); - - // ---------------------------------- - // per file/it detail - // ---------------------------------- - - sink.section2(); - sink.sectionTitle2(); - - sink.text(getText(locale, "report.invoker.detail.title")); - - sink.sectionTitle2_(); - - sink.section2_(); - - // detail tests table header - sink.table(); - sink.tableRows(null, false); - - sink.tableRow(); - // ------------------------------------------- - // name | Result | time | message - // ------------------------------------------- - sinkTableHeader(sink, getText(locale, "report.invoker.detail.name")); - sinkTableHeader(sink, getText(locale, "report.invoker.detail.result")); - sinkTableHeader(sink, getText(locale, "report.invoker.detail.time")); - sinkTableHeader(sink, getText(locale, "report.invoker.detail.message")); - - sink.tableRow_(); - - for (BuildJob buildJob : buildJobs) { - renderBuildJob(buildJob); - } - - sink.tableRows_(); - sink.table_(); - - sink.body_(); - - sink.flush(); - sink.close(); + InvokerReportRenderer r = new InvokerReportRenderer(getSink(), i18n, locale, getLog(), buildJobs); + r.render(); } - private void constructSummarySection(List buildJobs, Locale locale) { - Sink sink = getSink(); - - sink.section2(); - sink.sectionTitle2(); - - sink.text(getText(locale, "report.invoker.summary.title")); - - sink.sectionTitle2_(); - sink.section2_(); - - // ------------------------------------------------------------------------ - // Building a table with - // it number | succes nb | failed nb | Success rate | total time | avg time - // ------------------------------------------------------------------------ - - sink.table(); - sink.tableRows(null, false); - - sink.tableRow(); - - sinkTableHeader(sink, getText(locale, "report.invoker.summary.number")); - sinkTableHeader(sink, getText(locale, "report.invoker.summary.success")); - sinkTableHeader(sink, getText(locale, "report.invoker.summary.failed")); - sinkTableHeader(sink, getText(locale, "report.invoker.summary.skipped")); - sinkTableHeader(sink, getText(locale, "report.invoker.summary.success.rate")); - sinkTableHeader(sink, getText(locale, "report.invoker.summary.time.total")); - sinkTableHeader(sink, getText(locale, "report.invoker.summary.time.avg")); - - int number = buildJobs.size(); - int success = 0; - int failed = 0; - int skipped = 0; - double totalTime = 0; - - for (BuildJob buildJob : buildJobs) { - if (BuildJob.Result.SUCCESS.equals(buildJob.getResult())) { - success++; - } else if (BuildJob.Result.SKIPPED.equals(buildJob.getResult())) { - skipped++; - } else { - failed++; - } - totalTime += buildJob.getTime(); - } - - sink.tableRow_(); - sink.tableRow(); - - sinkCell(sink, Integer.toString(number)); - sinkCell(sink, Integer.toString(success)); - sinkCell(sink, Integer.toString(failed)); - sinkCell(sink, Integer.toString(skipped)); - - if (success + failed > 0) { - sinkCell(sink, percentFormat.format((double) success / (success + failed))); - } else { - sinkCell(sink, ""); - } - - sinkCell(sink, secondsFormat.format(totalTime)); - - sinkCell(sink, secondsFormat.format(totalTime / number)); - - sink.tableRow_(); - - sink.tableRows_(); - sink.table_(); - } - - private void renderBuildJob(BuildJob buildJob) { - Sink sink = getSink(); - sink.tableRow(); - sinkCell(sink, getBuildJobReportName(buildJob)); - // FIXME image - sinkCell(sink, buildJob.getResult()); - sinkCell(sink, secondsFormat.format(buildJob.getTime())); - sinkCell(sink, buildJob.getFailureMessage()); - sink.tableRow_(); - } - - private String getBuildJobReportName(BuildJob buildJob) { - String buildJobName = buildJob.getName(); - String buildJobDescription = buildJob.getDescription(); - boolean emptyJobName = buildJobName == null || buildJobName.isEmpty(); - boolean emptyJobDescription = buildJobDescription == null || buildJobDescription.isEmpty(); - boolean isReportJobNameComplete = !emptyJobName && !emptyJobDescription; - if (isReportJobNameComplete) { - return getFormattedName(buildJobName, buildJobDescription); - } else { - String buildJobProject = buildJob.getProject(); - if (!emptyJobName) { - getLog().warn(incompleteNameWarning("description", buildJobProject)); - } else if (!emptyJobDescription) { - getLog().warn(incompleteNameWarning("name", buildJobProject)); - } - return buildJobProject; - } - } - - private static String incompleteNameWarning(String missing, String pom) { - return String.format( - "Incomplete job name-description: %s is missing. " + "POM (%s) will be used in place of job name.", - missing, pom); + /** + * @param locale The locale + * @param key The key to search for + * @return The text appropriate for the locale. + */ + private String getI18nString(Locale locale, String key) { + return i18n.getString("invoker-report", locale, "report.invoker." + key); } - private String getFormattedName(String name, String description) { - return nameAndDescriptionFormat.format(new Object[] {name, description}); + /** {@inheritDoc} */ + public String getName(Locale locale) { + return getI18nString(locale, "name"); } + /** {@inheritDoc} */ public String getDescription(Locale locale) { - return getText(locale, "report.invoker.result.description"); - } - - public String getName(Locale locale) { - return getText(locale, "report.invoker.result.name"); + return getI18nString(locale, "description"); } public String getOutputName() { return "invoker-report"; } - public boolean canGenerateReport() { - return ReportUtils.getReportFiles(reportsDirectory).length > 0; + private File[] getReportFiles() { + return ReportUtils.getReportFiles(reportsDirectory); } - private String getText(Locale locale, String key) { - return i18n.getString("invoker-report", locale, key); - } - - private void sinkTableHeader(Sink sink, String header) { - sink.tableHeaderCell(); - sink.text(header); - sink.tableHeaderCell_(); - } - - private void sinkCell(Sink sink, String text) { - sink.tableCell(); - sink.text(text); - sink.tableCell_(); + public boolean canGenerateReport() { + return getReportFiles().length > 0; } } diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java new file mode 100644 index 00000000..eae9739b --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java @@ -0,0 +1,210 @@ +/* + * 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. + */ +package org.apache.maven.plugins.invoker; + +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.MessageFormat; +import java.text.NumberFormat; +import java.util.List; +import java.util.Locale; + +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugins.invoker.model.BuildJob; +import org.apache.maven.reporting.AbstractMavenReportRenderer; +import org.codehaus.plexus.i18n.I18N; + +public class InvokerReportRenderer extends AbstractMavenReportRenderer { + private final I18N i18n; + private final Locale locale; + private final Log log; + private final List buildJobs; + + /** + * The number format used to print percent values in the report locale. + */ + private NumberFormat percentFormat; + + /** + * The number format used to print time values in the report locale. + */ + private NumberFormat secondsFormat; + + /** + * The format used to print build name and description. + */ + private MessageFormat nameAndDescriptionFormat; + + public InvokerReportRenderer(Sink sink, I18N i18n, Locale locale, Log log, List buildJobs) { + super(sink); + this.i18n = i18n; + this.locale = locale; + this.log = log; + this.buildJobs = buildJobs; + } + + @Override + public String getTitle() { + return getI18nString("title"); + } + + /** + * @param key The key to translate. + * @return the translated key. + */ + private String getI18nString(String key) { + return i18n.getString("invoker-report", locale, "report.invoker." + key); + } + + /** + * @param key The key to translate. + * @param args The args to pass to translated string. + * @return the translated key. + */ + private String formatI18nString(String key, Object... args) { + return i18n.format("invoker-report", locale, "report.invoker." + key, args); + } + + @Override + protected void renderBody() { + DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale); + percentFormat = new DecimalFormat(getI18nString("format.percent"), symbols); + secondsFormat = new DecimalFormat(getI18nString("format.seconds"), symbols); + nameAndDescriptionFormat = new MessageFormat(getI18nString("format.name_with_description")); + + startSection(getTitle()); + paragraph(getI18nString("description")); + + renderSectionSummary(); + + renderSectionDetails(); + + endSection(); + } + + private void renderSectionSummary() { + startSection(getI18nString("summary.title")); + + startTable(); + + tableHeader(new String[] { + getI18nString("summary.builds"), + getI18nString("summary.success"), + getI18nString("summary.failures"), + getI18nString("summary.skipped"), + getI18nString("summary.successrate"), + getI18nString("summary.time") + }); + + int totalBuilds = buildJobs.size(); + int totalSuccess = 0; + int totalFailures = 0; + int totalSkipped = 0; + float totalTime = 0.0f; + + for (BuildJob buildJob : buildJobs) { + switch (buildJob.getResult()) { + case BuildJob.Result.SUCCESS: + totalSuccess++; + break; + case BuildJob.Result.SKIPPED: + totalSkipped++; + break; + default: + totalFailures++; + } + totalTime += buildJob.getTime(); + } + + tableRow(new String[] { + Integer.toString(totalBuilds), + Integer.toString(totalSuccess), + Integer.toString(totalFailures), + Integer.toString(totalSkipped), + (totalSuccess + totalFailures > 0) + ? percentFormat.format(totalSuccess / (float) (totalSuccess + totalFailures)) + : "", + secondsFormat.format(totalTime) + }); + + endTable(); + + endSection(); + } + + private void renderSectionDetails() { + startSection(getI18nString("detail.title")); + + startTable(); + + tableHeader(new String[] { + getI18nString("detail.name"), + getI18nString("detail.result"), + getI18nString("detail.time"), + getI18nString("detail.message") + }); + + for (BuildJob buildJob : buildJobs) { + renderBuildJob(buildJob); + } + + endTable(); + + endSection(); + } + + private void renderBuildJob(BuildJob buildJob) { + tableRow(new String[] { + getBuildJobReportName(buildJob), + // FIXME image + buildJob.getResult(), + secondsFormat.format(buildJob.getTime()), + buildJob.getFailureMessage() + }); + } + + private String getBuildJobReportName(BuildJob buildJob) { + String buildJobName = buildJob.getName(); + String buildJobDescription = buildJob.getDescription(); + boolean emptyJobName = buildJobName == null || buildJobName.isEmpty(); + boolean emptyJobDescription = buildJobDescription == null || buildJobDescription.isEmpty(); + boolean isReportJobNameComplete = !emptyJobName && !emptyJobDescription; + if (isReportJobNameComplete) { + return getFormattedName(buildJobName, buildJobDescription); + } else { + String buildJobProject = buildJob.getProject(); + if (!emptyJobName) { + log.warn(incompleteNameWarning("description", buildJobProject)); + } else if (!emptyJobDescription) { + log.warn(incompleteNameWarning("name", buildJobProject)); + } + return buildJobProject; + } + } + + private static String incompleteNameWarning(String missing, String pom) { + return "Incomplete job name-description: " + missing + " is missing. POM (" + pom + + ") will be used in place of job name!"; + } + + private String getFormattedName(String name, String description) { + return nameAndDescriptionFormat.format(new Object[] {name, description}); + } +} diff --git a/src/main/resources/invoker-report.properties b/src/main/resources/invoker-report.properties index 5fe569d2..e746c3ef 100644 --- a/src/main/resources/invoker-report.properties +++ b/src/main/resources/invoker-report.properties @@ -15,22 +15,21 @@ # specific language governing permissions and limitations # under the License. -report.invoker.result.description = The results of the Maven invocations. -report.invoker.result.name = Invoker Build Results -report.invoker.result.title = Invoker Report -report.invoker.summary.title = Summary -report.invoker.summary.number = Builds -report.invoker.summary.success = Success -report.invoker.summary.failed = Failures -report.invoker.summary.skipped = Skipped -report.invoker.summary.success.rate = Success Rate -report.invoker.summary.time.total = Total Time -report.invoker.summary.time.avg = Avg Time -report.invoker.detail.title = Build Details -report.invoker.detail.name = Name -report.invoker.detail.result = Result -report.invoker.detail.time = Time -report.invoker.detail.message = Message -report.invoker.format.percent = 0.0% -report.invoker.format.seconds = 0.0\u00A0s -report.invoker.format.name_with_description = {0}: {1} +report.invoker.name=Invoker +report.invoker.description=Report on the build results of the Maven invocations. +report.invoker.title=Invoker Report +report.invoker.summary.title=Summary +report.invoker.summary.builds=Builds +report.invoker.summary.success=Success +report.invoker.summary.failures=Failures +report.invoker.summary.skipped=Skipped +report.invoker.summary.successrate=Success Rate +report.invoker.summary.time=Time +report.invoker.detail.title=Build Details +report.invoker.detail.name=Name +report.invoker.detail.result=Result +report.invoker.detail.time=Time +report.invoker.detail.message=Message +report.invoker.format.percent=0.0% +report.invoker.format.seconds=0.0\u00A0s +report.invoker.format.name_with_description={0}: {1} diff --git a/src/main/resources/invoker-report_de.properties b/src/main/resources/invoker-report_de.properties index d1016e30..41e030be 100644 --- a/src/main/resources/invoker-report_de.properties +++ b/src/main/resources/invoker-report_de.properties @@ -15,21 +15,18 @@ # specific language governing permissions and limitations # under the License. -report.invoker.result.description = Die Ergebnisse der Maven-Ausf\u00FChrungen. -report.invoker.result.name = Invoker-Build-Ergebnisse -report.invoker.result.title = Invoker-Bericht -report.invoker.summary.title = Zusammenfassungen -report.invoker.summary.number = Builds -report.invoker.summary.success = Erfolge -report.invoker.summary.failed = Fehlschl\u00E4ge -report.invoker.summary.skipped = Ausgelassen -report.invoker.summary.success.rate = Erfolgsrate -report.invoker.summary.time.total = Gesamtzeit -report.invoker.summary.time.avg = Durchschnittszeit -report.invoker.detail.title = Build-Details -report.invoker.detail.name = Name -report.invoker.detail.result = Ergebnis -report.invoker.detail.time = Zeit -report.invoker.detail.message = Meldung -report.invoker.format.percent = 0.0\u00A0% -report.invoker.format.seconds = 0.0\u00A0s +report.invoker.description=Bericht \u00FCber die Build-Ergebnisse der Maven-Ausf\u00FChrungen. +report.invoker.title=Invoker-Bericht +report.invoker.summary.title=Zusammenfassung +report.invoker.summary.builds=Builds +report.invoker.summary.success=Erfolge +report.invoker.summary.failures=Fehlschl\u00E4ge +report.invoker.summary.skipped=Ausgelassen +report.invoker.summary.successrate=Erfolgsrate +report.invoker.summary.time=Zeit +report.invoker.detail.title=Build-Details +report.invoker.detail.name=Name +report.invoker.detail.result=Ergebnis +report.invoker.detail.time=Zeit +report.invoker.detail.message=Meldung +report.invoker.format.percent=0.0\u00A0% diff --git a/src/main/resources/invoker-report_fr.properties b/src/main/resources/invoker-report_fr.properties index 1d3393ab..7da545ad 100644 --- a/src/main/resources/invoker-report_fr.properties +++ b/src/main/resources/invoker-report_fr.properties @@ -15,22 +15,19 @@ # specific language governing permissions and limitations # under the License. -report.invoker.result.description = Résultat des invocations de Maven -report.invoker.result.name = Invoker Résultat de builds -report.invoker.result.title = Invoker Rapport -report.invoker.summary.title = Sommaire -report.invoker.summary.number = Builds -report.invoker.summary.success = Réussis -report.invoker.summary.failed = Echecs -report.invoker.summary.skipped = Ignorés -report.invoker.summary.success.rate = Taux de réussite -report.invoker.summary.time.total = Durée totale -report.invoker.summary.time.avg = Durée moyenne -report.invoker.detail.title = Détails de Build -report.invoker.detail.name = Nom -report.invoker.detail.result = Résultat -report.invoker.detail.time = Durée -report.invoker.detail.message = Message -report.invoker.format.percent = 0.0% -report.invoker.format.seconds = 0.0\u00A0s -report.invoker.format.name_with_description = {0} : {1} +report.invoker.description=Résultat des invocations de Maven +report.invoker.title=Invoker Rapport +report.invoker.summary.title=Sommaire +report.invoker.summary.builds=Builds +report.invoker.summary.success=Réussis +report.invoker.summary.failures=Echecs +report.invoker.summary.skipped=Ignorés +report.invoker.summary.successrate=Taux de réussite +report.invoker.summary.time=Durée +report.invoker.detail.title=Détails de Build +report.invoker.detail.name=Nom +report.invoker.detail.result=Résultat +report.invoker.detail.time=Durée +report.invoker.detail.message=Message +report.invoker.format.percent=0.0\u00A0% +report.invoker.format.name_with_description={0} : {1} From 3df7c384accf3489122a7f17995c778755d7ba88 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 11 Jun 2023 17:49:55 +0200 Subject: [PATCH 26/92] [MINVOKER-345] Use ChoiceFormat to selectively render percentage and elapsed time in InvokerReportRenderer This closes #194 --- .../invoker/InvokerReportRenderer.java | 36 +++---------------- src/main/resources/invoker-report.properties | 10 ++++-- .../resources/invoker-report_de.properties | 2 +- .../resources/invoker-report_fr.properties | 4 +-- 4 files changed, 14 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java index eae9739b..3958a0a2 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java @@ -18,10 +18,6 @@ */ package org.apache.maven.plugins.invoker; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.text.MessageFormat; -import java.text.NumberFormat; import java.util.List; import java.util.Locale; @@ -37,21 +33,6 @@ public class InvokerReportRenderer extends AbstractMavenReportRenderer { private final Log log; private final List buildJobs; - /** - * The number format used to print percent values in the report locale. - */ - private NumberFormat percentFormat; - - /** - * The number format used to print time values in the report locale. - */ - private NumberFormat secondsFormat; - - /** - * The format used to print build name and description. - */ - private MessageFormat nameAndDescriptionFormat; - public InvokerReportRenderer(Sink sink, I18N i18n, Locale locale, Log log, List buildJobs) { super(sink); this.i18n = i18n; @@ -84,11 +65,6 @@ private String formatI18nString(String key, Object... args) { @Override protected void renderBody() { - DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale); - percentFormat = new DecimalFormat(getI18nString("format.percent"), symbols); - secondsFormat = new DecimalFormat(getI18nString("format.seconds"), symbols); - nameAndDescriptionFormat = new MessageFormat(getI18nString("format.name_with_description")); - startSection(getTitle()); paragraph(getI18nString("description")); @@ -139,9 +115,9 @@ private void renderSectionSummary() { Integer.toString(totalFailures), Integer.toString(totalSkipped), (totalSuccess + totalFailures > 0) - ? percentFormat.format(totalSuccess / (float) (totalSuccess + totalFailures)) + ? formatI18nString("value.successrate", (totalSuccess / (float) (totalSuccess + totalFailures))) : "", - secondsFormat.format(totalTime) + formatI18nString("value.time", totalTime) }); endTable(); @@ -175,7 +151,7 @@ private void renderBuildJob(BuildJob buildJob) { getBuildJobReportName(buildJob), // FIXME image buildJob.getResult(), - secondsFormat.format(buildJob.getTime()), + formatI18nString("value.time", buildJob.getTime()), buildJob.getFailureMessage() }); } @@ -187,7 +163,7 @@ private String getBuildJobReportName(BuildJob buildJob) { boolean emptyJobDescription = buildJobDescription == null || buildJobDescription.isEmpty(); boolean isReportJobNameComplete = !emptyJobName && !emptyJobDescription; if (isReportJobNameComplete) { - return getFormattedName(buildJobName, buildJobDescription); + return formatI18nString("text.name_with_description", buildJobName, buildJobDescription); } else { String buildJobProject = buildJob.getProject(); if (!emptyJobName) { @@ -203,8 +179,4 @@ private static String incompleteNameWarning(String missing, String pom) { return "Incomplete job name-description: " + missing + " is missing. POM (" + pom + ") will be used in place of job name!"; } - - private String getFormattedName(String name, String description) { - return nameAndDescriptionFormat.format(new Object[] {name, description}); - } } diff --git a/src/main/resources/invoker-report.properties b/src/main/resources/invoker-report.properties index e746c3ef..9753d833 100644 --- a/src/main/resources/invoker-report.properties +++ b/src/main/resources/invoker-report.properties @@ -30,6 +30,10 @@ report.invoker.detail.name=Name report.invoker.detail.result=Result report.invoker.detail.time=Time report.invoker.detail.message=Message -report.invoker.format.percent=0.0% -report.invoker.format.seconds=0.0\u00A0s -report.invoker.format.name_with_description={0}: {1} +report.invoker.value.successrate={0,choice,0#0%|0.0<{0,number,0.0%}|1#{0,number,0%}} +# Rationale: The idea is to always display four digits for visually consistent output +# Important: +# * Keep in sync with org.apache.maven.plugins.invoker.AbstractInvokerMojo +# * Needs to be copied into other bundles only if non-Latin script is used +report.invoker.value.time={0,choice,0#0|0.0<{0,number,0.000}|10#{0,number,0.00}|100#{0,number,0.0}|1000#{0,number,0}} s +report.invoker.text.name_with_description={0}: {1} diff --git a/src/main/resources/invoker-report_de.properties b/src/main/resources/invoker-report_de.properties index 41e030be..ed617c34 100644 --- a/src/main/resources/invoker-report_de.properties +++ b/src/main/resources/invoker-report_de.properties @@ -29,4 +29,4 @@ report.invoker.detail.name=Name report.invoker.detail.result=Ergebnis report.invoker.detail.time=Zeit report.invoker.detail.message=Meldung -report.invoker.format.percent=0.0\u00A0% +report.invoker.value.successrate={0,choice,0#0 %|0.0<{0,number,0.0 %}|1#{0,number,0 %}} diff --git a/src/main/resources/invoker-report_fr.properties b/src/main/resources/invoker-report_fr.properties index 7da545ad..75b52756 100644 --- a/src/main/resources/invoker-report_fr.properties +++ b/src/main/resources/invoker-report_fr.properties @@ -29,5 +29,5 @@ report.invoker.detail.name=Nom report.invoker.detail.result=Résultat report.invoker.detail.time=Durée report.invoker.detail.message=Message -report.invoker.format.percent=0.0\u00A0% -report.invoker.format.name_with_description={0} : {1} +report.invoker.value.successrate={0,choice,0#0 %|0.0<{0,number,0.0 %}|1#{0,number,0 %}} +report.invoker.text.name_with_description={0} : {1} From 14ffae65a9f0db6cf623da820e7444a9d9cd0501 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 11 Jun 2023 18:35:09 +0200 Subject: [PATCH 27/92] [MINVOKER-347] Document upcoming report file name change --- src/site/apt/index.apt.vm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 4ffeda1d..a05187c4 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -34,6 +34,20 @@ ${project.name} This plugin is in particular handy to perform integration tests for other Maven plugins. The Invoker Plugin can be employed to run a set of test projects that have been designed to assert certain features of the plugin under test. +* Upcoming Incompatibility Notice + + With a future (minor) the report output filename will change for alignment with other + reporting plugins from <<>>. + To make you aware of that, see the following table for the upcoming changes: + +*---------------------*----------------------*------------------* +|| Mojo Class Name || Output name || New Output Name | +*---------------------+----------------------+------------------+ +| <<>> | <<>> | <<>> | +*---------------------+----------------------+------------------+ + + Details about this change can be found in {{{https://issues.apache.org/jira/browse/MINVOKER-346}MINVOKER-346}}. + * Goals Overview The plugin has four goals meant to participate in the default build lifecycle: @@ -98,7 +112,7 @@ ${project.name} * {{{./examples/prepare-build-env.html}Prepare the Build Environment}} by building some setup projects before other projects. - * {{{./examples/integration-test-verify.html}Using with other integration test frameworks}} by decoupling checking + * {{{./examples/integration-test-verify.html}Using with other integration test frameworks}} by decoupling checking the results of the integration tests from executing the integration tests. [] From d612eb63f2e5797728c29fec9ce7cef62541a87a Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 11 Jun 2023 19:18:01 +0200 Subject: [PATCH 28/92] [maven-release-plugin] prepare release maven-invoker-plugin-3.6.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index e2ebdfeb..7fe82ded 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.5.2-SNAPSHOT + 3.6.0 maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git - HEAD + maven-invoker-plugin-3.6.0 https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -66,7 +66,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2023-03-27T20:03:23Z + 2023-06-11T17:17:33Z 4.0.12 From ffb89ced0f2943c41dec5af946f2d7696f99a073 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 11 Jun 2023 19:18:10 +0200 Subject: [PATCH 29/92] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 7fe82ded..ffd6c916 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.6.0 + 3.6.1-SNAPSHOT maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git - maven-invoker-plugin-3.6.0 + HEAD https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -66,7 +66,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2023-06-11T17:17:33Z + 2023-06-11T17:18:10Z 4.0.12 From c57f670274111244877556426611f3ef789581cf Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 12 Jun 2023 09:11:20 -0400 Subject: [PATCH 30/92] add explicit dependency on commons-lang3 and update version (#196) --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index ffd6c916..cfffc615 100644 --- a/pom.xml +++ b/pom.xml @@ -206,6 +206,11 @@ under the License. runtime + + org.apache.commons + commons-lang3 + 3.12.0 + org.codehaus.plexus plexus-utils From 5472d12326f29ddb5ac681e283d8deeadc289ae0 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 12 Jun 2023 09:11:40 -0400 Subject: [PATCH 31/92] Update commons-io to 2.13.0 (#195) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cfffc615..4882f422 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ under the License. commons-io commons-io - 2.11.0 + 2.13.0 org.apache.groovy From fd333521a3d8b36502bb234bd169459f32985974 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Thu, 14 Dec 2023 16:01:05 +0100 Subject: [PATCH 32/92] Add .checkstyle to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f79c9285..8f9ebd5c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ out/ /bootstrap /dependencies.xml .java-version +.checkstyle \ No newline at end of file From d3a7592143f48d260536b0d8acfa9f9d878c7d7c Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Tue, 14 Nov 2023 09:58:18 +0100 Subject: [PATCH 33/92] [MINVOKER-350] - Upgrade maven-plugin parent to 41 --- pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4882f422..32446b10 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 39 + 41 @@ -396,7 +396,6 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - 3.5.0 ${project.build.directory}/it setup From 8b4829595bbd6bd3130538d144c0f22913770c7e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 30 Dec 2023 12:20:01 +0000 Subject: [PATCH 34/92] Bump org.codehaus.plexus:plexus-interpolation from 1.26 to 1.27 Bumps [org.codehaus.plexus:plexus-interpolation](https://github.com/codehaus-plexus/plexus-interpolation) from 1.26 to 1.27. - [Release notes](https://github.com/codehaus-plexus/plexus-interpolation/releases) - [Commits](https://github.com/codehaus-plexus/plexus-interpolation/compare/plexus-interpolation-1.26...plexus-interpolation-1.27) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-interpolation dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 32446b10..c87dfa78 100644 --- a/pom.xml +++ b/pom.xml @@ -219,7 +219,7 @@ under the License. org.codehaus.plexus plexus-interpolation - 1.26 + 1.27 org.codehaus.plexus From f9bb6661b693ffb332b8b130c3e6950a89972ef1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Dec 2023 04:03:28 +0000 Subject: [PATCH 35/92] Bump org.apache.maven.shared:maven-shared-utils from 3.4.1 to 3.4.2 Bumps [org.apache.maven.shared:maven-shared-utils](https://github.com/apache/maven-shared-utils) from 3.4.1 to 3.4.2. - [Release notes](https://github.com/apache/maven-shared-utils/releases) - [Commits](https://github.com/apache/maven-shared-utils/compare/maven-shared-utils-3.4.1...maven-shared-utils-3.4.2) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-shared-utils dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c87dfa78..65120e41 100644 --- a/pom.xml +++ b/pom.xml @@ -235,7 +235,7 @@ under the License. org.apache.maven.shared maven-shared-utils - 3.4.1 + 3.4.2 From cb814ee9011b4c65f4e2ea3b6e38d43787b79d2d Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 31 Dec 2023 16:02:41 +0100 Subject: [PATCH 36/92] Small code improvments. --- .../org/apache/maven/plugins/invoker/InvokerProperties.java | 4 ++-- .../org/apache/maven/plugins/invoker/InvokerToolchain.java | 2 +- .../java/org/apache/maven/plugins/invoker/JobExecutor.java | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java index f4e510e9..a315c554 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java @@ -88,7 +88,7 @@ public String toString() { private enum SelectorProperty { JAVA_VERSION(".java.version"), MAVEN_VERSION(".maven.version"), - OS_FAMLY(".os.family"); + OS_FAMILY(".os.family"); private final String suffix; @@ -281,7 +281,7 @@ public String getOsFamily() { * @since 3.0.0 */ public String getOsFamily(int index) { - return this.properties.getProperty(SELECTOR_PREFIX + index + SelectorProperty.OS_FAMLY, getOsFamily()); + return this.properties.getProperty(SELECTOR_PREFIX + index + SelectorProperty.OS_FAMILY, getOsFamily()); } public Collection getToolchains() { diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerToolchain.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerToolchain.java index a2e879b9..c132712c 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerToolchain.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerToolchain.java @@ -29,7 +29,7 @@ public class InvokerToolchain { private final String type; - private Map provides = new HashMap<>(); + private final Map provides = new HashMap<>(); public InvokerToolchain(String type) { this.type = type; diff --git a/src/main/java/org/apache/maven/plugins/invoker/JobExecutor.java b/src/main/java/org/apache/maven/plugins/invoker/JobExecutor.java index 3e2c3744..704e214a 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/JobExecutor.java +++ b/src/main/java/org/apache/maven/plugins/invoker/JobExecutor.java @@ -18,6 +18,7 @@ */ package org.apache.maven.plugins.invoker; +import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -49,7 +50,7 @@ interface ThrowableJobConsumer { public void forEach(ThrowableJobConsumer jobConsumer) { // group and sort jobs by ordinal Map> groupedJobs = jobs.stream() - .sorted((j1, j2) -> Integer.compare(j2.getOrdinal(), j1.getOrdinal())) + .sorted(Comparator.comparing(BuildJob::getOrdinal).reversed()) .collect(Collectors.groupingBy(BuildJob::getOrdinal, LinkedHashMap::new, Collectors.toList())); ExecutorService executorService = Executors.newFixedThreadPool(threadsCount); From f61e240ed7eed015aac82fc9e121922febb43b16 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Mon, 1 Jan 2024 13:58:53 +0100 Subject: [PATCH 37/92] [MINVOKER-352] - Remove usage commons-lang3 --- pom.xml | 5 ---- .../plugins/invoker/AbstractInvokerMojo.java | 13 ++++++---- .../plugins/invoker/InvokerProperties.java | 9 +++---- .../maven/plugins/invoker/SelectorUtils.java | 25 ++++++++++++------- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index 65120e41..c40407da 100644 --- a/pom.xml +++ b/pom.xml @@ -206,11 +206,6 @@ under the License. runtime - - org.apache.commons - commons-lang3 - 3.12.0 - org.codehaus.plexus plexus-utils diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 26320208..14ddb735 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -43,12 +43,12 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Properties; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; @@ -1020,8 +1020,7 @@ private void collectProjects( String projectDir = pomFile.getParent(); String parentPath = "../pom.xml"; - if (model.getParent() != null - && StringUtils.isNotEmpty(model.getParent().getRelativePath())) { + if (model.getParent() != null && isNotEmpty(model.getParent().getRelativePath())) { parentPath = model.getParent().getRelativePath(); } String parent = relativizePath(new File(projectDir, parentPath), projectsRoot); @@ -1044,6 +1043,10 @@ private void collectProjects( } } + private boolean isNotEmpty(String s) { + return Objects.nonNull(s) && !s.isEmpty(); + } + /** * Copies the specified projects to the directory given by {@link #cloneProjectsTo}. A project may either be denoted * by a path to a POM file or merely by a path to a base directory. During cloning, the POM files will be filtered. @@ -2031,7 +2034,7 @@ private void verify( private List calculateIncludes() { if (invokerTest != null) { - String[] testRegexes = StringUtils.split(invokerTest, ","); + String[] testRegexes = invokerTest.split(",+"); return Arrays.stream(testRegexes) .map(String::trim) .filter(s -> !s.isEmpty()) @@ -2049,7 +2052,7 @@ private List calculateExcludes() throws IOException { List excludes; if (invokerTest != null) { - String[] testRegexes = StringUtils.split(invokerTest, ","); + String[] testRegexes = invokerTest.split(",+"); excludes = Arrays.stream(testRegexes) .map(String::trim) .filter(s -> !s.isEmpty()) diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java index a315c554..15e246d0 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java @@ -31,7 +31,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.shared.invoker.InvocationRequest; /** @@ -43,7 +42,7 @@ class InvokerProperties { private static final String SELECTOR_PREFIX = "selector."; private static final Pattern ENVIRONMENT_VARIABLES_PATTERN = - Pattern.compile("invoker\\.environmentVariables\\.([A-Za-z][^.]+)(\\.([0-9]+))?"); + Pattern.compile("invoker\\.environmentVariables\\.([A-Za-z][^.]+)(\\.(\\d+))?"); // default values from Mojo configuration private Boolean defaultDebug; @@ -154,7 +153,7 @@ public void setDefaultProfiles(List defaultProfiles) { * @param defaultMavenExecutable a default value */ public void setDefaultMavenExecutable(String defaultMavenExecutable) { - if (StringUtils.isNotBlank(defaultMavenExecutable)) { + if (Objects.nonNull(defaultMavenExecutable) && !defaultMavenExecutable.isEmpty()) { this.defaultMavenExecutable = new File(defaultMavenExecutable); } } @@ -397,7 +396,7 @@ public void configureInvocation(InvocationRequest request, int index) { setIfNotNull( request::setGoals, get(InvocationProperty.GOALS, index) - .map(s -> StringUtils.split(s, ", \t\n\r\f")) + .map(s -> s.trim().split("\\s*[ ,]+\\s*")) .map(Arrays::asList) .filter(l -> !l.isEmpty()) .orElse(defaultGoals)); @@ -405,7 +404,7 @@ public void configureInvocation(InvocationRequest request, int index) { setIfNotNull( request::setProfiles, get(InvocationProperty.PROFILES, index) - .map(s -> StringUtils.split(s, ", \t\n\r\f")) + .map(s -> s.trim().split("\\s*[ ,]+\\s*")) .map(Arrays::asList) .filter(l -> !l.isEmpty()) .orElse(defaultProfiles)); diff --git a/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java b/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java index 5cba3f4e..00b54005 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java +++ b/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java @@ -29,10 +29,10 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.Objects; import java.util.Properties; import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.invoker.AbstractInvokerMojo.ToolchainPrivateManager; import org.apache.maven.project.MavenProject; import org.apache.maven.toolchain.MisconfiguredToolchainException; @@ -47,7 +47,11 @@ class SelectorUtils { static void parseList(String list, Collection includes, Collection excludes) { - String[] tokens = (list != null) ? StringUtils.split(list, ",") : new String[0]; + if (Objects.isNull(list)) { + return; + } + + String[] tokens = list.split(",+"); for (String token1 : tokens) { String token = token1.trim(); @@ -99,7 +103,8 @@ static String getMavenVersion() { .getClassLoader() .getResourceAsStream("META-INF/maven/org.apache.maven/maven-core/pom.properties")); // CHECKSTYLE_ON: LineLength - return StringUtils.trim(properties.getProperty("version")); + String str = properties.getProperty("version"); + return str == null ? null : str.trim(); } catch (Exception e) { return null; } @@ -121,7 +126,8 @@ static String getMavenVersion(File mavenHome) throws IOException { try (InputStream in = url.openStream()) { Properties properties = new Properties(); properties.load(in); - String version = StringUtils.trim(properties.getProperty("version")); + String str = properties.getProperty("version"); + String version = str == null ? null : str.trim(); if (version != null) { return version; } @@ -201,13 +207,14 @@ static boolean isJreVersion(List jreVersion, String versionPattern) { } static List parseVersion(String version) { - version = version.replaceAll("[^0-9]", "."); - - String[] tokens = StringUtils.split(version, "."); + version = version.replaceAll("\\D", "."); - List numbers = Arrays.stream(tokens).map(Integer::valueOf).collect(Collectors.toList()); + String[] tokens = version.split("\\s*\\.+\\s*"); - return numbers; + return Arrays.stream(tokens) + .filter(s -> !s.isEmpty()) + .map(Integer::valueOf) + .collect(Collectors.toList()); } static int compareVersions(List version1, List version2) { From 0d2d871b379193987abce7d5a1c18df912f49954 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 04:27:41 +0000 Subject: [PATCH 38/92] Bump org.assertj:assertj-core from 3.24.2 to 3.25.0 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.24.2 to 3.25.0. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.24.2...assertj-build-3.25.0) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c40407da..72f878af 100644 --- a/pom.xml +++ b/pom.xml @@ -266,7 +266,7 @@ under the License. org.assertj assertj-core - 3.24.2 + 3.25.0 test From 8dc8168c9c9628289f171e5e40ee213f557cbffe Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 1 Jan 2024 19:26:25 +0100 Subject: [PATCH 39/92] Switch to defaults for GHA maven verify --- .github/workflows/maven-verify.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 8a95815d..9811acb1 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -26,5 +26,4 @@ jobs: name: Verify uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3 with: - jdk-matrix: '[ "8", "11", "17", "19"]' verify-fail-fast: false From 2fc8632b228b8f7e95db709639fce885f028af6d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jan 2024 15:21:42 +0100 Subject: [PATCH 40/92] Upgrade org.codehaus.plexus:plexus-utils from 3.5.1 to 4.0.0 (#200) --- pom.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 72f878af..9006fc49 100644 --- a/pom.xml +++ b/pom.xml @@ -209,7 +209,10 @@ under the License. org.codehaus.plexus plexus-utils - 3.5.1 + + + org.codehaus.plexus + plexus-xml org.codehaus.plexus From 5ed9b039db8fe9493d2a7ec6b3e4dac40ab82ff5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 07:35:45 -0500 Subject: [PATCH 41/92] Bump org.assertj:assertj-core from 3.25.0 to 3.25.1 (#211) Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.25.0 to 3.25.1. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.25.0...assertj-build-3.25.1) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9006fc49..f3979dde 100644 --- a/pom.xml +++ b/pom.xml @@ -269,7 +269,7 @@ under the License. org.assertj assertj-core - 3.25.0 + 3.25.1 test From 37e86793d691d282c5c0b0652dc0192f6df96f98 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 07:36:46 -0500 Subject: [PATCH 42/92] Bump org.apache.groovy:groovy-bom from 4.0.12 to 4.0.17 (#205) Bumps [org.apache.groovy:groovy-bom](https://github.com/apache/groovy) from 4.0.12 to 4.0.17. - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f3979dde..e4c1db24 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ under the License. bsh 2.0b6 2023-06-11T17:18:10Z - 4.0.12 + 4.0.17 From 637304c513b1b2f1048e6a424bf311b0dec78146 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 07:37:38 -0500 Subject: [PATCH 43/92] Bump commons-codec:commons-codec from 1.15 to 1.16.0 (#198) Bumps [commons-codec:commons-codec](https://github.com/apache/commons-codec) from 1.15 to 1.16.0. - [Changelog](https://github.com/apache/commons-codec/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-codec/compare/rel/commons-codec-1.15...rel/commons-codec-1.16.0) --- updated-dependencies: - dependency-name: commons-codec:commons-codec dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e4c1db24..5ffb1f48 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ under the License. commons-codec commons-codec - 1.15 + 1.16.0 commons-collections From 9c9095ddfd1f71e31590d57855e8df18cd60127c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 03:43:07 +0100 Subject: [PATCH 44/92] Bump org.apache.groovy:groovy-bom from 4.0.17 to 4.0.18 (#213) Bumps [org.apache.groovy:groovy-bom](https://github.com/apache/groovy) from 4.0.17 to 4.0.18. - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5ffb1f48..3c21f33c 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ under the License. bsh 2.0b6 2023-06-11T17:18:10Z - 4.0.17 + 4.0.18 From 5cf008b38e2cc5bce1a7a87f87d03f6ac20b1750 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 04:22:43 +0000 Subject: [PATCH 45/92] Bump org.assertj:assertj-core from 3.25.1 to 3.25.3 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.25.1 to 3.25.3. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.25.1...assertj-build-3.25.3) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3c21f33c..a9b16f03 100644 --- a/pom.xml +++ b/pom.xml @@ -269,7 +269,7 @@ under the License. org.assertj assertj-core - 3.25.1 + 3.25.3 test From 6dc88b62b7776cc29a5998dcff9d8dfe39a40fa2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:09:09 +0000 Subject: [PATCH 46/92] Bump apache/maven-gh-actions-shared from 3 to 4 Bumps [apache/maven-gh-actions-shared](https://github.com/apache/maven-gh-actions-shared) from 3 to 4. - [Commits](https://github.com/apache/maven-gh-actions-shared/compare/v3...v4) --- updated-dependencies: - dependency-name: apache/maven-gh-actions-shared dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/maven-verify.yml | 2 +- .github/workflows/release-drafter.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 9811acb1..f213d075 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -24,6 +24,6 @@ on: jobs: build: name: Verify - uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3 + uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 with: verify-fail-fast: false diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index b44872cf..1049eaa3 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -22,4 +22,4 @@ on: - master jobs: update_release_draft: - uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v3 + uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v4 From 8ee6f26ff6a03663922deabbad4af685241d8498 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Feb 2024 04:28:33 +0000 Subject: [PATCH 47/92] Bump commons-codec:commons-codec from 1.16.0 to 1.16.1 Bumps [commons-codec:commons-codec](https://github.com/apache/commons-codec) from 1.16.0 to 1.16.1. - [Changelog](https://github.com/apache/commons-codec/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-codec/compare/rel/commons-codec-1.16.0...rel/commons-codec-1.16.1) --- updated-dependencies: - dependency-name: commons-codec:commons-codec dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a9b16f03..de711297 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ under the License. commons-codec commons-codec - 1.16.0 + 1.16.1 commons-collections From 09a47e040573a98274bb03ed1f40abe5b7319103 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 04:05:39 +0000 Subject: [PATCH 48/92] Bump org.apache.groovy:groovy-bom from 4.0.18 to 4.0.20 Bumps [org.apache.groovy:groovy-bom](https://github.com/apache/groovy) from 4.0.18 to 4.0.20. - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index de711297..23c52e59 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ under the License. bsh 2.0b6 2023-06-11T17:18:10Z - 4.0.18 + 4.0.20 From fcae667b070815fae176b06fb2393a940a3a9670 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Thu, 21 Mar 2024 21:57:20 +0100 Subject: [PATCH 49/92] - Removed negative logic (#212) - Removed unused code - Improved code. --- .../maven/plugins/invoker/SelectorUtils.java | 48 +++++-------------- 1 file changed, 11 insertions(+), 37 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java b/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java index 00b54005..ded4fad3 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java +++ b/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java @@ -73,17 +73,10 @@ static boolean isOsFamily(String osSpec) { } static boolean isOsFamily(List families, boolean defaultMatch) { - if (families != null && !families.isEmpty()) { - for (String family : families) { - if (Os.isFamily(family)) { - return true; - } - } - - return false; - } else { + if (families == null || families.isEmpty()) { return defaultMatch; } + return families.stream().anyMatch(Os::isFamily); } /** @@ -139,10 +132,6 @@ static String getMavenVersion(File mavenHome) throws IOException { return null; } - static boolean isMavenVersion(String mavenSpec) { - return isMavenVersion(mavenSpec, getMavenVersion()); - } - static boolean isMavenVersion(String mavenSpec, String actualVersion) { List includes = new ArrayList<>(); List excludes = new ArrayList<>(); @@ -157,15 +146,6 @@ static String getJreVersion() { return System.getProperty("java.version", ""); } - static String getJreVersion(File javaHome) { - // @todo detect actual version - return null; - } - - static boolean isJreVersion(String jreSpec) { - return isJreVersion(jreSpec, getJreVersion()); - } - static boolean isJreVersion(String jreSpec, String actualJreVersion) { List includes = new ArrayList<>(); List excludes = new ArrayList<>(); @@ -176,33 +156,27 @@ static boolean isJreVersion(String jreSpec, String actualJreVersion) { return isJreVersion(jreVersion, includes, true) && !isJreVersion(jreVersion, excludes, false); } - static boolean isJreVersion(List jreVersion, List versionPatterns, boolean defaultMatch) { - if (versionPatterns != null && !versionPatterns.isEmpty()) { - for (String versionPattern : versionPatterns) { - if (isJreVersion(jreVersion, versionPattern)) { - return true; - } - } - - return false; - } else { + static boolean isJreVersion(List jreVersions, List versionPatterns, boolean defaultMatch) { + if (versionPatterns == null || versionPatterns.isEmpty()) { return defaultMatch; } + + return versionPatterns.stream().anyMatch(versionPattern -> isJreVersion(jreVersions, versionPattern)); } - static boolean isJreVersion(List jreVersion, String versionPattern) { + static boolean isJreVersion(List jreVersions, String versionPattern) { List checkVersion = parseVersion(versionPattern); if (versionPattern.endsWith("+")) { // 1.5+ <=> [1.5,) - return compareVersions(jreVersion, checkVersion) >= 0; + return compareVersions(jreVersions, checkVersion) >= 0; } else if (versionPattern.endsWith("-")) { // 1.5- <=> (,1.5) - return compareVersions(jreVersion, checkVersion) < 0; + return compareVersions(jreVersions, checkVersion) < 0; } else { // 1.5 <=> [1.5,1.6) - return checkVersion.size() <= jreVersion.size() - && checkVersion.equals(jreVersion.subList(0, checkVersion.size())); + return checkVersion.size() <= jreVersions.size() + && checkVersion.equals(jreVersions.subList(0, checkVersion.size())); } } From 3cb6f325d220b72a75b664ddc9c14ba4a1097eff Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 27 Mar 2024 16:00:26 +1000 Subject: [PATCH 50/92] use github for all scm elements Signed-off-by: Olivier Lamy --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 23c52e59..18df98c1 100644 --- a/pom.xml +++ b/pom.xml @@ -40,8 +40,8 @@ under the License. - scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git - scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git + scm:git:https://github.com/apache/maven-invoker-plugin.git + scm:git:https://github.com/apache/maven-invoker-plugin.git HEAD https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} From 324d17eb353228933bcfaef024563e6306d0ebf3 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 27 Mar 2024 16:01:07 +1000 Subject: [PATCH 51/92] [maven-release-plugin] prepare release maven-invoker-plugin-3.6.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 18df98c1..c720c377 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.6.1-SNAPSHOT + 3.6.1 maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://github.com/apache/maven-invoker-plugin.git scm:git:https://github.com/apache/maven-invoker-plugin.git - HEAD + maven-invoker-plugin-3.6.1 https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -66,7 +66,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2023-06-11T17:18:10Z + 2024-03-27T06:01:00Z 4.0.20 From e4f918b64b43d72d96908e3044604ddce275c5c8 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 27 Mar 2024 16:01:10 +1000 Subject: [PATCH 52/92] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index c720c377..c04f7505 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.6.1 + 3.6.2-SNAPSHOT maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://github.com/apache/maven-invoker-plugin.git scm:git:https://github.com/apache/maven-invoker-plugin.git - maven-invoker-plugin-3.6.1 + HEAD https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -66,7 +66,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2024-03-27T06:01:00Z + 2024-03-27T06:01:10Z 4.0.20 From 8c2325ae2141d481eceb8217a815cc7dce3ec6c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 31 Mar 2024 20:32:58 +0200 Subject: [PATCH 53/92] [MINVOKER-357] Bump commons-io:commons-io from 2.13.0 to 2.16.0 (#220) --- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c04f7505..7ffadb20 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ under the License. commons-io commons-io - 2.13.0 + 2.16.0 org.apache.groovy From 1f42511275ed8b743ee19a4a71a6569c509690d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 28 Apr 2024 17:36:01 +0200 Subject: [PATCH 54/92] [MINVOKER-358] Bump org.apache.maven.plugins:maven-plugins from 41 to 42 (#224) Bumps [org.apache.maven.plugins:maven-plugins](https://github.com/apache/maven-parent) from 41 to 42. - [Release notes](https://github.com/apache/maven-parent/releases) - [Commits](https://github.com/apache/maven-parent/commits) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-plugins dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7ffadb20..07976cad 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 41 + 42 From 8d56134b065d756a5822bbc19f0d34ff18745572 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 28 Apr 2024 18:07:33 +0200 Subject: [PATCH 55/92] [MINVOKER-337] Exclude plexus-container-default and o.a.maven from runtime dependencies --- pom.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pom.xml b/pom.xml index 07976cad..c1b98dc1 100644 --- a/pom.xml +++ b/pom.xml @@ -145,6 +145,11 @@ under the License. ${mavenVersion} provided + + org.eclipse.aether + aether-util + 1.0.0.v20140518 + @@ -161,6 +166,10 @@ under the License. org.codehaus.plexus plexus-container-default + + org.apache.maven + * + @@ -169,6 +178,12 @@ under the License. org.apache.maven.doxia doxia-sink-api 1.12.0 + + + org.codehaus.plexus + plexus-container-default + + From 08c57a653d932f34fa985d87c70f532786faf8e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 00:20:36 +0200 Subject: [PATCH 56/92] [MINVOKER-359] Bump org.apache.groovy:groovy-bom from 4.0.20 to 4.0.21 (#223) Bumps [org.apache.groovy:groovy-bom](https://github.com/apache/groovy) from 4.0.20 to 4.0.21. - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c1b98dc1..3236e4ba 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ under the License. bsh 2.0b6 2024-03-27T06:01:10Z - 4.0.20 + 4.0.21 From 3c8651b027e2053f4334c924a5bf8d1f1608d207 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 08:06:59 +0200 Subject: [PATCH 57/92] [MINVOKER-360] Bump commons-io:commons-io from 2.16.0 to 2.16.1 (#222) Bumps commons-io:commons-io from 2.16.0 to 2.16.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3236e4ba..eeab2b31 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ under the License. commons-io commons-io - 2.16.0 + 2.16.1 org.apache.groovy From 7c329e180e6b4807cba08b9415d649c01ef9f260 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 10:57:53 +0200 Subject: [PATCH 58/92] [MINVOKER-361] Bump commons-codec:commons-codec from 1.16.1 to 1.17.0 (#227) Bumps [commons-codec:commons-codec](https://github.com/apache/commons-codec) from 1.16.1 to 1.17.0. - [Changelog](https://github.com/apache/commons-codec/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-codec/compare/rel/commons-codec-1.16.1...rel/commons-codec-1.17.0) --- updated-dependencies: - dependency-name: commons-codec:commons-codec dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eeab2b31..234ad90c 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ under the License. commons-codec commons-codec - 1.16.1 + 1.17.0 commons-collections From 17d8b69b1383c4d0ecdc577cb2238a13b12ecc89 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 29 Apr 2024 17:24:58 +0200 Subject: [PATCH 59/92] [MINVOKER-284] Switch to JUnit5, drop maven-compat --- pom.xml | 25 +--- src/it/exec-timeout-invoker-level/pom.xml | 11 ++ src/it/exec-timeout-mojo-level/pom.xml | 11 ++ .../plugins/invoker/AbstractInvokerMojo.java | 16 +-- .../maven/plugins/invoker/InvokerReport.java | 4 +- .../maven/plugins/invoker/InvokerSession.java | 4 +- .../maven/plugins/invoker/PomUtils.java | 4 +- .../maven/plugins/invoker/VerifyMojo.java | 4 +- ...ProjectStub.java => AbstractTestUtil.java} | 31 ++--- .../plugins/invoker/InterpolationTest.java | 86 +++++++------- .../plugins/invoker/InvokerMojoTest.java | 39 ++++--- .../invoker/InvokerPropertiesTest.java | 62 +++++----- .../plugins/invoker/InvokerSessionTest.java | 6 +- .../plugins/invoker/JobExecutorTest.java | 10 +- .../maven/plugins/invoker/SelectorTest.java | 26 ++--- .../plugins/invoker/SelectorUtilsTest.java | 109 ++++++++++-------- 16 files changed, 230 insertions(+), 218 deletions(-) rename src/test/java/org/apache/maven/plugins/invoker/{ExtendedMavenProjectStub.java => AbstractTestUtil.java} (59%) diff --git a/pom.xml b/pom.xml index 234ad90c..6b6ab537 100644 --- a/pom.xml +++ b/pom.xml @@ -252,33 +252,20 @@ under the License. - junit - junit - 4.13.2 + org.junit.jupiter + junit-jupiter-api test org.mockito mockito-core - 4.10.0 + 4.11.0 test - org.apache.maven.plugin-testing - maven-plugin-testing-harness - 3.3.0 - test - - - org.codehaus.plexus - plexus-container-default - - - - - org.apache.maven - maven-compat - ${mavenVersion} + org.mockito + mockito-junit-jupiter + 4.11.0 test diff --git a/src/it/exec-timeout-invoker-level/pom.xml b/src/it/exec-timeout-invoker-level/pom.xml index 441d9aac..352ba165 100644 --- a/src/it/exec-timeout-invoker-level/pom.xml +++ b/src/it/exec-timeout-invoker-level/pom.xml @@ -36,6 +36,17 @@ under the License. + + + + org.apache.maven.plugins + maven-plugin-plugin + + test + + + + org.apache.maven.plugins diff --git a/src/it/exec-timeout-mojo-level/pom.xml b/src/it/exec-timeout-mojo-level/pom.xml index e9a1f5e5..1ff964ec 100644 --- a/src/it/exec-timeout-mojo-level/pom.xml +++ b/src/it/exec-timeout-mojo-level/pom.xml @@ -36,6 +36,17 @@ under the License. + + + + org.apache.maven.plugins + maven-plugin-plugin + + test + + + + org.apache.maven.plugins diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 14ddb735..3f13a13a 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -28,6 +28,7 @@ import java.io.OutputStreamWriter; import java.io.Reader; import java.io.Writer; +import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -91,13 +92,13 @@ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.InterpolationFilterReader; -import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.ReflectionUtils; -import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; import org.codehaus.plexus.util.cli.StreamConsumer; +import org.codehaus.plexus.util.xml.XmlStreamReader; +import org.codehaus.plexus.util.xml.XmlStreamWriter; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomWriter; @@ -751,8 +752,8 @@ public void execute() throws MojoExecutionException, MojoFailureException { } if (encoding == null || encoding.isEmpty()) { - getLog().warn("File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING - + ", i.e. build is platform dependent!"); + getLog().warn("File encoding has not been set, using platform encoding " + + Charset.defaultCharset().displayName() + ", i.e. build is platform dependent!"); } // done it here to prevent issues with concurrent access in case of parallel run @@ -1522,7 +1523,7 @@ private void runBuild( File interpolatedPomFile = interpolatePomFile(pomFile, basedir); // FIXME: Think about the following code part -- ^^^^^^^ END - getLog().info(buffer().a("Building: ").strong(buildJob.getProject()).toString()); + getLog().info(buffer().a("Building: ").strong(buildJob.getProject()).build()); InvokerProperties invokerProperties = getInvokerProperties(basedir, globalInvokerProperties); @@ -2274,13 +2275,12 @@ void buildInterpolatedFile(File originalFile, File interpolatedFile) throws Mojo // interpolation with token @...@ try (Reader reader = - new InterpolationFilterReader(ReaderFactory.newXmlReader(originalFile), composite, "@", "@")) { + new InterpolationFilterReader(new XmlStreamReader(originalFile), composite, "@", "@")) { xml = IOUtil.toString(reader); } - try (Writer writer = WriterFactory.newXmlWriter(interpolatedFile)) { + try (Writer writer = new XmlStreamWriter(interpolatedFile)) { interpolatedFile.getParentFile().mkdirs(); - writer.write(xml); } } catch (IOException e) { diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java index 339705a4..b3adabfb 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java @@ -32,7 +32,6 @@ import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.MavenReportException; import org.codehaus.plexus.i18n.I18N; -import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.XmlStreamReader; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; @@ -64,7 +63,7 @@ protected void executeReport(Locale locale) throws MavenReportException { BuildJobXpp3Reader buildJobReader = new BuildJobXpp3Reader(); List buildJobs = new ArrayList<>(reportFiles.length); for (File reportFile : reportFiles) { - try (XmlStreamReader xmlReader = ReaderFactory.newXmlReader(reportFile)) { + try (XmlStreamReader xmlReader = new XmlStreamReader(reportFile)) { buildJobs.add(buildJobReader.read(xmlReader)); } catch (XmlPullParserException e) { throw new MavenReportException("Failed to parse report file: " + reportFile, e); @@ -103,6 +102,7 @@ private File[] getReportFiles() { return ReportUtils.getReportFiles(reportsDirectory); } + @Override public boolean canGenerateReport() { return getReportFiles().length > 0; } diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerSession.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerSession.java index 9f47c1eb..a6667449 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerSession.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerSession.java @@ -27,7 +27,7 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.invoker.model.BuildJob; -import org.apache.maven.shared.utils.io.IOUtil; +import org.codehaus.plexus.util.IOUtil; import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; @@ -38,7 +38,7 @@ */ class InvokerSession { private static final String SEPARATOR = - buffer().strong("-------------------------------------------------").toString(); + buffer().strong("-------------------------------------------------").build(); private List buildJobs; diff --git a/src/main/java/org/apache/maven/plugins/invoker/PomUtils.java b/src/main/java/org/apache/maven/plugins/invoker/PomUtils.java index 17965c96..526ed7dd 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/PomUtils.java +++ b/src/main/java/org/apache/maven/plugins/invoker/PomUtils.java @@ -25,7 +25,7 @@ import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.MojoExecutionException; -import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.XmlStreamReader; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** @@ -43,7 +43,7 @@ class PomUtils { * @throws MojoExecutionException If the POM file could not be loaded. */ public static Model loadPom(File pomFile) throws MojoExecutionException { - try (Reader reader = ReaderFactory.newXmlReader(pomFile)) { + try (Reader reader = new XmlStreamReader(pomFile)) { return new MavenXpp3Reader().read(reader, false); } catch (XmlPullParserException e) { throw new MojoExecutionException("Failed to parse POM: " + pomFile, e); diff --git a/src/main/java/org/apache/maven/plugins/invoker/VerifyMojo.java b/src/main/java/org/apache/maven/plugins/invoker/VerifyMojo.java index 9bd6d823..b3a21cb0 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/VerifyMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/VerifyMojo.java @@ -29,7 +29,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Reader; -import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.XmlStreamReader; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** @@ -117,7 +117,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { InvokerSession invokerSession = new InvokerSession(); for (File reportFile : reportFiles) { - try (Reader xmlReader = ReaderFactory.newXmlReader(reportFile)) { + try (Reader xmlReader = new XmlStreamReader(reportFile)) { invokerSession.addJob(reader.read(xmlReader)); } catch (XmlPullParserException e) { throw new MojoExecutionException("Failed to parse report file: " + reportFile, e); diff --git a/src/test/java/org/apache/maven/plugins/invoker/ExtendedMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/invoker/AbstractTestUtil.java similarity index 59% rename from src/test/java/org/apache/maven/plugins/invoker/ExtendedMavenProjectStub.java rename to src/test/java/org/apache/maven/plugins/invoker/AbstractTestUtil.java index b8e5f9d7..2a2f791e 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/ExtendedMavenProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/invoker/AbstractTestUtil.java @@ -18,33 +18,18 @@ */ package org.apache.maven.plugins.invoker; -import java.util.Properties; +import java.io.File; -import org.apache.maven.model.Scm; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +import org.codehaus.plexus.util.ReflectionUtils; -/** - * @author Olivier Lamy - * @since 22 nov. 07 - */ -public class ExtendedMavenProjectStub extends MavenProjectStub { - private Scm scm; - - private Properties properties; - - public Scm getScm() { - return scm; - } - - public void setScm(Scm scm) { - this.scm = scm; - } +abstract class AbstractTestUtil { - public Properties getProperties() { - return properties; + protected String getBasedir() { + String path = System.getProperty("basedir"); + return path != null ? path : new File("").getAbsolutePath(); } - public void setProperties(Properties properties) { - this.properties = properties; + protected void setVariableValueToObject(Object object, String filed, Object value) throws IllegalAccessException { + ReflectionUtils.setVariableValueInObject(object, filed, value); } } diff --git a/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java b/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java index 637845d2..83850119 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java @@ -20,80 +20,80 @@ import java.io.File; import java.io.Reader; +import java.util.HashMap; import java.util.Map; import java.util.Properties; import org.apache.maven.model.Scm; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Settings; import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.XmlStreamReader; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; /** * @author Olivier Lamy * @since 22 nov. 07 */ -public class InterpolationTest extends AbstractMojoTestCase { +class InterpolationTest extends AbstractTestUtil { - protected MavenProjectStub buildMavenProjectStub() { - ExtendedMavenProjectStub project = new ExtendedMavenProjectStub(); + private MavenProject buildMavenProjectStub() { + MavenProject project = new MavenProject(); project.setVersion("1.0-SNAPSHOT"); project.setArtifactId("foo"); project.setGroupId("bar"); + project.setFile(new File(getBasedir(), "pom.xml")); Properties properties = new Properties(); properties.put("fooOnProject", "barOnProject"); - project.setProperties(properties); + project.getModel().setProperties(properties); Scm scm = new Scm(); scm.setConnection("http://blabla"); project.setScm(scm); return project; } - public void testCompositeMap() { + @Test + void testCompositeMap() { - Properties properties = new Properties(); + Map properties = new HashMap<>(); properties.put("foo", "bar"); properties.put("version", "2.0-SNAPSHOT"); - CompositeMap compositeMap = new CompositeMap(buildMavenProjectStub(), (Map) properties, false); - assertEquals("1.0-SNAPSHOT", compositeMap.get("pom.version")); - assertEquals("bar", compositeMap.get("foo")); - assertEquals("bar", compositeMap.get("pom.groupId")); - assertEquals("http://blabla", compositeMap.get("pom.scm.connection")); - assertEquals("barOnProject", compositeMap.get("fooOnProject")); + CompositeMap compositeMap = new CompositeMap(buildMavenProjectStub(), properties, false); + assertThat(compositeMap).containsEntry("pom.version", "1.0-SNAPSHOT"); + assertThat(compositeMap).containsEntry("foo", "bar"); + assertThat(compositeMap).containsEntry("pom.groupId", "bar"); + assertThat(compositeMap).containsEntry("pom.scm.connection", "http://blabla"); + assertThat(compositeMap).containsEntry("fooOnProject", "barOnProject"); } - public void testPomInterpolation() throws Exception { - Reader reader = null; + @Test + void testPomInterpolation() throws Exception { File interpolatedPomFile; - try { - InvokerMojo invokerMojo = new InvokerMojo(); - setVariableValueToObject(invokerMojo, "project", buildMavenProjectStub()); - setVariableValueToObject(invokerMojo, "settings", new Settings()); - Properties properties = new Properties(); - properties.put("foo", "bar"); - properties.put("version", "2.0-SNAPSHOT"); - setVariableValueToObject(invokerMojo, "filterProperties", properties); - String dirPath = - getBasedir() + File.separatorChar + "src" + File.separatorChar + "test" + File.separatorChar - + "resources" + File.separatorChar + "unit" + File.separatorChar + "interpolation"; + InvokerMojo invokerMojo = new InvokerMojo(); + setVariableValueToObject(invokerMojo, "project", buildMavenProjectStub()); + setVariableValueToObject(invokerMojo, "settings", new Settings()); + Properties properties = new Properties(); + properties.put("foo", "bar"); + properties.put("version", "2.0-SNAPSHOT"); + setVariableValueToObject(invokerMojo, "filterProperties", properties); + String dirPath = getBasedir() + File.separatorChar + "src" + File.separatorChar + "test" + File.separatorChar + + "resources" + File.separatorChar + "unit" + File.separatorChar + "interpolation"; - interpolatedPomFile = new File(getBasedir(), "target/interpolated-pom.xml"); - invokerMojo.buildInterpolatedFile(new File(dirPath, "pom.xml"), interpolatedPomFile); - reader = ReaderFactory.newXmlReader(interpolatedPomFile); + interpolatedPomFile = new File(getBasedir(), "target/interpolated-pom.xml"); + invokerMojo.buildInterpolatedFile(new File(dirPath, "pom.xml"), interpolatedPomFile); + try (Reader reader = new XmlStreamReader(interpolatedPomFile)) { + String content = IOUtil.toString(reader); + assertThat(content.indexOf("bar")) + .isPositive(); + } + // recreate it to test delete if exists before creation + invokerMojo.buildInterpolatedFile(new File(dirPath, "pom.xml"), interpolatedPomFile); + try (Reader reader = new XmlStreamReader(interpolatedPomFile)) { String content = IOUtil.toString(reader); - assertTrue(content.indexOf("bar") > 0); - reader.close(); - reader = null; - // recreate it to test delete if exists before creation - invokerMojo.buildInterpolatedFile(new File(dirPath, "pom.xml"), interpolatedPomFile); - reader = ReaderFactory.newXmlReader(interpolatedPomFile); - content = IOUtil.toString(reader); - assertTrue(content.indexOf("bar") > 0); - reader.close(); - reader = null; - } finally { - IOUtil.close(reader); + assertThat(content.indexOf("bar")) + .isPositive(); } } } diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java index 49abbeba..d57a5876 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java @@ -22,10 +22,10 @@ import java.util.Collections; import java.util.List; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugins.invoker.model.BuildJob; import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Settings; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -33,7 +33,7 @@ * @author Olivier Lamy * @since 18 nov. 07 */ -public class InvokerMojoTest extends AbstractMojoTestCase { +class InvokerMojoTest extends AbstractTestUtil { private static final String DUMMY_PROJECT = "dummy" + File.separator + "pom.xml"; private static final String WITH_POM_DIR_PROJECT = "with-pom-project-dir" + File.separator + "pom.xml"; @@ -46,7 +46,8 @@ private MavenProject getMavenProject() { return mavenProject; } - public void testSingleInvokerTest() throws Exception { + @Test + void testSingleInvokerTest() throws Exception { // given InvokerMojo invokerMojo = new InvokerMojo(); String dirPath = getBasedir() + "/src/test/resources/unit"; @@ -63,7 +64,8 @@ public void testSingleInvokerTest() throws Exception { assertThat(jobs).map(BuildJob::getProject).containsExactlyInAnyOrder(DUMMY_PROJECT); } - public void testMultiInvokerTest() throws Exception { + @Test + void testMultiInvokerTest() throws Exception { // given InvokerMojo invokerMojo = new InvokerMojo(); String dirPath = getBasedir() + "/src/test/resources/unit"; @@ -80,7 +82,8 @@ public void testMultiInvokerTest() throws Exception { assertThat(jobs).map(BuildJob::getProject).containsExactlyInAnyOrder(DUMMY_PROJECT, INTERPOLATION_PROJECT); } - public void testFullPatternInvokerTest() throws Exception { + @Test + void testFullPatternInvokerTest() throws Exception { // given InvokerMojo invokerMojo = new InvokerMojo(); String dirPath = getBasedir() + "/src/test/resources/unit"; @@ -100,7 +103,8 @@ public void testFullPatternInvokerTest() throws Exception { DUMMY_PROJECT, WITH_POM_DIR_PROJECT, WITHOUT_POM_PROJECT, INTERPOLATION_PROJECT); } - public void testSetupInProjectList() throws Exception { + @Test + void testSetupInProjectList() throws Exception { // given InvokerMojo invokerMojo = new InvokerMojo(); String dirPath = getBasedir() + "/src/test/resources/unit"; @@ -127,7 +131,8 @@ public void testSetupInProjectList() throws Exception { .containsExactlyInAnyOrder(DUMMY_PROJECT); } - public void testSetupProjectIsFiltered() throws Exception { + @Test + void testSetupProjectIsFiltered() throws Exception { // given InvokerMojo invokerMojo = new InvokerMojo(); String dirPath = getBasedir() + "/src/test/resources/unit"; @@ -152,14 +157,20 @@ public void testSetupProjectIsFiltered() throws Exception { .isEmpty(); } - public void testAlreadyCloned() { - assertFalse(AbstractInvokerMojo.alreadyCloned("dir", Collections.emptyList())); - assertTrue(AbstractInvokerMojo.alreadyCloned("dir", Collections.singletonList("dir"))); - assertTrue(AbstractInvokerMojo.alreadyCloned("dir" + File.separator + "sub", Collections.singletonList("dir"))); - assertFalse(AbstractInvokerMojo.alreadyCloned("dirs", Collections.singletonList("dir"))); + @Test + void testAlreadyCloned() { + assertThat(AbstractInvokerMojo.alreadyCloned("dir", Collections.emptyList())) + .isFalse(); + assertThat(AbstractInvokerMojo.alreadyCloned("dir", Collections.singletonList("dir"))) + .isTrue(); + assertThat(AbstractInvokerMojo.alreadyCloned("dir" + File.separator + "sub", Collections.singletonList("dir"))) + .isTrue(); + assertThat(AbstractInvokerMojo.alreadyCloned("dirs", Collections.singletonList("dir"))) + .isFalse(); } - public void testParallelThreadsSettings() throws IllegalAccessException { + @Test + void testParallelThreadsSettings() throws Exception { Object[][] testValues = { {"4", 4}, {"1C", Runtime.getRuntime().availableProcessors()}, @@ -174,7 +185,7 @@ public void testParallelThreadsSettings() throws IllegalAccessException { setVariableValueToObject(invokerMojo, "parallelThreads", parallelThreads); - assertEquals(expectedParallelThreads, invokerMojo.getParallelThreadsCount()); + assertThat(expectedParallelThreads).isEqualTo(invokerMojo.getParallelThreadsCount()); } } } diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java index 8db6c396..26a706ec 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java @@ -27,10 +27,10 @@ import org.apache.maven.shared.invoker.InvocationRequest; import org.apache.maven.shared.invoker.InvocationRequest.ReactorFailureBehavior; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; @@ -48,20 +48,20 @@ * * @author Benjamin Bentmann */ -@RunWith(MockitoJUnitRunner.class) -public class InvokerPropertiesTest { +@ExtendWith(MockitoExtension.class) +class InvokerPropertiesTest { @Mock private InvocationRequest request; @Test - public void testConstructorNullSafe() { + void testConstructorNullSafe() { InvokerProperties facade = new InvokerProperties(null); assertThat(facade.getProperties()).isNotNull(); } @Test - public void testGetInvokerProperty() { + void testGetInvokerProperty() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -76,7 +76,7 @@ public void testGetInvokerProperty() { } @Test - public void testGetJobName() { + void testGetJobName() { Properties props = new Properties(); final String jobName = "Build Job name"; props.put("invoker.name", jobName); @@ -86,7 +86,7 @@ public void testGetJobName() { } @Test - public void testIsExpectedResult() { + void testIsExpectedResult() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -103,7 +103,7 @@ public void testIsExpectedResult() { } @Test - public void testConfigureRequestEmptyProperties() { + void testConfigureRequestEmptyProperties() { InvokerProperties facade = new InvokerProperties(null); @@ -112,7 +112,7 @@ public void testConfigureRequestEmptyProperties() { } @Test - public void testConfigureRequestGoals() { + void testConfigureRequestGoals() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -149,7 +149,7 @@ public void testConfigureRequestGoals() { } @Test - public void testConfigureRequestProfiles() { + void testConfigureRequestProfiles() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -185,7 +185,7 @@ public void testConfigureRequestProfiles() { } @Test - public void testConfigureRequestProject() throws Exception { + void testConfigureRequestProject() throws Exception { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -211,7 +211,7 @@ public void testConfigureRequestProject() throws Exception { } @Test - public void testConfigureRequestMavenExecutable() { + void testConfigureRequestMavenExecutable() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -232,7 +232,7 @@ public void testConfigureRequestMavenExecutable() { } @Test - public void testConfigureRequestMavenOpts() { + void testConfigureRequestMavenOpts() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -252,7 +252,7 @@ public void testConfigureRequestMavenOpts() { } @Test - public void testConfigureRequestFailureBehavior() { + void testConfigureRequestFailureBehavior() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -264,7 +264,7 @@ public void testConfigureRequestFailureBehavior() { } @Test - public void testConfigureRequestFailureBehaviorUnKnownName() { + void testConfigureRequestFailureBehaviorUnKnownName() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -278,7 +278,7 @@ public void testConfigureRequestFailureBehaviorUnKnownName() { } @Test - public void testConfigureRequestRecursion() { + void testConfigureRequestRecursion() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -295,7 +295,7 @@ public void testConfigureRequestRecursion() { } @Test - public void testConfigureRequestOffline() { + void testConfigureRequestOffline() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -312,7 +312,7 @@ public void testConfigureRequestOffline() { } @Test - public void testConfigureRequestDebug() { + void testConfigureRequestDebug() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -343,7 +343,7 @@ public void testConfigureRequestDebug() { } @Test - public void testConfigureRequestQuiet() { + void testConfigureRequestQuiet() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -374,7 +374,7 @@ public void testConfigureRequestQuiet() { } @Test - public void testConfigureRequestTimeoutInSeconds() { + void testConfigureRequestTimeoutInSeconds() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -393,7 +393,7 @@ public void testConfigureRequestTimeoutInSeconds() { } @Test - public void testConfigureEnvironmentVariables() { + void testConfigureEnvironmentVariables() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -411,7 +411,7 @@ public void testConfigureEnvironmentVariables() { } @Test - public void testConfigureEnvironmentVariablesWithIndex() { + void testConfigureEnvironmentVariablesWithIndex() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -429,7 +429,7 @@ public void testConfigureEnvironmentVariablesWithIndex() { } @Test - public void testConfigureUpdateSnapshots() { + void testConfigureUpdateSnapshots() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -447,7 +447,7 @@ public void testConfigureUpdateSnapshots() { } @Test - public void testConfigureUpdateSnapshotsDefault() { + void testConfigureUpdateSnapshotsDefault() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -464,7 +464,7 @@ public void testConfigureUpdateSnapshotsDefault() { } @Test - public void testIsInvocationDefined() { + void testIsInvocationDefined() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -486,7 +486,7 @@ public void testIsInvocationDefined() { } @Test - public void testIsSelectedDefined() { + void testIsSelectedDefined() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -508,7 +508,7 @@ public void testIsSelectedDefined() { } @Test - public void testGetToolchainsForEmptyProperties() { + void testGetToolchainsForEmptyProperties() { Properties props = new Properties(); InvokerProperties facade = new InvokerProperties(props); @@ -521,7 +521,7 @@ public void testGetToolchainsForEmptyProperties() { } @Test - public void testGetToolchains() { + void testGetToolchains() { Properties props = new Properties(); props.put("invoker.toolchain.jdk.version", "11"); InvokerProperties facade = new InvokerProperties(props); @@ -534,7 +534,7 @@ public void testGetToolchains() { } @Test - public void testGetToolchainsWithIndex() { + void testGetToolchainsWithIndex() { Properties props = new Properties(); props.put("selector.1.invoker.toolchain.jdk.version", "11"); InvokerProperties facade = new InvokerProperties(props); diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerSessionTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerSessionTest.java index 6226e394..9220735b 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/InvokerSessionTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerSessionTest.java @@ -22,7 +22,7 @@ import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.invoker.model.BuildJob; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.mock; @@ -32,10 +32,10 @@ /** * Unittest for {@link InvokerSession} */ -public class InvokerSessionTest { +class InvokerSessionTest { @Test - public void skipSummary() { + void skipSummary() { Log logger = mock(Log.class); BuildJob skippedBuildJob = new BuildJob("minvoker-279"); skippedBuildJob.setResult(BuildJob.Result.SKIPPED); diff --git a/src/test/java/org/apache/maven/plugins/invoker/JobExecutorTest.java b/src/test/java/org/apache/maven/plugins/invoker/JobExecutorTest.java index de374329..9f564086 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/JobExecutorTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/JobExecutorTest.java @@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.maven.plugins.invoker.model.BuildJob; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -36,17 +36,17 @@ * * @author Slawomir Jaranowski */ -public class JobExecutorTest { +class JobExecutorTest { @Test - public void emptyJobList() { + void emptyJobList() { JobExecutor jobExecutor = new JobExecutor(Collections.emptyList(), 1); jobExecutor.forEach(job -> fail("fail")); } @Test - public void failedJob() { + void failedJob() { BuildJob job = aJob("job1", 100); JobExecutor jobExecutor = new JobExecutor(Collections.singletonList(job), 1); @@ -58,7 +58,7 @@ public void failedJob() { } @Test - public void jobsShouldBeGroupedAndExecutedInProperOrder() { + void jobsShouldBeGroupedAndExecutedInProperOrder() { Map jobsCounter = new HashMap<>(); jobsCounter.put(100, new AtomicInteger(3)); jobsCounter.put(10, new AtomicInteger(2)); diff --git a/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java b/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java index f4a8f974..d55875c9 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java @@ -20,39 +20,39 @@ import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; /** * Test for {@link Selector}. */ -public class SelectorTest { +class SelectorTest { @Test - public void testGlobalMatch() { + void testGlobalMatch() { Selector selector = new Selector("3.2.5", "1.7", null); Properties props = new Properties(); props.setProperty("invoker.maven.version", "3.0+"); InvokerProperties invokerProperties = new InvokerProperties(props); - assertEquals(0, selector.getSelection(invokerProperties)); + assertThat(selector.getSelection(invokerProperties)).isZero(); } @Test - public void testSelectorMatch() { + void testSelectorMatch() { Selector selector = new Selector("3.2.5", "1.7", null); Properties props = new Properties(); props.setProperty("selector.1.maven.version", "3.0+"); InvokerProperties invokerProperties = new InvokerProperties(props); - assertEquals(0, selector.getSelection(invokerProperties)); + assertThat(selector.getSelection(invokerProperties)).isZero(); props.setProperty("selector.1.maven.version", "3.3.1+"); - assertEquals(Selector.SELECTOR_MULTI, selector.getSelection(invokerProperties)); + assertThat(selector.getSelection(invokerProperties)).isEqualTo(Selector.SELECTOR_MULTI); } @Test - public void testSelectorWithGlobalMatch() { + void testSelectorWithGlobalMatch() { Selector selector = new Selector("3.2.5", "1.7", null); Properties props = new Properties(); @@ -61,16 +61,16 @@ public void testSelectorWithGlobalMatch() { props.setProperty("selector.1.java.version", "1.4+"); props.setProperty("selector.2.os.family", "myos"); InvokerProperties invokerProperties = new InvokerProperties(props); - assertEquals(0, selector.getSelection(invokerProperties)); + assertThat(selector.getSelection(invokerProperties)).isZero(); props.setProperty("invoker.maven.version", "3.3.1+"); - assertEquals(Selector.SELECTOR_MULTI, selector.getSelection(invokerProperties)); + assertThat(selector.getSelection(invokerProperties)).isEqualTo(Selector.SELECTOR_MULTI); props.setProperty("invoker.maven.version", "3.0+"); props.setProperty("selector.1.maven.version", "3.3.1+"); - assertEquals(Selector.SELECTOR_MULTI, selector.getSelection(invokerProperties)); + assertThat(selector.getSelection(invokerProperties)).isEqualTo(Selector.SELECTOR_MULTI); props.setProperty("selector.2.os.family", "!myos"); - assertEquals(0, selector.getSelection(invokerProperties)); + assertThat(selector.getSelection(invokerProperties)).isZero(); } } diff --git a/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java b/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java index 77f26bee..8f72bfac 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java @@ -24,18 +24,14 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Map; import org.apache.maven.plugins.invoker.AbstractInvokerMojo.ToolchainPrivateManager; import org.apache.maven.toolchain.ToolchainPrivate; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.isA; +import static org.mockito.ArgumentMatchers.anyMap; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -44,63 +40,69 @@ * * @author Benjamin Bentmann */ -public class SelectorUtilsTest { +class SelectorUtilsTest { @Test - public void testParseList() { + void testParseList() { List includes = new ArrayList<>(); List excludes = new ArrayList<>(); SelectorUtils.parseList(null, includes, excludes); SelectorUtils.parseList(" 1.5, !1.4, 1.6+ ", includes, excludes); - assertEquals(Arrays.asList("1.5", "1.6+"), includes); - assertEquals(Collections.singletonList("1.4"), excludes); + assertThat(includes).containsExactly("1.5", "1.6+"); + assertThat(excludes).containsExactly("1.4"); } @Test - public void testParseVersion() { - assertEquals(Arrays.asList(1, 6, 0, 12), SelectorUtils.parseVersion("1.6.0_12")); - - assertEquals(Arrays.asList(1, 6, 0, 12), SelectorUtils.parseVersion("1.6.0_12+")); - assertEquals(Arrays.asList(1, 6, 0, 12), SelectorUtils.parseVersion("1.6.0_12-")); + void testParseVersion() { + assertThat(SelectorUtils.parseVersion("1.6.0_12")).containsExactly(1, 6, 0, 12); + assertThat(SelectorUtils.parseVersion("1.6.0_12+")).containsExactly(1, 6, 0, 12); + assertThat(SelectorUtils.parseVersion("1.6.0_12-")).containsExactly(1, 6, 0, 12); } @Test - public void testCompareVersions() { - assertTrue(SelectorUtils.compareVersions(Arrays.asList(1, 6), Arrays.asList(1, 6)) == 0); - - assertTrue(SelectorUtils.compareVersions(Arrays.asList(1, 5), Arrays.asList(1, 6)) < 0); - assertTrue(SelectorUtils.compareVersions(Arrays.asList(1, 6), Arrays.asList(1, 5)) > 0); - - assertTrue(SelectorUtils.compareVersions(Collections.singletonList(1), Arrays.asList(1, 6)) < 0); - assertTrue(SelectorUtils.compareVersions(Arrays.asList(1, 6), Collections.singletonList(1)) > 0); + void testCompareVersions() { + assertThat(SelectorUtils.compareVersions(Arrays.asList(1, 6), Arrays.asList(1, 6))) + .isZero(); + + assertThat(SelectorUtils.compareVersions(Arrays.asList(1, 5), Arrays.asList(1, 6))) + .isNegative(); + assertThat(SelectorUtils.compareVersions(Arrays.asList(1, 6), Arrays.asList(1, 5))) + .isPositive(); + + assertThat(SelectorUtils.compareVersions(Collections.singletonList(1), Arrays.asList(1, 6))) + .isNegative(); + assertThat(SelectorUtils.compareVersions(Arrays.asList(1, 6), Collections.singletonList(1))) + .isPositive(); } @Test - public void testIsMatchingJre() { - - assertFalse(SelectorUtils.isJreVersion(Arrays.asList(1, 4, 2, 8), "1.5")); - assertTrue(SelectorUtils.isJreVersion(Arrays.asList(1, 5), "1.5")); - assertTrue(SelectorUtils.isJreVersion(Arrays.asList(1, 5, 9), "1.5")); - assertFalse(SelectorUtils.isJreVersion(Arrays.asList(1, 6), "1.5")); - - assertFalse(SelectorUtils.isJreVersion(Arrays.asList(1, 4, 2, 8), "1.5+")); - assertTrue(SelectorUtils.isJreVersion(Arrays.asList(1, 5), "1.5+")); - assertTrue(SelectorUtils.isJreVersion(Arrays.asList(1, 5, 9), "1.5+")); - assertTrue(SelectorUtils.isJreVersion(Arrays.asList(1, 6), "1.5+")); - - assertTrue(SelectorUtils.isJreVersion(Arrays.asList(1, 4, 2, 8), "1.5-")); - assertFalse(SelectorUtils.isJreVersion(Arrays.asList(1, 5), "1.5-")); - assertFalse(SelectorUtils.isJreVersion(Arrays.asList(1, 5, 9), "1.5-")); - assertFalse(SelectorUtils.isJreVersion(Arrays.asList(1, 6), "1.5-")); - - assertTrue(SelectorUtils.isJreVersion((String) null, "1.5")); - assertTrue(SelectorUtils.isJreVersion("", "1.5")); + void testIsMatchingJre() { + + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 4, 2, 8), "1.5")).isFalse(); + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 5), "1.5")).isTrue(); + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 5, 9), "1.5")).isTrue(); + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 6), "1.5")).isFalse(); + + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 4, 2, 8), "1.5+")) + .isFalse(); + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 5), "1.5+")).isTrue(); + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 5, 9), "1.5+")).isTrue(); + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 6), "1.5+")).isTrue(); + + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 4, 2, 8), "1.5-")) + .isTrue(); + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 5), "1.5-")).isFalse(); + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 5, 9), "1.5-")).isFalse(); + assertThat(SelectorUtils.isJreVersion(Arrays.asList(1, 6), "1.5-")).isFalse(); + + assertThat(SelectorUtils.isJreVersion((String) null, "1.5")).isTrue(); + assertThat(SelectorUtils.isJreVersion("", "1.5")).isTrue(); } @Test - public void testIsMatchingToolchain() throws Exception { + void testIsMatchingToolchain() throws Exception { InvokerToolchain openJdk9 = new InvokerToolchain("jdk"); openJdk9.addProvides("version", "9"); openJdk9.addProvides("vendor", "openJDK"); @@ -110,32 +112,37 @@ public void testIsMatchingToolchain() throws Exception { ToolchainPrivateManager toolchainPrivateManager = mock(ToolchainPrivateManager.class); ToolchainPrivate jdkMatching = mock(ToolchainPrivate.class); - when(jdkMatching.matchesRequirements(isA(Map.class))).thenReturn(true); + when(jdkMatching.matchesRequirements(anyMap())).thenReturn(true); when(jdkMatching.getType()).thenReturn("jdk"); ToolchainPrivate jdkMismatch = mock(ToolchainPrivate.class); when(jdkMismatch.getType()).thenReturn("jdk"); when(toolchainPrivateManager.getToolchainPrivates("jdk")).thenReturn(new ToolchainPrivate[] {jdkMatching}); - assertTrue(SelectorUtils.isToolchain(toolchainPrivateManager, Collections.singleton(openJdk9))); + assertThat(SelectorUtils.isToolchain(toolchainPrivateManager, Collections.singleton(openJdk9))) + .isTrue(); when(toolchainPrivateManager.getToolchainPrivates("jdk")).thenReturn(new ToolchainPrivate[] {jdkMismatch}); - assertFalse(SelectorUtils.isToolchain(toolchainPrivateManager, Collections.singleton(openJdk9))); + assertThat(SelectorUtils.isToolchain(toolchainPrivateManager, Collections.singleton(openJdk9))) + .isFalse(); when(toolchainPrivateManager.getToolchainPrivates("jdk")) .thenReturn(new ToolchainPrivate[] {jdkMatching, jdkMismatch, jdkMatching}); - assertTrue(SelectorUtils.isToolchain(toolchainPrivateManager, Collections.singleton(openJdk9))); + assertThat(SelectorUtils.isToolchain(toolchainPrivateManager, Collections.singleton(openJdk9))) + .isTrue(); when(toolchainPrivateManager.getToolchainPrivates("jdk")).thenReturn(new ToolchainPrivate[0]); - assertFalse(SelectorUtils.isToolchain(toolchainPrivateManager, Collections.singleton(openJdk9))); + assertThat(SelectorUtils.isToolchain(toolchainPrivateManager, Collections.singleton(openJdk9))) + .isFalse(); when(toolchainPrivateManager.getToolchainPrivates("jdk")).thenReturn(new ToolchainPrivate[] {jdkMatching}); when(toolchainPrivateManager.getToolchainPrivates("maven")).thenReturn(new ToolchainPrivate[0]); - assertFalse(SelectorUtils.isToolchain(toolchainPrivateManager, Arrays.asList(openJdk9, maven360))); + assertThat(SelectorUtils.isToolchain(toolchainPrivateManager, Arrays.asList(openJdk9, maven360))) + .isFalse(); } @Test - public void mavenVersionForNotExistingMavenHomeThrowException() { + void mavenVersionForNotExistingMavenHomeThrowException() { File mavenHome = new File("not-existing-path"); assertThatCode(() -> SelectorUtils.getMavenVersion(mavenHome)) @@ -144,7 +151,7 @@ public void mavenVersionForNotExistingMavenHomeThrowException() { } @Test - public void mavenVersionFromMavenHome() throws IOException { + void mavenVersionFromMavenHome() throws IOException { File mavenHome = new File(System.getProperty("maven.home")); String mavenVersion = SelectorUtils.getMavenVersion(mavenHome); From ee34dc2119f5116e9b169205055c57c4cf58e03e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 04:12:56 +0000 Subject: [PATCH 60/92] Bump org.apache.maven.shared:maven-script-interpreter from 1.4 to 1.5 Bumps [org.apache.maven.shared:maven-script-interpreter](https://github.com/apache/maven-script-interpreter) from 1.4 to 1.5. - [Release notes](https://github.com/apache/maven-script-interpreter/releases) - [Commits](https://github.com/apache/maven-script-interpreter/compare/maven-script-interpreter-1.4...maven-script-interpreter-1.5) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-script-interpreter dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6b6ab537..5f25aec7 100644 --- a/pom.xml +++ b/pom.xml @@ -195,7 +195,7 @@ under the License. org.apache.maven.shared maven-script-interpreter - 1.4 + 1.5 From f121de51df7c9473293ac6cd130f72fe00587ace Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 30 Apr 2024 14:21:01 +0200 Subject: [PATCH 61/92] [MINVOKER-362] Use properties from parent for plugins versions in ITs by the way - replace pom.version with project.version --- pom.xml | 15 --------------- src/it/MINVOKER-191/plugin/pom.xml | 11 +++++++++++ src/it/MINVOKER-191/pom.xml | 6 +++--- src/it/MINVOKER-196_junit_report_file/pom.xml | 4 ++-- .../src/it/project_2/pom.xml | 2 +- src/it/MINVOKER-288-failed-setup-run/pom.xml | 2 +- src/it/MINVOKER-288-failed-setup-verify/pom.xml | 2 +- src/it/MINVOKER-289/pom.xml | 2 +- src/it/clone-clean/pom.xml | 2 +- src/it/clone-maven-plugin-packaging/pom.xml | 2 +- src/it/fail-build-streamLogsOnFailures/pom.xml | 2 +- src/it/fail-build-with-verify/pom.xml | 2 +- src/it/fail-build/pom.xml | 2 +- src/it/fail-ignore-with-verify/pom.xml | 2 +- src/it/fail-ignore/pom.xml | 2 +- src/it/fail-noprojects_integration-test/pom.xml | 2 +- src/it/fail-noprojects_run/pom.xml | 2 +- src/it/fail-noprojects_verify/pom.xml | 2 +- src/it/fail-postbuild/pom.xml | 2 +- src/it/fail-prebuild/pom.xml | 2 +- src/it/fail-run-postbuild/pom.xml | 2 +- src/it/install-extra-artifacts/pom.xml | 2 +- src/it/integration-test-never-fails/pom.xml | 2 +- src/it/invocation-cmdline-exclude/pom.xml | 2 +- .../src/it/minvoker-140-executable/pom.xml | 2 +- .../src/it/minvoker-140-ignorable/pom.xml | 2 +- src/it/invocation-debug/pom.xml | 4 ++-- .../invocation-debug/src/it/minvoker-142/pom.xml | 2 +- src/it/invocation-emptyproperty/pom.xml | 2 +- .../src/it/minvoker-118/pom.xml | 2 +- src/it/invocation-environmentvariable/pom.xml | 4 ++-- .../src/it/minvoker-145/pom.xml | 2 +- .../src/it/minvoker-255/pom.xml | 2 +- .../src/it/minvoker-273/pom.xml | 2 +- .../src/it/projects/group-1/sub-1/pom.xml | 2 +- .../src/it/projects/group-1/sub-2/pom.xml | 2 +- .../src/it/projects/group-2/sub-1/pom.xml | 2 +- .../src/it/projects/group-2/sub-2/pom.xml | 2 +- src/it/invocation-multiple/pom.xml | 14 +++++++------- src/it/invocation-multiple/src/it/project/pom.xml | 12 ++++++------ src/it/invocation-reactor-indirect/plugin/pom.xml | 14 ++++++++++++++ src/it/invocation-reactor-indirect/pom.xml | 6 +++--- src/it/invocation-spaces/pom.xml | 12 ++++++------ .../src/it projects/project/spacy pom.xml | 10 +++++----- src/it/invoker-report/pom.xml | 2 +- src/it/local-repo-default/pom.xml | 2 +- src/it/local-repo-isolated/pom.xml | 2 +- src/it/local-repo-path/pom.xml | 4 ++-- src/it/local-repo-url/pom.xml | 4 ++-- src/it/not-clone-not-plugin/pom.xml | 2 +- src/it/pom-filtering-encoding/pom.xml | 4 ++-- .../pom-filtering-encoding/src/it/latin-1/pom.xml | 2 +- .../pom-filtering-encoding/src/it/utf-8/pom.xml | 2 +- src/it/pom-filtering-reactor/pom.xml | 2 +- src/it/pom-filtering/pom.xml | 2 +- src/it/pom-filtering/src/it/project/pom.xml | 2 +- src/it/pom-less-invocation/pom.xml | 2 +- src/it/postbuild-executed-only-once/pom.xml | 4 ++-- .../src/it/project/pom.xml | 4 ++-- src/it/project-cloning-reactor/pom.xml | 2 +- src/it/project-cloning/pom.xml | 2 +- src/it/project-setup/pom.xml | 2 +- src/it/script-accessibility/pom.xml | 2 +- src/it/script-additional-vars/pom.xml | 2 +- src/it/script-class-loading/pom.xml | 2 +- src/it/script-classpath-duplicates/pom.xml | 2 +- src/it/script-global-vars/pom.xml | 2 +- src/it/script-interpreter-detection/pom.xml | 2 +- src/it/selector-conditions/pom.xml | 2 +- src/it/selector-scripts/pom.xml | 2 +- src/it/settings-auto-exclude/pom.xml | 2 +- src/it/settings-inherit/pom.xml | 2 +- src/it/settings-inherit/src/it/project/pom.xml | 2 +- src/it/settings-merge/pom.xml | 2 +- src/it/settings-merge/src/it/project/pom.xml | 2 +- src/it/settings-merge_jdk9+/pom.xml | 4 ++-- .../settings-merge_jdk9+/src/it/project/pom.xml | 4 ++-- src/it/settings-override/pom.xml | 2 +- src/it/settings-override/src/it/project/pom.xml | 2 +- src/it/spaces-should-work_non-windows/pom.xml | 2 +- .../src/it/minvoker-test/pom.xml | 2 +- src/it/spaces-should-work_windows/pom.xml | 2 +- .../src/it/minvoker-test/pom.xml | 2 +- src/it/special-characters-should-work/pom.xml | 2 +- .../src/it/minvoker-test/pom.xml | 2 +- src/it/staging-dependencies-test-scope/pom.xml | 2 +- src/it/staging-dependencies/pom.xml | 2 +- src/it/staging-pom/pom.xml | 4 ++-- src/it/staging-reactor/mod1-parent/pom.xml | 2 +- src/it/staging-reactor/mod2/pom.xml | 2 +- src/it/staging-reactor/mod3/pom.xml | 2 +- src/it/staging-reactor/pom.xml | 2 +- src/it/updateOnly/pom.xml | 2 +- 93 files changed, 150 insertions(+), 140 deletions(-) diff --git a/pom.xml b/pom.xml index 5f25aec7..bba9d2f5 100644 --- a/pom.xml +++ b/pom.xml @@ -375,21 +375,6 @@ under the License. run-its - - - 3.1.0 - 3.2.0 - 3.11.0 - 3.2.1 - 3.4.0 - 3.1.1 - 3.3.0 - 3.8.1 - 3.3.1 - 3.12.1 - 3.2.1 - 3.0.0 - diff --git a/src/it/MINVOKER-191/plugin/pom.xml b/src/it/MINVOKER-191/plugin/pom.xml index cf5b9fce..cae0b2b8 100644 --- a/src/it/MINVOKER-191/plugin/pom.xml +++ b/src/it/MINVOKER-191/plugin/pom.xml @@ -39,6 +39,17 @@ under the License. + + + + org.apache.maven.plugins + maven-plugin-plugin + + test + + + + org.apache.maven.plugins diff --git a/src/it/MINVOKER-191/pom.xml b/src/it/MINVOKER-191/pom.xml index ee01722d..1e2d8866 100644 --- a/src/it/MINVOKER-191/pom.xml +++ b/src/it/MINVOKER-191/pom.xml @@ -49,17 +49,17 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - @compilerPluginVersion@ + @version.maven-compiler-plugin@ org.apache.maven.plugins maven-plugin-plugin - @pluginPluginVersion@ + @version.maven-plugin-tools@ org.apache.maven.plugins maven-resources-plugin - @resourcesPluginVersion@ + @version.maven-resources-plugin@ org.apache.maven.plugins diff --git a/src/it/MINVOKER-196_junit_report_file/pom.xml b/src/it/MINVOKER-196_junit_report_file/pom.xml index cb5ee642..b6d11cc0 100644 --- a/src/it/MINVOKER-196_junit_report_file/pom.xml +++ b/src/it/MINVOKER-196_junit_report_file/pom.xml @@ -41,12 +41,12 @@ under the License. org.apache.maven.plugins maven-resources-plugin - @resourcesPluginVersion@ + @version.maven-resources-plugin@ org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true true diff --git a/src/it/MINVOKER-196_junit_report_file/src/it/project_2/pom.xml b/src/it/MINVOKER-196_junit_report_file/src/it/project_2/pom.xml index 56343427..1268201d 100644 --- a/src/it/MINVOKER-196_junit_report_file/src/it/project_2/pom.xml +++ b/src/it/MINVOKER-196_junit_report_file/src/it/project_2/pom.xml @@ -64,7 +64,7 @@ under the License. maven-resources-plugin - @resourcesPluginVersion@ + @version.maven-resources-plugin@ diff --git a/src/it/MINVOKER-288-failed-setup-run/pom.xml b/src/it/MINVOKER-288-failed-setup-run/pom.xml index af7aec20..66934092 100644 --- a/src/it/MINVOKER-288-failed-setup-run/pom.xml +++ b/src/it/MINVOKER-288-failed-setup-run/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it true diff --git a/src/it/MINVOKER-288-failed-setup-verify/pom.xml b/src/it/MINVOKER-288-failed-setup-verify/pom.xml index b1822dd1..a2cdb0dc 100644 --- a/src/it/MINVOKER-288-failed-setup-verify/pom.xml +++ b/src/it/MINVOKER-288-failed-setup-verify/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it true diff --git a/src/it/MINVOKER-289/pom.xml b/src/it/MINVOKER-289/pom.xml index 09da8e89..fa4868e9 100644 --- a/src/it/MINVOKER-289/pom.xml +++ b/src/it/MINVOKER-289/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true true diff --git a/src/it/clone-clean/pom.xml b/src/it/clone-clean/pom.xml index c2859244..ab2d2691 100644 --- a/src/it/clone-clean/pom.xml +++ b/src/it/clone-clean/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it true diff --git a/src/it/clone-maven-plugin-packaging/pom.xml b/src/it/clone-maven-plugin-packaging/pom.xml index d3f9f85f..d1b8ff4c 100644 --- a/src/it/clone-maven-plugin-packaging/pom.xml +++ b/src/it/clone-maven-plugin-packaging/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it true diff --git a/src/it/fail-build-streamLogsOnFailures/pom.xml b/src/it/fail-build-streamLogsOnFailures/pom.xml index 49ec32d7..3ef70b8c 100644 --- a/src/it/fail-build-streamLogsOnFailures/pom.xml +++ b/src/it/fail-build-streamLogsOnFailures/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true false diff --git a/src/it/fail-build-with-verify/pom.xml b/src/it/fail-build-with-verify/pom.xml index 00ad8631..dd67c096 100644 --- a/src/it/fail-build-with-verify/pom.xml +++ b/src/it/fail-build-with-verify/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/fail-build/pom.xml b/src/it/fail-build/pom.xml index 10ec51d5..f2de0411 100644 --- a/src/it/fail-build/pom.xml +++ b/src/it/fail-build/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true true diff --git a/src/it/fail-ignore-with-verify/pom.xml b/src/it/fail-ignore-with-verify/pom.xml index c0e4c8d8..80921378 100644 --- a/src/it/fail-ignore-with-verify/pom.xml +++ b/src/it/fail-ignore-with-verify/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/fail-ignore/pom.xml b/src/it/fail-ignore/pom.xml index c34ec5da..d8aa3636 100644 --- a/src/it/fail-ignore/pom.xml +++ b/src/it/fail-ignore/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/fail-noprojects_integration-test/pom.xml b/src/it/fail-noprojects_integration-test/pom.xml index 494f0869..e3ad38e1 100644 --- a/src/it/fail-noprojects_integration-test/pom.xml +++ b/src/it/fail-noprojects_integration-test/pom.xml @@ -37,7 +37,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/fail-noprojects_run/pom.xml b/src/it/fail-noprojects_run/pom.xml index 4af1ff54..c14cb50d 100644 --- a/src/it/fail-noprojects_run/pom.xml +++ b/src/it/fail-noprojects_run/pom.xml @@ -37,7 +37,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/fail-noprojects_verify/pom.xml b/src/it/fail-noprojects_verify/pom.xml index 312f4dfe..16b45835 100644 --- a/src/it/fail-noprojects_verify/pom.xml +++ b/src/it/fail-noprojects_verify/pom.xml @@ -37,7 +37,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/fail-postbuild/pom.xml b/src/it/fail-postbuild/pom.xml index 4f6722fc..2f8651ff 100644 --- a/src/it/fail-postbuild/pom.xml +++ b/src/it/fail-postbuild/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/fail-prebuild/pom.xml b/src/it/fail-prebuild/pom.xml index 29e464b0..b5d50262 100644 --- a/src/it/fail-prebuild/pom.xml +++ b/src/it/fail-prebuild/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/fail-run-postbuild/pom.xml b/src/it/fail-run-postbuild/pom.xml index 474fa363..cf806dff 100644 --- a/src/it/fail-run-postbuild/pom.xml +++ b/src/it/fail-run-postbuild/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/install-extra-artifacts/pom.xml b/src/it/install-extra-artifacts/pom.xml index 55da1fa9..6329a7aa 100644 --- a/src/it/install-extra-artifacts/pom.xml +++ b/src/it/install-extra-artifacts/pom.xml @@ -40,7 +40,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it-repo diff --git a/src/it/integration-test-never-fails/pom.xml b/src/it/integration-test-never-fails/pom.xml index 3d0a2a79..4d84b282 100644 --- a/src/it/integration-test-never-fails/pom.xml +++ b/src/it/integration-test-never-fails/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/invocation-cmdline-exclude/pom.xml b/src/it/invocation-cmdline-exclude/pom.xml index 1041bdca..9db8d1d9 100644 --- a/src/it/invocation-cmdline-exclude/pom.xml +++ b/src/it/invocation-cmdline-exclude/pom.xml @@ -31,7 +31,7 @@ under the License. UTF-8 - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/invocation-cmdline-exclude/src/it/minvoker-140-executable/pom.xml b/src/it/invocation-cmdline-exclude/src/it/minvoker-140-executable/pom.xml index 071fd003..2236da0d 100644 --- a/src/it/invocation-cmdline-exclude/src/it/minvoker-140-executable/pom.xml +++ b/src/it/invocation-cmdline-exclude/src/it/minvoker-140-executable/pom.xml @@ -35,7 +35,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/invocation-cmdline-exclude/src/it/minvoker-140-ignorable/pom.xml b/src/it/invocation-cmdline-exclude/src/it/minvoker-140-ignorable/pom.xml index 72fb0bcb..3209bafa 100644 --- a/src/it/invocation-cmdline-exclude/src/it/minvoker-140-ignorable/pom.xml +++ b/src/it/invocation-cmdline-exclude/src/it/minvoker-140-ignorable/pom.xml @@ -35,7 +35,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/invocation-debug/pom.xml b/src/it/invocation-debug/pom.xml index f3b3704e..9f39fc03 100644 --- a/src/it/invocation-debug/pom.xml +++ b/src/it/invocation-debug/pom.xml @@ -33,7 +33,7 @@ under the License. UTF-8 - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ @@ -41,7 +41,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ validate diff --git a/src/it/invocation-debug/src/it/minvoker-142/pom.xml b/src/it/invocation-debug/src/it/minvoker-142/pom.xml index 2716f598..20b989a4 100644 --- a/src/it/invocation-debug/src/it/minvoker-142/pom.xml +++ b/src/it/invocation-debug/src/it/minvoker-142/pom.xml @@ -35,7 +35,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/invocation-emptyproperty/pom.xml b/src/it/invocation-emptyproperty/pom.xml index f22733f1..73a19d7a 100644 --- a/src/it/invocation-emptyproperty/pom.xml +++ b/src/it/invocation-emptyproperty/pom.xml @@ -31,7 +31,7 @@ under the License. UTF-8 - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml b/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml index f125d617..881f48ee 100644 --- a/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml +++ b/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml @@ -35,7 +35,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/invocation-environmentvariable/pom.xml b/src/it/invocation-environmentvariable/pom.xml index 94f697d4..5ae26913 100644 --- a/src/it/invocation-environmentvariable/pom.xml +++ b/src/it/invocation-environmentvariable/pom.xml @@ -32,8 +32,8 @@ under the License. UTF-8 - @enforcerPluginVersion@ - @helpPluginVersion@ + @version.maven-enforcer-plugin@ + @version.maven-help-plugin@ diff --git a/src/it/invocation-environmentvariable/src/it/minvoker-145/pom.xml b/src/it/invocation-environmentvariable/src/it/minvoker-145/pom.xml index dbf55779..bee9cf8c 100644 --- a/src/it/invocation-environmentvariable/src/it/minvoker-145/pom.xml +++ b/src/it/invocation-environmentvariable/src/it/minvoker-145/pom.xml @@ -37,7 +37,7 @@ org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/invocation-environmentvariable/src/it/minvoker-255/pom.xml b/src/it/invocation-environmentvariable/src/it/minvoker-255/pom.xml index f89d646e..c04a02cb 100644 --- a/src/it/invocation-environmentvariable/src/it/minvoker-255/pom.xml +++ b/src/it/invocation-environmentvariable/src/it/minvoker-255/pom.xml @@ -36,7 +36,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/invocation-environmentvariable/src/it/minvoker-273/pom.xml b/src/it/invocation-environmentvariable/src/it/minvoker-273/pom.xml index d6f15f34..300c1bd8 100644 --- a/src/it/invocation-environmentvariable/src/it/minvoker-273/pom.xml +++ b/src/it/invocation-environmentvariable/src/it/minvoker-273/pom.xml @@ -36,7 +36,7 @@ under the License. org.apache.maven.plugins maven-help-plugin - @helpPluginVersion@ + @version.maven-help-plugin@ validate diff --git a/src/it/invocation-group-properties/src/it/projects/group-1/sub-1/pom.xml b/src/it/invocation-group-properties/src/it/projects/group-1/sub-1/pom.xml index cd693884..7089190c 100644 --- a/src/it/invocation-group-properties/src/it/projects/group-1/sub-1/pom.xml +++ b/src/it/invocation-group-properties/src/it/projects/group-1/sub-1/pom.xml @@ -31,7 +31,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ enforce diff --git a/src/it/invocation-group-properties/src/it/projects/group-1/sub-2/pom.xml b/src/it/invocation-group-properties/src/it/projects/group-1/sub-2/pom.xml index c428365b..9df94cb4 100644 --- a/src/it/invocation-group-properties/src/it/projects/group-1/sub-2/pom.xml +++ b/src/it/invocation-group-properties/src/it/projects/group-1/sub-2/pom.xml @@ -31,7 +31,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ enforce diff --git a/src/it/invocation-group-properties/src/it/projects/group-2/sub-1/pom.xml b/src/it/invocation-group-properties/src/it/projects/group-2/sub-1/pom.xml index cd693884..7089190c 100644 --- a/src/it/invocation-group-properties/src/it/projects/group-2/sub-1/pom.xml +++ b/src/it/invocation-group-properties/src/it/projects/group-2/sub-1/pom.xml @@ -31,7 +31,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ enforce diff --git a/src/it/invocation-group-properties/src/it/projects/group-2/sub-2/pom.xml b/src/it/invocation-group-properties/src/it/projects/group-2/sub-2/pom.xml index 555a9251..757cd413 100644 --- a/src/it/invocation-group-properties/src/it/projects/group-2/sub-2/pom.xml +++ b/src/it/invocation-group-properties/src/it/projects/group-2/sub-2/pom.xml @@ -31,7 +31,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ enforce diff --git a/src/it/invocation-multiple/pom.xml b/src/it/invocation-multiple/pom.xml index 7a01a729..2fbc5352 100644 --- a/src/it/invocation-multiple/pom.xml +++ b/src/it/invocation-multiple/pom.xml @@ -32,12 +32,12 @@ under the License. UTF-8 @mavenVersion@ - @compilerPluginVersion@ - @installPluginVersion@ - @jarPluginVersion@ - @pluginPluginVersion@ - @resourcesPluginVersion@ - @surefirePluginVersion@ + @version.maven-compiler-plugin@ + @version.maven-install-plugin@ + @version.maven-jar-plugin@ + @version.maven-plugin-tools@ + @version.maven-resources-plugin@ + @version.maven-surefire@ @@ -45,7 +45,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/invocation-multiple/src/it/project/pom.xml b/src/it/invocation-multiple/src/it/project/pom.xml index 3c43664c..4746a6eb 100644 --- a/src/it/invocation-multiple/src/it/project/pom.xml +++ b/src/it/invocation-multiple/src/it/project/pom.xml @@ -47,7 +47,7 @@ under the License. maven-compiler-plugin - @compilerPluginVersion@ + @version.maven-compiler-plugin@ ${maven.compiler.source} ${maven.compiler.target} @@ -55,23 +55,23 @@ under the License. maven-install-plugin - @installPluginVersion@ + @version.maven-install-plugin@ maven-jar-plugin - @jarPluginVersion@ + @version.maven-jar-plugin@ maven-plugin-plugin - @pluginPluginVersion@ + @version.maven-plugin-tools@ maven-resources-plugin - @resourcesPluginVersion@ + @version.maven-resources-plugin@ maven-surefire-plugin - @surefirePluginVersion@ + @version.maven-surefire@ diff --git a/src/it/invocation-reactor-indirect/plugin/pom.xml b/src/it/invocation-reactor-indirect/plugin/pom.xml index f443bffe..76c4d843 100644 --- a/src/it/invocation-reactor-indirect/plugin/pom.xml +++ b/src/it/invocation-reactor-indirect/plugin/pom.xml @@ -37,4 +37,18 @@ under the License. 2.0 + + + + + + org.apache.maven.plugins + maven-plugin-plugin + + test + + + + + diff --git a/src/it/invocation-reactor-indirect/pom.xml b/src/it/invocation-reactor-indirect/pom.xml index e99c651f..c6e7a59a 100644 --- a/src/it/invocation-reactor-indirect/pom.xml +++ b/src/it/invocation-reactor-indirect/pom.xml @@ -48,17 +48,17 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - @compilerPluginVersion@ + @version.maven-compiler-plugin@ org.apache.maven.plugins maven-plugin-plugin - @pluginPluginVersion@ + @version.maven-plugin-tools@ org.apache.maven.plugins maven-resources-plugin - @resourcesPluginVersion@ + @version.maven-resources-plugin@ org.apache.maven.plugins diff --git a/src/it/invocation-spaces/pom.xml b/src/it/invocation-spaces/pom.xml index cbe1b124..7a594b93 100644 --- a/src/it/invocation-spaces/pom.xml +++ b/src/it/invocation-spaces/pom.xml @@ -31,11 +31,11 @@ under the License. UTF-8 - @compilerPluginVersion@ - @installPluginVersion@ - @jarPluginVersion@ - @resourcesPluginVersion@ - @surefirePluginVersion@ + @version.maven-compiler-plugin@ + @version.maven-install-plugin@ + @version.maven-jar-plugin@ + @version.maven-resources-plugin@ + @version.maven-surefire@ @@ -43,7 +43,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true src/it projects diff --git a/src/it/invocation-spaces/src/it projects/project/spacy pom.xml b/src/it/invocation-spaces/src/it projects/project/spacy pom.xml index 34638172..98454b0b 100644 --- a/src/it/invocation-spaces/src/it projects/project/spacy pom.xml +++ b/src/it/invocation-spaces/src/it projects/project/spacy pom.xml @@ -41,21 +41,21 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - @compilerPluginVersion@ + @version.maven-compiler-plugin@ org.apache.maven.plugins maven-install-plugin - @installPluginVersion@ + @version.maven-install-plugin@ maven-jar-plugin - @jarPluginVersion@ + @version.maven-jar-plugin@ org.apache.maven.plugins maven-resources-plugin - @resourcesPluginVersion@ + @version.maven-resources-plugin@ ${project.build.sourceEncoding} @@ -63,7 +63,7 @@ under the License. org.apache.maven.plugins maven-surefire-plugin - @surefirePluginVersion@ + @version.maven-surefire@ diff --git a/src/it/invoker-report/pom.xml b/src/it/invoker-report/pom.xml index dbc99085..a8864503 100644 --- a/src/it/invoker-report/pom.xml +++ b/src/it/invoker-report/pom.xml @@ -63,7 +63,7 @@ under the License. org.apache.maven.plugins maven-site-plugin - @sitePluginVersion@ + @version.maven-site-plugin@ diff --git a/src/it/local-repo-default/pom.xml b/src/it/local-repo-default/pom.xml index b601efb2..16b8edfa 100644 --- a/src/it/local-repo-default/pom.xml +++ b/src/it/local-repo-default/pom.xml @@ -41,7 +41,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/its diff --git a/src/it/local-repo-isolated/pom.xml b/src/it/local-repo-isolated/pom.xml index a2e2f8e7..f7cac4ff 100644 --- a/src/it/local-repo-isolated/pom.xml +++ b/src/it/local-repo-isolated/pom.xml @@ -40,7 +40,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it-repo diff --git a/src/it/local-repo-path/pom.xml b/src/it/local-repo-path/pom.xml index 7edfa613..0977b50e 100644 --- a/src/it/local-repo-path/pom.xml +++ b/src/it/local-repo-path/pom.xml @@ -41,7 +41,7 @@ under the License. org.apache.maven.plugins maven-clean-plugin - @cleanPluginVersion@ + @version.maven-clean-plugin@ org.apache.maven.plugins @@ -56,7 +56,7 @@ under the License. -c - org.apache.maven.plugins:maven-clean-plugin:@cleanPluginVersion@:clean + org.apache.maven.plugins:maven-clean-plugin:@version.maven-clean-plugin@:clean diff --git a/src/it/local-repo-url/pom.xml b/src/it/local-repo-url/pom.xml index cb3e8a8b..fb776dec 100644 --- a/src/it/local-repo-url/pom.xml +++ b/src/it/local-repo-url/pom.xml @@ -41,12 +41,12 @@ under the License. org.apache.maven.plugins maven-resources-plugin - @resourcesPluginVersion@ + @version.maven-resources-plugin@ org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it-repo src/it/settings.xml diff --git a/src/it/not-clone-not-plugin/pom.xml b/src/it/not-clone-not-plugin/pom.xml index 4cf525c6..1e293ce9 100644 --- a/src/it/not-clone-not-plugin/pom.xml +++ b/src/it/not-clone-not-plugin/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ diff --git a/src/it/pom-filtering-encoding/pom.xml b/src/it/pom-filtering-encoding/pom.xml index 431c256c..d07c1392 100644 --- a/src/it/pom-filtering-encoding/pom.xml +++ b/src/it/pom-filtering-encoding/pom.xml @@ -30,7 +30,7 @@ under the License. Test to check for proper handling of file encoding during POM filtering. - @resourcesPluginVersion@ + @version.maven-resources-plugin@ @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/pom-filtering-encoding/src/it/latin-1/pom.xml b/src/it/pom-filtering-encoding/src/it/latin-1/pom.xml index 65fae357..236d1bd3 100644 --- a/src/it/pom-filtering-encoding/src/it/latin-1/pom.xml +++ b/src/it/pom-filtering-encoding/src/it/latin-1/pom.xml @@ -47,7 +47,7 @@ under the License. maven-resources-plugin - @resourcesPluginVersion@ + @version.maven-resources-plugin@ diff --git a/src/it/pom-filtering-encoding/src/it/utf-8/pom.xml b/src/it/pom-filtering-encoding/src/it/utf-8/pom.xml index 8d3d0deb..069c1c23 100644 --- a/src/it/pom-filtering-encoding/src/it/utf-8/pom.xml +++ b/src/it/pom-filtering-encoding/src/it/utf-8/pom.xml @@ -47,7 +47,7 @@ under the License. maven-resources-plugin - @resourcesPluginVersion@ + @version.maven-resources-plugin@ diff --git a/src/it/pom-filtering-reactor/pom.xml b/src/it/pom-filtering-reactor/pom.xml index 79dac5f1..a64957bb 100644 --- a/src/it/pom-filtering-reactor/pom.xml +++ b/src/it/pom-filtering-reactor/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true ${project.build.directory}/it diff --git a/src/it/pom-filtering/pom.xml b/src/it/pom-filtering/pom.xml index 8fcb6dd7..047e5a51 100644 --- a/src/it/pom-filtering/pom.xml +++ b/src/it/pom-filtering/pom.xml @@ -34,7 +34,7 @@ under the License. UTF-8 PROPERTY-FROM-PROPERTIES-SECTION FAILED - @resourcesPluginVersion@ + @version.maven-resources-plugin@ diff --git a/src/it/pom-filtering/src/it/project/pom.xml b/src/it/pom-filtering/src/it/project/pom.xml index b273ae7c..cc98e82d 100644 --- a/src/it/pom-filtering/src/it/project/pom.xml +++ b/src/it/pom-filtering/src/it/project/pom.xml @@ -64,7 +64,7 @@ under the License. maven-resources-plugin - @resourcesPluginVersion@ + @version.maven-resources-plugin@ diff --git a/src/it/pom-less-invocation/pom.xml b/src/it/pom-less-invocation/pom.xml index a9458c49..4b5eda26 100644 --- a/src/it/pom-less-invocation/pom.xml +++ b/src/it/pom-less-invocation/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it diff --git a/src/it/postbuild-executed-only-once/pom.xml b/src/it/postbuild-executed-only-once/pom.xml index 9624cfb4..3a7cabb6 100644 --- a/src/it/postbuild-executed-only-once/pom.xml +++ b/src/it/postbuild-executed-only-once/pom.xml @@ -31,8 +31,8 @@ under the License. UTF-8 - @compilerPluginVersion@ - @surefirePluginVersion@ + @version.maven-compiler-plugin@ + @version.maven-surefire@ diff --git a/src/it/postbuild-executed-only-once/src/it/project/pom.xml b/src/it/postbuild-executed-only-once/src/it/project/pom.xml index 9cc053af..1f0fb33f 100644 --- a/src/it/postbuild-executed-only-once/src/it/project/pom.xml +++ b/src/it/postbuild-executed-only-once/src/it/project/pom.xml @@ -49,12 +49,12 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - @compilerPluginVersion@ + @version.maven-compiler-plugin@ org.apache.maven.plugins maven-surefire-plugin - @surefirePluginVersion@ + @version.maven-surefire@ ${create_touch_file} diff --git a/src/it/project-cloning-reactor/pom.xml b/src/it/project-cloning-reactor/pom.xml index 7da94c98..c186bc8c 100644 --- a/src/it/project-cloning-reactor/pom.xml +++ b/src/it/project-cloning-reactor/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it diff --git a/src/it/project-cloning/pom.xml b/src/it/project-cloning/pom.xml index 1b7e9081..c1be5b8c 100644 --- a/src/it/project-cloning/pom.xml +++ b/src/it/project-cloning/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it diff --git a/src/it/project-setup/pom.xml b/src/it/project-setup/pom.xml index 0922bba0..ae3a507b 100644 --- a/src/it/project-setup/pom.xml +++ b/src/it/project-setup/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it diff --git a/src/it/script-accessibility/pom.xml b/src/it/script-accessibility/pom.xml index 808cf00e..340e2912 100644 --- a/src/it/script-accessibility/pom.xml +++ b/src/it/script-accessibility/pom.xml @@ -40,7 +40,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ */pom.xml diff --git a/src/it/script-additional-vars/pom.xml b/src/it/script-additional-vars/pom.xml index fbafe4fe..ed4bd558 100644 --- a/src/it/script-additional-vars/pom.xml +++ b/src/it/script-additional-vars/pom.xml @@ -40,7 +40,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ */pom.xml diff --git a/src/it/script-class-loading/pom.xml b/src/it/script-class-loading/pom.xml index d3c3c11c..64d29df6 100644 --- a/src/it/script-class-loading/pom.xml +++ b/src/it/script-class-loading/pom.xml @@ -48,7 +48,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true diff --git a/src/it/script-classpath-duplicates/pom.xml b/src/it/script-classpath-duplicates/pom.xml index 20a19265..589db482 100644 --- a/src/it/script-classpath-duplicates/pom.xml +++ b/src/it/script-classpath-duplicates/pom.xml @@ -54,7 +54,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true true diff --git a/src/it/script-global-vars/pom.xml b/src/it/script-global-vars/pom.xml index 585b5b1b..ea98fdc6 100644 --- a/src/it/script-global-vars/pom.xml +++ b/src/it/script-global-vars/pom.xml @@ -40,7 +40,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ */pom.xml diff --git a/src/it/script-interpreter-detection/pom.xml b/src/it/script-interpreter-detection/pom.xml index b5d5ee1e..672b5255 100644 --- a/src/it/script-interpreter-detection/pom.xml +++ b/src/it/script-interpreter-detection/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/its true diff --git a/src/it/selector-conditions/pom.xml b/src/it/selector-conditions/pom.xml index c73a245b..c30863f5 100644 --- a/src/it/selector-conditions/pom.xml +++ b/src/it/selector-conditions/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ true diff --git a/src/it/selector-scripts/pom.xml b/src/it/selector-scripts/pom.xml index c3be520d..206f5ac3 100644 --- a/src/it/selector-scripts/pom.xml +++ b/src/it/selector-scripts/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/its true diff --git a/src/it/settings-auto-exclude/pom.xml b/src/it/settings-auto-exclude/pom.xml index c3491c68..240402d6 100644 --- a/src/it/settings-auto-exclude/pom.xml +++ b/src/it/settings-auto-exclude/pom.xml @@ -47,7 +47,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ diff --git a/src/it/settings-inherit/pom.xml b/src/it/settings-inherit/pom.xml index f979416a..7f60df1c 100644 --- a/src/it/settings-inherit/pom.xml +++ b/src/it/settings-inherit/pom.xml @@ -31,7 +31,7 @@ under the License. UTF-8 - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/settings-inherit/src/it/project/pom.xml b/src/it/settings-inherit/src/it/project/pom.xml index 42a3f4c2..5ad2dc66 100644 --- a/src/it/settings-inherit/src/it/project/pom.xml +++ b/src/it/settings-inherit/src/it/project/pom.xml @@ -35,7 +35,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ enforce-property diff --git a/src/it/settings-merge/pom.xml b/src/it/settings-merge/pom.xml index 26df7c72..acf4864f 100644 --- a/src/it/settings-merge/pom.xml +++ b/src/it/settings-merge/pom.xml @@ -32,7 +32,7 @@ under the License. UTF-8 - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/settings-merge/src/it/project/pom.xml b/src/it/settings-merge/src/it/project/pom.xml index 1058edb1..5262cf35 100644 --- a/src/it/settings-merge/src/it/project/pom.xml +++ b/src/it/settings-merge/src/it/project/pom.xml @@ -36,7 +36,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ verify-properties diff --git a/src/it/settings-merge_jdk9+/pom.xml b/src/it/settings-merge_jdk9+/pom.xml index 72ca04fd..b7bb9e0f 100644 --- a/src/it/settings-merge_jdk9+/pom.xml +++ b/src/it/settings-merge_jdk9+/pom.xml @@ -32,8 +32,8 @@ under the License. UTF-8 - @enforcerPluginVersion@ - @helpPluginVersion@ + @version.maven-enforcer-plugin@ + @version.maven-help-plugin@ diff --git a/src/it/settings-merge_jdk9+/src/it/project/pom.xml b/src/it/settings-merge_jdk9+/src/it/project/pom.xml index f2ab455f..9c67cce5 100644 --- a/src/it/settings-merge_jdk9+/src/it/project/pom.xml +++ b/src/it/settings-merge_jdk9+/src/it/project/pom.xml @@ -36,7 +36,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ verify-properties @@ -64,7 +64,7 @@ under the License. org.apache.maven.plugins maven-help-plugin - @helpPluginVersion@ + @version.maven-help-plugin@ effective-settings diff --git a/src/it/settings-override/pom.xml b/src/it/settings-override/pom.xml index e5818e64..60cc8008 100644 --- a/src/it/settings-override/pom.xml +++ b/src/it/settings-override/pom.xml @@ -32,7 +32,7 @@ under the License. UTF-8 - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/settings-override/src/it/project/pom.xml b/src/it/settings-override/src/it/project/pom.xml index 505aaea9..d84fbfe1 100644 --- a/src/it/settings-override/src/it/project/pom.xml +++ b/src/it/settings-override/src/it/project/pom.xml @@ -37,7 +37,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ verify-properties diff --git a/src/it/spaces-should-work_non-windows/pom.xml b/src/it/spaces-should-work_non-windows/pom.xml index af9fbf0d..d9858db4 100644 --- a/src/it/spaces-should-work_non-windows/pom.xml +++ b/src/it/spaces-should-work_non-windows/pom.xml @@ -34,7 +34,7 @@ under the License. UTF-8 - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/spaces-should-work_non-windows/src/it/minvoker-test/pom.xml b/src/it/spaces-should-work_non-windows/src/it/minvoker-test/pom.xml index 2716f598..20b989a4 100644 --- a/src/it/spaces-should-work_non-windows/src/it/minvoker-test/pom.xml +++ b/src/it/spaces-should-work_non-windows/src/it/minvoker-test/pom.xml @@ -35,7 +35,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/spaces-should-work_windows/pom.xml b/src/it/spaces-should-work_windows/pom.xml index af9fbf0d..d9858db4 100644 --- a/src/it/spaces-should-work_windows/pom.xml +++ b/src/it/spaces-should-work_windows/pom.xml @@ -34,7 +34,7 @@ under the License. UTF-8 - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/spaces-should-work_windows/src/it/minvoker-test/pom.xml b/src/it/spaces-should-work_windows/src/it/minvoker-test/pom.xml index 2716f598..20b989a4 100644 --- a/src/it/spaces-should-work_windows/src/it/minvoker-test/pom.xml +++ b/src/it/spaces-should-work_windows/src/it/minvoker-test/pom.xml @@ -35,7 +35,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/special-characters-should-work/pom.xml b/src/it/special-characters-should-work/pom.xml index 6f612081..218c7c71 100644 --- a/src/it/special-characters-should-work/pom.xml +++ b/src/it/special-characters-should-work/pom.xml @@ -33,7 +33,7 @@ under the License. UTF-8 - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/special-characters-should-work/src/it/minvoker-test/pom.xml b/src/it/special-characters-should-work/src/it/minvoker-test/pom.xml index 2716f598..20b989a4 100644 --- a/src/it/special-characters-should-work/src/it/minvoker-test/pom.xml +++ b/src/it/special-characters-should-work/src/it/minvoker-test/pom.xml @@ -35,7 +35,7 @@ under the License. org.apache.maven.plugins maven-enforcer-plugin - @enforcerPluginVersion@ + @version.maven-enforcer-plugin@ diff --git a/src/it/staging-dependencies-test-scope/pom.xml b/src/it/staging-dependencies-test-scope/pom.xml index b130f77a..8118f99d 100644 --- a/src/it/staging-dependencies-test-scope/pom.xml +++ b/src/it/staging-dependencies-test-scope/pom.xml @@ -52,7 +52,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it-repo test diff --git a/src/it/staging-dependencies/pom.xml b/src/it/staging-dependencies/pom.xml index 72e92ce0..9f2c462b 100644 --- a/src/it/staging-dependencies/pom.xml +++ b/src/it/staging-dependencies/pom.xml @@ -94,7 +94,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it-repo diff --git a/src/it/staging-pom/pom.xml b/src/it/staging-pom/pom.xml index e9582c67..db20423b 100644 --- a/src/it/staging-pom/pom.xml +++ b/src/it/staging-pom/pom.xml @@ -47,7 +47,7 @@ under the License. org.apache.maven.plugins maven-invoker-plugin - @pom.version@ + @project.version@ ${project.build.directory}/it-repo @@ -63,7 +63,7 @@ under the License. org.apache.maven.plugins maven-site-plugin - @sitePluginVersion@ + @version.maven-site-plugin@ diff --git a/src/it/staging-reactor/mod1-parent/pom.xml b/src/it/staging-reactor/mod1-parent/pom.xml index 7bfcffa5..d961392d 100644 --- a/src/it/staging-reactor/mod1-parent/pom.xml +++ b/src/it/staging-reactor/mod1-parent/pom.xml @@ -40,7 +40,7 @@ under the License. org.apache.maven.plugins maven-site-plugin - @sitePluginVersion@ + @version.maven-site-plugin@ diff --git a/src/it/staging-reactor/mod2/pom.xml b/src/it/staging-reactor/mod2/pom.xml index 38208b66..e6f4e676 100644 --- a/src/it/staging-reactor/mod2/pom.xml +++ b/src/it/staging-reactor/mod2/pom.xml @@ -44,7 +44,7 @@ under the License. maven-source-plugin - @sourcePluginVersion@ + @version.maven-source-plugin@ attach-resources diff --git a/src/it/staging-reactor/mod3/pom.xml b/src/it/staging-reactor/mod3/pom.xml index 13f90a15..3622d981 100644 --- a/src/it/staging-reactor/mod3/pom.xml +++ b/src/it/staging-reactor/mod3/pom.xml @@ -44,7 +44,7 @@ under the License. maven-source-plugin - @sourcePluginVersion@ + @version.maven-source-plugin@ attach-resources diff --git a/src/it/staging-reactor/pom.xml b/src/it/staging-reactor/pom.xml index 62ae2f34..46420123 100644 --- a/src/it/staging-reactor/pom.xml +++ b/src/it/staging-reactor/pom.xml @@ -46,7 +46,7 @@ under the License. org.apache.maven.plugins maven-site-plugin - @sitePluginVersion@ + @version.maven-site-plugin@ diff --git a/src/it/updateOnly/pom.xml b/src/it/updateOnly/pom.xml index 0b8d1f4b..86be0b69 100644 --- a/src/it/updateOnly/pom.xml +++ b/src/it/updateOnly/pom.xml @@ -42,7 +42,7 @@ under the License. org.apache.maven.plugins maven-antrun-plugin - @antrunPluginVersion@ + @version.maven-antrun-plugin@ initialize From 6a6770833f2df4fcb92c9869a6e2605c22d83dee Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 1 May 2024 13:20:50 +0200 Subject: [PATCH 62/92] [MINVOKER-335] Preserve symlinks for copied files --- .../invoker.properties | 19 ++++++ .../MINVOKER-335-symlinks-in-source/pom.xml | 65 +++++++++++++++++++ .../setup.groovy | 34 ++++++++++ .../src/it/clone-symlinks/pom.xml | 32 +++++++++ .../verify.groovy | 26 ++++++++ .../plugins/invoker/AbstractInvokerMojo.java | 9 ++- 6 files changed, 183 insertions(+), 2 deletions(-) create mode 100644 src/it/MINVOKER-335-symlinks-in-source/invoker.properties create mode 100644 src/it/MINVOKER-335-symlinks-in-source/pom.xml create mode 100644 src/it/MINVOKER-335-symlinks-in-source/setup.groovy create mode 100644 src/it/MINVOKER-335-symlinks-in-source/src/it/clone-symlinks/pom.xml create mode 100644 src/it/MINVOKER-335-symlinks-in-source/verify.groovy diff --git a/src/it/MINVOKER-335-symlinks-in-source/invoker.properties b/src/it/MINVOKER-335-symlinks-in-source/invoker.properties new file mode 100644 index 00000000..f45dd01a --- /dev/null +++ b/src/it/MINVOKER-335-symlinks-in-source/invoker.properties @@ -0,0 +1,19 @@ +# 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. + +# NOTE: Don't clean here to be able to detect test failures +invoker.goals = initialize diff --git a/src/it/MINVOKER-335-symlinks-in-source/pom.xml b/src/it/MINVOKER-335-symlinks-in-source/pom.xml new file mode 100644 index 00000000..a62be04d --- /dev/null +++ b/src/it/MINVOKER-335-symlinks-in-source/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + clone-clean-invocation + 1.0-SNAPSHOT + pom + + Test to check for copping symlinks from source to target + https://issues.apache.org/jira/browse/MINVOKER-335 + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it + + */pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/src/it/MINVOKER-335-symlinks-in-source/setup.groovy b/src/it/MINVOKER-335-symlinks-in-source/setup.groovy new file mode 100644 index 00000000..1d0e0fbb --- /dev/null +++ b/src/it/MINVOKER-335-symlinks-in-source/setup.groovy @@ -0,0 +1,34 @@ +/* + * 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.Files +import java.nio.file.Paths + +def projectPath = new File(basedir, 'src/it/clone-symlinks').toPath() + +def testDir = projectPath.resolve('testDir'); +def testFile = projectPath.resolve('test.txt') + +Files.createDirectory(testDir) +Files.createFile(testFile) + +Files.createSymbolicLink(projectPath.resolve('testDirLink'), Paths.get('testDir')) +Files.createSymbolicLink(projectPath.resolve('testLink.txt'), Paths.get('test.txt')) + +true \ No newline at end of file diff --git a/src/it/MINVOKER-335-symlinks-in-source/src/it/clone-symlinks/pom.xml b/src/it/MINVOKER-335-symlinks-in-source/src/it/clone-symlinks/pom.xml new file mode 100644 index 00000000..b49b4127 --- /dev/null +++ b/src/it/MINVOKER-335-symlinks-in-source/src/it/clone-symlinks/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + clone-symlnks + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/src/it/MINVOKER-335-symlinks-in-source/verify.groovy b/src/it/MINVOKER-335-symlinks-in-source/verify.groovy new file mode 100644 index 00000000..dee7a378 --- /dev/null +++ b/src/it/MINVOKER-335-symlinks-in-source/verify.groovy @@ -0,0 +1,26 @@ +/* + * 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.Files +import java.nio.file.Paths + +def projectPath = new File(basedir, 'target/it/clone-symlinks').toPath() + +assert Files.readSymbolicLink(projectPath.resolve('testDirLink')) == Paths.get('testDir') +assert Files.readSymbolicLink(projectPath.resolve('testLink.txt')) == Paths.get('test.txt') diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 3f13a13a..70ca4fec 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -92,6 +92,7 @@ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.InterpolationFilterReader; +import org.codehaus.plexus.util.NioFiles; import org.codehaus.plexus.util.ReflectionUtils; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.CommandLineUtils; @@ -1178,14 +1179,18 @@ private void copyDirectoryStructure(File sourceDir, File destDir) throws IOExcep /* * NOTE: Make sure the destination directory is always there (even if empty) to support POM-less ITs. */ - destDir.mkdirs(); + Files.createDirectories(destDir.toPath()); // Create all the directories, including any symlinks present in source FileUtils.mkDirs(sourceDir, scanner.getIncludedDirectories(), destDir); for (String includedFile : scanner.getIncludedFiles()) { File sourceFile = new File(sourceDir, includedFile); File destFile = new File(destDir, includedFile); - FileUtils.copyFile(sourceFile, destFile); + if (NioFiles.isSymbolicLink(sourceFile)) { + NioFiles.createSymbolicLink(destFile, NioFiles.readSymbolicLink(sourceFile)); + } else { + FileUtils.copyFile(sourceFile, destFile); + } // ensure clone project must be writable for additional changes destFile.setWritable(true); From 1bcf216cdccb3e7ff4d93af03073681860f17490 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 2 May 2024 21:13:46 +0200 Subject: [PATCH 63/92] Use default JDKs on jenkins build --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e257faf3..e9f05f7d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,4 +17,4 @@ * under the License. */ -asfMavenTlpPlgnBuild(jdks:[ "8", "11", "17", "19"]) +asfMavenTlpPlgnBuild() From 66a536f3ba1e94b2cbb40cfb23c60d2b067f628c Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 2 May 2024 20:18:43 +0200 Subject: [PATCH 64/92] [MINVOKER-336] Create empty .mvn directory in cloned projects --- .../clone-clean/{verify.bsh => setup.groovy} | 16 ++++-------- .../clone-clean/{setup.bsh => verify.groovy} | 16 +++--------- .../plugins/invoker/AbstractInvokerMojo.java | 26 +++++++++++++++++++ 3 files changed, 35 insertions(+), 23 deletions(-) rename src/it/clone-clean/{verify.bsh => setup.groovy} (79%) rename src/it/clone-clean/{setup.bsh => verify.groovy} (77%) diff --git a/src/it/clone-clean/verify.bsh b/src/it/clone-clean/setup.groovy similarity index 79% rename from src/it/clone-clean/verify.bsh rename to src/it/clone-clean/setup.groovy index f2ece44f..02466de4 100644 --- a/src/it/clone-clean/verify.bsh +++ b/src/it/clone-clean/setup.groovy @@ -17,15 +17,9 @@ * under the License. */ -import java.io.*; +File itRoot = new File(basedir, "target/it/clone-clean") +itRoot.mkdirs() +assert new File(itRoot, "foobar.log").createNewFile() + +assert !new File(basedir, 'src/it/clone-clean/.mvn').exists() -try -{ - File itRoot = new File( basedir, "target/it/clone-clean" ); - return !new File( itRoot, "foobar.log" ).exists(); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} diff --git a/src/it/clone-clean/setup.bsh b/src/it/clone-clean/verify.groovy similarity index 77% rename from src/it/clone-clean/setup.bsh rename to src/it/clone-clean/verify.groovy index b0296e20..9bb1d43f 100644 --- a/src/it/clone-clean/setup.bsh +++ b/src/it/clone-clean/verify.groovy @@ -17,16 +17,8 @@ * under the License. */ -import java.io.*; -try -{ - File itRoot = new File( basedir, "target/it/clone-clean" ); - itRoot.mkdirs(); - return new File(itRoot, "foobar.log").createNewFile(); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} +File itRoot = new File(basedir, "target/it/clone-clean") +assert !new File(itRoot, "foobar.log").exists() +// .mnv will be created +assert new File(itRoot, ".mvn").isDirectory() diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 70ca4fec..3c454b29 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -820,6 +820,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (cloneProjectsTo != null) { cloneProjects(collectedProjects); + addMissingDotMvnDirectory(cloneProjectsTo, buildJobs); projectsDir = cloneProjectsTo; } else { getLog().warn("Filtering of parent/child POMs is not supported without cloning the projects"); @@ -856,6 +857,31 @@ public void execute() throws MojoExecutionException, MojoFailureException { processResults(new InvokerSession(buildJobs)); } + /** + * We need add missing {@code .mnvn} directories for executing projects + * + * @param projectsDir base of projects + * @param buildJobs list of discovered jobs + */ + private void addMissingDotMvnDirectory(File projectsDir, List buildJobs) throws MojoExecutionException { + for (BuildJob buildJob : buildJobs) { + Path projectPath = projectsDir.toPath().resolve(buildJob.getProject()); + + if (Files.isRegularFile(projectPath)) { + projectPath = projectPath.getParent(); + } + + Path mvnDotPath = projectPath.resolve(".mvn"); + if (!Files.exists(mvnDotPath)) { + try { + Files.createDirectories(mvnDotPath); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); + } + } + } + } + private void setupActualMavenVersion() throws MojoExecutionException { if (mavenHome != null) { try { From 162fb74d0df5670a3a85e09d28842cfe3affffdb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 May 2024 13:03:32 +0200 Subject: [PATCH 65/92] [MINVOKER-363] Bump org.apache.maven.shared:maven-script-interpreter from 1.5 to 1.6 (#234) Bumps [org.apache.maven.shared:maven-script-interpreter](https://github.com/apache/maven-script-interpreter) from 1.5 to 1.6. - [Release notes](https://github.com/apache/maven-script-interpreter/releases) - [Commits](https://github.com/apache/maven-script-interpreter/compare/maven-script-interpreter-1.5...maven-script-interpreter-1.6) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-script-interpreter dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bba9d2f5..8f00c316 100644 --- a/pom.xml +++ b/pom.xml @@ -195,7 +195,7 @@ under the License. org.apache.maven.shared maven-script-interpreter - 1.5 + 1.6 From a741ea04854071c2900a323e65e7037449a4bdd3 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Fri, 3 May 2024 12:18:10 +0200 Subject: [PATCH 66/92] [MINVOKER-364] Rename invoker.systemPropertiesFile to invoker.userPropertiesFile --- .../src/it/project/invoker.properties | 4 +- .../{system1.properties => user.properties} | 0 .../{system2.properties => user3.properties} | 0 .../{verify.bsh => verify.groovy} | 26 +++--------- .../plugins/invoker/AbstractInvokerMojo.java | 19 ++++----- .../plugins/invoker/InvokerProperties.java | 41 +++++++++++++++++-- .../invoker/InvokerPropertiesTest.java | 39 ++++++++++++++++++ 7 files changed, 93 insertions(+), 36 deletions(-) rename src/it/invocation-multiple/src/it/project/{system1.properties => user.properties} (100%) rename src/it/invocation-multiple/src/it/project/{system2.properties => user3.properties} (100%) rename src/it/postbuild-executed-only-once/{verify.bsh => verify.groovy} (59%) diff --git a/src/it/invocation-multiple/src/it/project/invoker.properties b/src/it/invocation-multiple/src/it/project/invoker.properties index 89ca0884..3d0e1384 100644 --- a/src/it/invocation-multiple/src/it/project/invoker.properties +++ b/src/it/invocation-multiple/src/it/project/invoker.properties @@ -20,7 +20,7 @@ ####################################### invoker.goals = install invoker.profiles = plugin,profile0 -invoker.systemPropertiesFile = system1.properties +invoker.userPropertiesFile = user.properties ####################################### # First build @@ -40,4 +40,4 @@ invoker.profiles.2 = plugin,profile1 ####################################### invoker.goals.3 = test:test-maven-plugin:0.1-SNAPSHOT:test # profiles should fall back to invoker.profiles -invoker.systemPropertiesFile.3 = system2.properties +invoker.userPropertiesFile.3 = user3.properties diff --git a/src/it/invocation-multiple/src/it/project/system1.properties b/src/it/invocation-multiple/src/it/project/user.properties similarity index 100% rename from src/it/invocation-multiple/src/it/project/system1.properties rename to src/it/invocation-multiple/src/it/project/user.properties diff --git a/src/it/invocation-multiple/src/it/project/system2.properties b/src/it/invocation-multiple/src/it/project/user3.properties similarity index 100% rename from src/it/invocation-multiple/src/it/project/system2.properties rename to src/it/invocation-multiple/src/it/project/user3.properties diff --git a/src/it/postbuild-executed-only-once/verify.bsh b/src/it/postbuild-executed-only-once/verify.groovy similarity index 59% rename from src/it/postbuild-executed-only-once/verify.bsh rename to src/it/postbuild-executed-only-once/verify.groovy index e05fbff3..8ee560ad 100644 --- a/src/it/postbuild-executed-only-once/verify.bsh +++ b/src/it/postbuild-executed-only-once/verify.groovy @@ -17,25 +17,9 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.regex.*; +// make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else +def touchFile = new File(basedir, 'target/it/project/target/touch.txt') +assert touchFile.exists() -try -{ - // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else - File touchFile = new File( basedir, "target/it/project/target/touch.txt" ); - System.out.println( "Checking for existence of touch file: " + touchFile ); - if ( !touchFile.exists() ) - { - System.out.println( "FAILED! no touchFile " + touchFile.toString() ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; +def logs = new File(basedir, 'build.log').text +assert logs.contains('[WARNING] property invoker.systemPropertiesFile is deprecated - please use invoker.userPropertiesFile') diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 3c454b29..09987f4b 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -526,11 +526,11 @@ public abstract class AbstractInvokerMojo extends AbstractMojo { * # can be indexed * invoker.offline = true * - * # The path to the properties file from which to load system properties, defaults to the + * # The path to the properties file from which to load user properties, defaults to the * # filename given by the plugin parameter testPropertiesFile * # Since plugin version 1.4 * # can be indexed - * invoker.systemPropertiesFile = test.properties + * invoker.userPropertiesFile = test.properties * * # An optional human friendly name and description for this build job. * # Both name and description have to be set to be included in the build reports. @@ -1887,9 +1887,9 @@ private boolean runBuild( request.setUserSettingsFile(settingsFile); } - Properties systemProperties = - getSystemProperties(basedir, invokerProperties.getSystemPropertiesFile(invocationIndex)); - request.setProperties(systemProperties); + Properties userProperties = + getUserProperties(basedir, invokerProperties.getUserPropertiesFile(invocationIndex)); + request.setProperties(userProperties); invokerProperties.configureInvocation(request, invocationIndex); @@ -1999,7 +1999,7 @@ private FileLogger setupBuildLogFile(File basedir) throws MojoExecutionException * @return The system properties to use, may be empty but never null. * @throws org.apache.maven.plugin.MojoExecutionException If the properties file exists but could not be read. */ - private Properties getSystemProperties(final File basedir, final String filename) throws MojoExecutionException { + private Properties getUserProperties(final File basedir, final String filename) throws MojoExecutionException { Properties collectedTestProperties = new Properties(); if (properties != null) { @@ -2014,18 +2014,16 @@ private Properties getSystemProperties(final File basedir, final String filename File propertiesFile = null; if (filename != null) { propertiesFile = new File(basedir, filename); - } else if (testPropertiesFile != null) { - propertiesFile = new File(basedir, testPropertiesFile); } if (propertiesFile != null && propertiesFile.isFile()) { - try (InputStream fin = new FileInputStream(propertiesFile)) { + try (InputStream fin = Files.newInputStream(propertiesFile.toPath())) { Properties loadedProperties = new Properties(); loadedProperties.load(fin); collectedTestProperties.putAll(loadedProperties); } catch (IOException e) { - throw new MojoExecutionException("Error reading system properties from " + propertiesFile); + throw new MojoExecutionException("Error reading user properties from " + propertiesFile); } } @@ -2369,6 +2367,7 @@ private InvokerProperties getInvokerProperties(final File projectDirectory, Prop invokerProperties.setDefaultTimeoutInSeconds(timeoutInSeconds); invokerProperties.setDefaultEnvironmentVariables(environmentVariables); invokerProperties.setDefaultUpdateSnapshots(updateSnapshots); + invokerProperties.setDefaultUserPropertiesFiles(testPropertiesFile); return invokerProperties; } diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java index 15e246d0..4bf09e71 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java @@ -32,6 +32,8 @@ import java.util.regex.Pattern; import org.apache.maven.shared.invoker.InvocationRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Provides a convenient facade around the invoker.properties. @@ -39,6 +41,9 @@ * @author Benjamin Bentmann */ class InvokerProperties { + + private final Logger logger = LoggerFactory.getLogger(InvokerProperties.class); + private static final String SELECTOR_PREFIX = "selector."; private static final Pattern ENVIRONMENT_VARIABLES_PATTERN = @@ -54,6 +59,7 @@ class InvokerProperties { private Map defaultEnvironmentVariables; private File defaultMavenExecutable; private Boolean defaultUpdateSnapshots; + private String defaultUserPropertiesFiles; private enum InvocationProperty { PROJECT("invoker.project"), @@ -66,6 +72,7 @@ private enum InvocationProperty { NON_RECURSIVE("invoker.nonRecursive"), OFFLINE("invoker.offline"), SYSTEM_PROPERTIES_FILE("invoker.systemPropertiesFile"), + USER_PROPERTIES_FILE("invoker.userPropertiesFile"), DEBUG("invoker.debug"), QUIET("invoker.quiet"), SETTINGS_FILE("invoker.settingsFile"), @@ -190,6 +197,14 @@ public void setDefaultUpdateSnapshots(boolean defaultUpdateSnapshots) { this.defaultUpdateSnapshots = defaultUpdateSnapshots; } + /** + * Default value for userPropertiesFile + * @param defaultUserPropertiesFiles a default value + */ + public void setDefaultUserPropertiesFiles(String defaultUserPropertiesFiles) { + this.defaultUserPropertiesFiles = defaultUserPropertiesFiles; + } + /** * Gets the invoker properties being wrapped. * @@ -467,13 +482,33 @@ public boolean isExpectedResult(int exitCode, int index) { } /** - * Gets the path to the properties file used to set the system properties for the specified invocation. + * Gets the path to the properties file used to set the user properties for the specified invocation. * * @param index The index of the invocation, must not be negative. * @return The path to the properties file or null if not set. */ - public String getSystemPropertiesFile(int index) { - return get(InvocationProperty.SYSTEM_PROPERTIES_FILE, index).orElse(null); + public String getUserPropertiesFile(int index) { + Optional userProperties = get(InvocationProperty.USER_PROPERTIES_FILE, index); + Optional systemProperties = get(InvocationProperty.SYSTEM_PROPERTIES_FILE, index); + + if (userProperties.isPresent() && systemProperties.isPresent()) { + throw new IllegalArgumentException("only one property '" + InvocationProperty.USER_PROPERTIES_FILE + + "' or '" + InvocationProperty.SYSTEM_PROPERTIES_FILE + "' can be used"); + } + + if (userProperties.isPresent()) { + return userProperties.get(); + } + + if (systemProperties.isPresent()) { + logger.warn( + "property {} is deprecated - please use {}", + InvocationProperty.SYSTEM_PROPERTIES_FILE, + InvocationProperty.USER_PROPERTIES_FILE); + return systemProperties.get(); + } + + return defaultUserPropertiesFiles; } /** diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java index 26a706ec..58285f86 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java @@ -545,4 +545,43 @@ void testGetToolchainsWithIndex() { assertThat(toolchain.getType()).isEqualTo("jdk"); assertThat(toolchain.getProvides()).containsExactlyEntriesOf(Collections.singletonMap("version", "11")); } + + @Test + void defaultValueForUserPropertiesFileShouldBeReturned() { + InvokerProperties facade = new InvokerProperties(new Properties()); + facade.setDefaultUserPropertiesFiles("test3.properties"); + + assertThat(facade.getUserPropertiesFile(0)).isEqualTo("test3.properties"); + } + + @Test + void userPropertiesFilesShouldBeUsed() { + Properties props = new Properties(); + props.put("invoker.userPropertiesFile", "test1"); + InvokerProperties facade = new InvokerProperties(props); + + assertThat(facade.getUserPropertiesFile(0)).isEqualTo("test1"); + } + + @Test + void systemPropertiesFilesShouldBeUsed() { + Properties props = new Properties(); + props.put("invoker.systemPropertiesFile", "test1"); + InvokerProperties facade = new InvokerProperties(props); + + assertThat(facade.getUserPropertiesFile(0)).isEqualTo("test1"); + } + + @Test + void userAndSystemPropertiesFilesShouldThrowException() { + Properties props = new Properties(); + props.put("invoker.systemPropertiesFile", "test1"); + props.put("invoker.userPropertiesFile", "test2"); + InvokerProperties facade = new InvokerProperties(props); + + assertThatCode(() -> facade.getUserPropertiesFile(0)) + .isExactlyInstanceOf(IllegalArgumentException.class) + .hasMessage( + "only one property 'invoker.userPropertiesFile' or 'invoker.systemPropertiesFile' can be used"); + } } From be7f699d10c8afeeaa6dc0d5c9e8ece9f7c9c209 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 5 May 2024 10:50:59 +0200 Subject: [PATCH 67/92] [MINVOKER-335] Use selector script for preparing test with symlinks --- .../{setup.groovy => selector.groovy} | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) rename src/it/MINVOKER-335-symlinks-in-source/{setup.groovy => selector.groovy} (78%) diff --git a/src/it/MINVOKER-335-symlinks-in-source/setup.groovy b/src/it/MINVOKER-335-symlinks-in-source/selector.groovy similarity index 78% rename from src/it/MINVOKER-335-symlinks-in-source/setup.groovy rename to src/it/MINVOKER-335-symlinks-in-source/selector.groovy index 1d0e0fbb..9afad9aa 100644 --- a/src/it/MINVOKER-335-symlinks-in-source/setup.groovy +++ b/src/it/MINVOKER-335-symlinks-in-source/selector.groovy @@ -28,7 +28,12 @@ def testFile = projectPath.resolve('test.txt') Files.createDirectory(testDir) Files.createFile(testFile) -Files.createSymbolicLink(projectPath.resolve('testDirLink'), Paths.get('testDir')) -Files.createSymbolicLink(projectPath.resolve('testLink.txt'), Paths.get('test.txt')) +// If FS does not support symlinks we should skip test +try { + Files.createSymbolicLink(projectPath.resolve('testDirLink'), Paths.get('testDir')) + Files.createSymbolicLink(projectPath.resolve('testLink.txt'), Paths.get('test.txt')) +} catch (IOException e) { + return false +} -true \ No newline at end of file +return true From e4dea9d5a05cc4d716f8d9605b26d76bdd62d912 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 5 May 2024 13:52:44 +0200 Subject: [PATCH 68/92] [MINVOKER-366] Require Maven 3.6.3 --- pom.xml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 8f00c316..0de3e5b3 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.6.2-SNAPSHOT + 3.7.0-SNAPSHOT maven-plugin Apache Maven Invoker Plugin @@ -62,11 +62,11 @@ under the License. 8 - 3.2.5 + 3.6.3 org.apache-extras.beanshell bsh 2.0b6 - 2024-03-27T06:01:10Z + 2024-05-05T11:44:43Z 4.0.21 @@ -146,9 +146,9 @@ under the License. provided - org.eclipse.aether - aether-util - 1.0.0.v20140518 + org.apache.maven.resolver + maven-resolver-util + 1.4.1 @@ -168,7 +168,15 @@ under the License. org.apache.maven - * + maven-artifact + + + org.apache.maven + maven-core + + + org.apache.maven + maven-plugin-api From b8aed81a7ed872624df9a10846b8a9cddf5f9b1d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 11 May 2024 12:48:07 +0200 Subject: [PATCH 69/92] [MINVOKER-367] Bump org.apache.maven.shared:maven-invoker from 3.2.0 to 3.3.0 (#240) Bumps [org.apache.maven.shared:maven-invoker](https://github.com/apache/maven-invoker) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/apache/maven-invoker/releases) - [Commits](https://github.com/apache/maven-invoker/compare/maven-invoker-3.2.0...maven-invoker-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-invoker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0de3e5b3..6c236b58 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ under the License. org.apache.maven.shared maven-invoker - 3.2.0 + 3.3.0 org.apache.maven From 89b9633c3d811275573633ace560f89107a9decb Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 4 May 2024 16:43:56 +0200 Subject: [PATCH 70/92] [MINVOKER-365] Allow to pre-build script to set user properties --- .../pom.xml | 65 ++++++++ .../src/it/project/pom.xml | 60 +++++++ .../src/it/project/postbuild.groovy | 22 +++ .../src/it/project/prebuild.groovy | 26 +++ .../verify.groovy | 29 ++++ .../plugins/invoker/AbstractInvokerMojo.java | 53 +++--- .../apt/examples/post-build-script.apt.vm | 97 ----------- .../apt/examples/pre-post-build-script.apt.vm | 151 ++++++++++++++++++ src/site/apt/examples/selector-scripts.apt.vm | 5 +- src/site/apt/groovy-version.apt.vm | 2 +- src/site/apt/index.apt.vm | 2 +- src/site/apt/usage.apt.vm | 2 +- src/site/site.xml | 2 +- 13 files changed, 394 insertions(+), 122 deletions(-) create mode 100644 src/it/MINVOKER-365-user-poperties-from-pre-build/pom.xml create mode 100644 src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/pom.xml create mode 100644 src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/postbuild.groovy create mode 100644 src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/prebuild.groovy create mode 100644 src/it/MINVOKER-365-user-poperties-from-pre-build/verify.groovy delete mode 100644 src/site/apt/examples/post-build-script.apt.vm create mode 100644 src/site/apt/examples/pre-post-build-script.apt.vm diff --git a/src/it/MINVOKER-365-user-poperties-from-pre-build/pom.xml b/src/it/MINVOKER-365-user-poperties-from-pre-build/pom.xml new file mode 100644 index 00000000..044b2f84 --- /dev/null +++ b/src/it/MINVOKER-365-user-poperties-from-pre-build/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker.its + minvoker-335 + 1.0-SNAPSHOT + pom + + + Test to check a user properties generated by pre-build + + + + UTF-8 + @version.maven-enforcer-plugin@ + @version.maven-clean-plugin@ + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + + integration-test + initialize + + run + + + + + + clean + initialize + + + + + + + diff --git a/src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/pom.xml b/src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/pom.xml new file mode 100644 index 00000000..02d6e99a --- /dev/null +++ b/src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/pom.xml @@ -0,0 +1,60 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + minvoker-365 + 0.1-SNAPSHOT + pom + + + + + org.apache.maven.plugins + maven-clean-plugin + @version.maven-clean-plugin@ + + + org.apache.maven.plugins + maven-enforcer-plugin + @version.maven-enforcer-plugin@ + + + initialize + + enforce + + + + + + + + ${testFile} + + + + + + + + diff --git a/src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/postbuild.groovy b/src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/postbuild.groovy new file mode 100644 index 00000000..6491a73a --- /dev/null +++ b/src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/postbuild.groovy @@ -0,0 +1,22 @@ +/* + * 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. + */ + +def logs = new File(basedir, 'build.log').text + +assert logs.contains('[INFO] Clean is skipped.') diff --git a/src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/prebuild.groovy b/src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/prebuild.groovy new file mode 100644 index 00000000..ebb19e07 --- /dev/null +++ b/src/it/MINVOKER-365-user-poperties-from-pre-build/src/it/project/prebuild.groovy @@ -0,0 +1,26 @@ +import java.nio.file.Files + +/* + * 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. + */ + +def userProperties = context.get('userProperties') + +def testFilePath = Files.createTempFile('minvoker-365-prefix', 'suffix') +userProperties.put('testFile', testFilePath.toString()) +userProperties.put('maven.clean.skip', 'true') diff --git a/src/it/MINVOKER-365-user-poperties-from-pre-build/verify.groovy b/src/it/MINVOKER-365-user-poperties-from-pre-build/verify.groovy new file mode 100644 index 00000000..e82ee9ab --- /dev/null +++ b/src/it/MINVOKER-365-user-poperties-from-pre-build/verify.groovy @@ -0,0 +1,29 @@ +/* + * 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. + */ + +def logs = new File(basedir, 'build.log').text + +// check if properties are pass to execution +if (System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("windows")) { + assert logs.contains("-D testFile=") + assert logs.contains("-D maven.clean.skip=true") +} else { + assert logs.contains("'-D' 'testFile=") + assert logs.contains("'-D' 'maven.clean.skip=true'") +} diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 09987f4b..78b2d305 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -1838,24 +1838,15 @@ private boolean runBuild( } Map context = new LinkedHashMap<>(); + Properties scriptUserProperties = new Properties(); + context.put("userProperties", scriptUserProperties); - boolean selectorResult = true; + if (!runSelectorHook(basedir, context, logger)) { + return false; + } try { - try { - scriptRunner.run("selector script", basedir, selectorScript, context, logger); - } catch (ScriptReturnException e) { - selectorResult = false; - return false; - } catch (ScriptException e) { - throw new RunFailureException(BuildJob.Result.ERROR, e); - } - - try { - scriptRunner.run("pre-build script", basedir, preBuildHookScript, context, logger); - } catch (ScriptException e) { - throw new RunFailureException(BuildJob.Result.FAILURE_PRE_HOOK, e); - } + runPreBuildHook(basedir, context, logger); for (int invocationIndex = 1; ; invocationIndex++) { if (invocationIndex > 1 && !invokerProperties.isInvocationDefined(invocationIndex)) { @@ -1889,6 +1880,7 @@ private boolean runBuild( Properties userProperties = getUserProperties(basedir, invokerProperties.getUserPropertiesFile(invocationIndex)); + userProperties.putAll(scriptUserProperties); request.setProperties(userProperties); invokerProperties.configureInvocation(request, invocationIndex); @@ -1911,12 +1903,8 @@ private boolean runBuild( "Maven invocation failed. " + e.getMessage(), BuildJob.Result.FAILURE_BUILD); } } - } catch (IOException e) { - throw new MojoExecutionException(e.getMessage(), e); } finally { - if (selectorResult) { - runPostBuildHook(basedir, context, logger); - } + runPostBuildHook(basedir, context, logger); } return true; } @@ -1931,6 +1919,31 @@ int getParallelThreadsCount() { } } + private boolean runSelectorHook(File basedir, Map context, FileLogger logger) + throws MojoExecutionException, RunFailureException { + try { + scriptRunner.run("selector script", basedir, selectorScript, context, logger); + } catch (ScriptReturnException e) { + return false; + } catch (ScriptException e) { + throw new RunFailureException(BuildJob.Result.ERROR, e); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); + } + return true; + } + + private void runPreBuildHook(File basedir, Map context, FileLogger logger) + throws MojoExecutionException, RunFailureException { + try { + scriptRunner.run("pre-build script", basedir, preBuildHookScript, context, logger); + } catch (ScriptException e) { + throw new RunFailureException(BuildJob.Result.FAILURE_PRE_HOOK, e); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); + } + } + private void runPostBuildHook(File basedir, Map context, FileLogger logger) throws MojoExecutionException, RunFailureException { try { diff --git a/src/site/apt/examples/post-build-script.apt.vm b/src/site/apt/examples/post-build-script.apt.vm deleted file mode 100644 index 93c15a8c..00000000 --- a/src/site/apt/examples/post-build-script.apt.vm +++ /dev/null @@ -1,97 +0,0 @@ - ------ - Using a Post-Build Script - ------ - Paul Gier - ------ - 2008-08-02 - ------ - - ~~ 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. - - ~~ NOTE: For help with the syntax of this file, see: - ~~ http://maven.apache.org/doxia/references/apt-format.html - -Using a Post-Build Script - - Here is an example of how the Invoker Plugin can be used to run a set of Maven projects and then verify their output - with a {{{http://www.beanshell.org/}BeanShell}} or {{{http://groovy-lang.org/}Groovy}} script. The name of the - script file in this case is <<>>. - -+------------------ - - - - - maven-invoker-plugin - ${project.version} - - true - src/it - setup.bsh - verify.bsh - - - - integration-test - - run - - - - - - - -+------------------ - - Below is an example post-build BeanShell script (<<>>) that checks for the existence of a JAR file after - the build has run. If the JAR file does not exist, the script throws an exception which causes the Invoker Plugin to - log that the build failed. More precisely, any non-null return value which does not equal <<>> will be interpreted - as a failure condition. And of course, if the script exits abnormally due to an exception, the plugin will flag the - corresponding build as a failure, too. - -+------------------ -import java.io.*; - -File file = new File( basedir, "target/my-test-project-1.0-SNAPSHOT.jar" ); -if ( !file.isFile() ) -{ - throw new FileNotFoundException( "Could not find generated JAR: " + file ); -} -+------------------ - - Complementary to the post-build hook script, you can also create a pre-build hook script that will be run before - the invocation of Maven. This can be used to do some preparations for the build. - - To allow the scripts to access some useful data about the test project, the following global variables will be - defined by the Invoker Plugin before running the script: - -*--------------------------+----------------------+-----------------------------------------------------------+--------+ -|| Name || Type || Description || Since | -*--------------------------+----------------------+-----------------------------------------------------------+--------+ -| <<>> | <<>> | The absolute path to the base directory of the test project. | 1.0 | -*--------------------------+----------------------+-----------------------------------------------------------+--------+ -| <<>>| <<>> | The absolute path to the local repository used for the Maven invocation on the test project. | 1.3 | -*--------------------------+----------------------+-----------------------------------------------------------+--------+ -| <<>> | <<>> | The storage of key-value pairs used to pass data from the pre-build hook script to the post-build hook script. | 1.4 | -*--------------------------+----------------------+-----------------------------------------------------------+--------+ -| <<>> | <<>> | The version of Maven executing on the test project. | 1.9 | -*--------------------------+----------------------+-----------------------------------------------------------+--------+ - - Additional variables that can be accessed in the hook scripts can be defined through the - <<<{{{../run-mojo.html#scriptVariables}scriptVariables}}>>> parameter in the Invoker Plugin's configuration. \ No newline at end of file diff --git a/src/site/apt/examples/pre-post-build-script.apt.vm b/src/site/apt/examples/pre-post-build-script.apt.vm new file mode 100644 index 00000000..8a8e0948 --- /dev/null +++ b/src/site/apt/examples/pre-post-build-script.apt.vm @@ -0,0 +1,151 @@ + ------ + Using Pre and Post Build Script + ------ + Paul Gier + ------ + 2008-08-02 + ------ + + ~~ 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. + + ~~ NOTE: For help with the syntax of this file, see: + ~~ http://maven.apache.org/doxia/references/apt-format.html + +Using a Pre-Build Script + + Complementary to the post-build hook script, you can also create a pre-build hook script that will be run before + the invocation of Maven. This can be used to do some preparations for the build. + + Default name of Pre-Build script is <<>>, you can use name <<>> or <<>> + according to chosen script language. + + In Pre-Build scripts you can prepare a test resources for your project. + + You can also define a user properties which will be added to executed test project by <<<-D>>> Maven argument. + + Here is an example of groovy script: + ++------------------ +def userProperties = context.get('userProperties') + +def server = new MockServer() +userProperties.put('serverHost', server.getHost()) +userProperties.put('serverPort', server.getPort()) ++------------------ + + Now you can use it in test project: + ++------------------ + + + + + org.example + my-maven-plugin + @project.version@ + + ${serverHost}:${serverPort} + + + .... + + + + + ++------------------ + +Using a Post-Build Script + + Here is an example of how the Invoker Plugin can be used to run a set of Maven projects and then verify their output + with a {{{https://beanshell.github.io/}BeanShell}} or {{{https://groovy-lang.org/}Groovy}} script. The name of the + script file in this case is <<>> - default value is <<>>. + ++------------------ + + + + + maven-invoker-plugin + ${project.version} + + true + src/it + setup + verify + + + + integration-test + + run + + + + + + + ++------------------ + + Below is an example post-build BeanShell script (<<>>) that checks for the existence of a JAR file after + the build has run. If the JAR file does not exist, the script throws an exception which causes the Invoker Plugin to + log that the build failed. More precisely, any non-null return value which does not equal <<>> will be interpreted + as a failure condition. And of course, if the script exits abnormally due to an exception, the plugin will flag the + corresponding build as a failure, too. + + Example <<>> + ++------------------ +import java.io.*; + +File file = new File( basedir, "target/my-test-project-1.0-SNAPSHOT.jar" ); +if ( !file.isFile() ) +{ + throw new FileNotFoundException( "Could not find generated JAR: " + file ); +} ++------------------ + + and similar <<>> + ++------------------ +def file = new File( basedir, "target/my-test-project-1.0-SNAPSHOT.jar" ) +assert file.isFile() ++------------------ + +Predefined global variables + + To allow the scripts to access some useful data about the test project, the following global variables will be + defined by the Invoker Plugin before running the script: + +*-------------------------------------+----------------------------+-----------------------------------------------------------+--------+ +|| Name || Type || Description || Since | +*-------------------------------------+----------------------------+-----------------------------------------------------------+--------+ +| <<>> | <<>> | The absolute path to the base directory of the test project. | 1.0 | +*-------------------------------------+----------------------------+-----------------------------------------------------------+--------+ +| <<>> | <<>> | The absolute path to the local repository used for the Maven invocation on the test project. | 1.3 | +*-------------------------------------+----------------------------+-----------------------------------------------------------+--------+ +| <<>> | <<>> | The storage of key-value pairs used to pass data from the pre-build hook script to the post-build hook script. | 1.4 | +*-------------------------------------+----------------------------+-----------------------------------------------------------+--------+ +| <<>> | <<>> | The user properties for executing project | 3.7.0 | +*-------------------------------------+----------------------------+-----------------------------------------------------------+--------+ +| <<>> | <<>> | The version of Maven executing on the test project. | 1.9 | +*-------------------------------------+----------------------------+-----------------------------------------------------------+--------+ + + Additional variables that can be accessed in the hook scripts can be defined through the + <<<{{{../run-mojo.html#scriptVariables}scriptVariables}}>>> parameter in the Invoker Plugin's configuration. diff --git a/src/site/apt/examples/selector-scripts.apt.vm b/src/site/apt/examples/selector-scripts.apt.vm index 43072dfe..806a2223 100644 --- a/src/site/apt/examples/selector-scripts.apt.vm +++ b/src/site/apt/examples/selector-scripts.apt.vm @@ -85,4 +85,7 @@ Selector Scripts If the script returns any value other than <<>>, then the project will not be executed. If the script throws an exception, then the project will be marked as being in ERROR. - + +Predefined global variables + + In Selector Scripts the same global variables are defined as in {{{./pre-post-build-script.html#predefined-global-variables}Pre and Post Build Script}} diff --git a/src/site/apt/groovy-version.apt.vm b/src/site/apt/groovy-version.apt.vm index bc1d17f9..76a1aad6 100644 --- a/src/site/apt/groovy-version.apt.vm +++ b/src/site/apt/groovy-version.apt.vm @@ -56,7 +56,7 @@ Groovy version and extensions org.apache.groovy groovy-yaml - 3.0.10 + ${groovy-version} diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index a05187c4..bcb7e576 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -98,7 +98,7 @@ ${project.name} * {{{./examples/install-artifacts.html}Install}} projects artifacts to a local repository before running. - * {{{./examples/post-build-script.html}Run a BeanShell or Groovy script}} to verify project output. + * {{{./examples/pre-post-build-script.html}Run a BeanShell or Groovy script}} to prepare or verify project. * {{{./examples/fast-use.html}Fast Invoker Plugin configuration}} to accelerate project execution. diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm index 8269569f..7562d05c 100644 --- a/src/site/apt/usage.apt.vm +++ b/src/site/apt/usage.apt.vm @@ -122,7 +122,7 @@ Usage When an integration test has finished, the plugin will invoke an optional post build hook script. In the example, this is the case for <<>> where <<>> will be run. The purpose of this script is usually to check that the build of the integration test did not only succeed but also produced the intended output. Have a look - at the example {{{./examples/post-build-script.html}Using a Post Build Script}} for a code snippet. + at the example {{{./examples/pre-post-build-script.html}Using Pre and Post Build Script}} for a code snippet. * Running Only Some Tests diff --git a/src/site/site.xml b/src/site/site.xml index 1b34bc66..a0932f76 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -48,7 +48,7 @@ under the License. - + From 0e572a9e3221b2b755c01ce00754d6d8a1c57100 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 11 May 2024 12:56:36 +0200 Subject: [PATCH 71/92] [MINVOKER-307] Support `@{..}` syntax in mavenOpts --- pom.xml | 9 +++ .../plugins/invoker/AbstractInvokerMojo.java | 9 ++- .../plugins/invoker/InterpolatorUtils.java | 62 ++++++++++++++++ .../invoker/InterpolatorUtilsTest.java | 71 +++++++++++++++++++ .../plugins/invoker/InvokerMojoTest.java | 20 ++++-- 5 files changed, 165 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/apache/maven/plugins/invoker/InterpolatorUtils.java create mode 100644 src/test/java/org/apache/maven/plugins/invoker/InterpolatorUtilsTest.java diff --git a/pom.xml b/pom.xml index 6c236b58..cc87562d 100644 --- a/pom.xml +++ b/pom.xml @@ -264,6 +264,11 @@ under the License. junit-jupiter-api test + + org.junit.jupiter + junit-jupiter-params + test + org.mockito mockito-core @@ -377,6 +382,10 @@ under the License. + + org.eclipse.sisu + sisu-maven-plugin + diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 78b2d305..5644fe2a 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -410,6 +410,10 @@ public abstract class AbstractInvokerMojo extends AbstractMojo { /** * The MAVEN_OPTS environment variable to use when invoking Maven. This value can be overridden for * individual integration tests by using {@link #invokerPropertiesFile}. + *
+ * Since the version 3.7.0 using an alternate syntax for mavenOpts, @{...} + * allows late replacement of properties when the plugin is executed, + * so properties that have been modified by other plugins will be picked up correctly. * * @since 1.2 */ @@ -739,6 +743,9 @@ public abstract class AbstractInvokerMojo extends AbstractMojo { @Component private ToolchainManagerPrivate toolchainManagerPrivate; + @Component + private InterpolatorUtils interpolatorUtils; + /** * Invokes Maven on the configured test projects. * @@ -2376,7 +2383,7 @@ private InvokerProperties getInvokerProperties(final File projectDirectory, Prop invokerProperties.setDefaultGoals(goals); invokerProperties.setDefaultProfiles(profiles); invokerProperties.setDefaultMavenExecutable(mavenExecutable); - invokerProperties.setDefaultMavenOpts(mavenOpts); + invokerProperties.setDefaultMavenOpts(interpolatorUtils.interpolateAtPattern(mavenOpts)); invokerProperties.setDefaultTimeoutInSeconds(timeoutInSeconds); invokerProperties.setDefaultEnvironmentVariables(environmentVariables); invokerProperties.setDefaultUpdateSnapshots(updateSnapshots); diff --git a/src/main/java/org/apache/maven/plugins/invoker/InterpolatorUtils.java b/src/main/java/org/apache/maven/plugins/invoker/InterpolatorUtils.java new file mode 100644 index 00000000..a4804b9b --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/invoker/InterpolatorUtils.java @@ -0,0 +1,62 @@ +/* + * 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. + */ +package org.apache.maven.plugins.invoker; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.MapBasedValueSource; +import org.codehaus.plexus.interpolation.RegexBasedInterpolator; + +/** + * Helper component for interpolating values. + */ +@Named +class InterpolatorUtils { + + private final Interpolator atInterpolator; + + /** + * A default constructor. + * + * @param mavenProject a MavenProject + */ + @Inject + InterpolatorUtils(MavenProject mavenProject) { + atInterpolator = new RegexBasedInterpolator("[@\\$]\\{(.+?)", "}"); + atInterpolator.addValueSource(new MapBasedValueSource(mavenProject.getProperties())); + } + + public String interpolateAtPattern(String value) throws MojoExecutionException { + + if (value == null || !(value.contains("@{") || value.contains("${"))) { + return value; + } + + try { + return atInterpolator.interpolate(value); + } catch (InterpolationException e) { + throw new MojoExecutionException(e.getMessage(), e); + } + } +} diff --git a/src/test/java/org/apache/maven/plugins/invoker/InterpolatorUtilsTest.java b/src/test/java/org/apache/maven/plugins/invoker/InterpolatorUtilsTest.java new file mode 100644 index 00000000..ceab70aa --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/invoker/InterpolatorUtilsTest.java @@ -0,0 +1,71 @@ +/* + * 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. + */ +package org.apache.maven.plugins.invoker; + +import java.util.Properties; +import java.util.stream.Stream; + +import org.apache.maven.project.MavenProject; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class InterpolatorUtilsTest { + + @Mock + private MavenProject mavenProject; + + static Stream testAtInterpolate() { + return Stream.of( + Arguments.of(null, null), + Arguments.of("test", "test"), + Arguments.of("test@test", "test@test"), + Arguments.of("test$test", "test$test"), + Arguments.of("@{test}", "testInProps"), + Arguments.of("${test}", "testInProps"), + Arguments.of("test @{test} test", "test testInProps test"), + Arguments.of("test ${test} test", "test testInProps test"), + Arguments.of("@{test} @{test}", "testInProps testInProps"), + Arguments.of("${test} ${test}", "testInProps testInProps"), + Arguments.of("@{test} ${test}", "testInProps testInProps")); + } + + @ParameterizedTest + @MethodSource + void testAtInterpolate(String input, String expected) throws Exception { + // given + Properties properties = new Properties(); + properties.put("test", "testInProps"); + when(mavenProject.getProperties()).thenReturn(properties); + InterpolatorUtils interpolatorUtils = new InterpolatorUtils(mavenProject); + + // when + String output = interpolatorUtils.interpolateAtPattern(input); + + // then + assertThat(output).isEqualTo(expected); + } +} diff --git a/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java b/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java index d57a5876..fd603222 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java @@ -49,11 +49,13 @@ private MavenProject getMavenProject() { @Test void testSingleInvokerTest() throws Exception { // given + MavenProject mavenProject = getMavenProject(); InvokerMojo invokerMojo = new InvokerMojo(); String dirPath = getBasedir() + "/src/test/resources/unit"; setVariableValueToObject(invokerMojo, "projectsDirectory", new File(dirPath)); setVariableValueToObject(invokerMojo, "invokerPropertiesFile", "invoker.properties"); - setVariableValueToObject(invokerMojo, "project", getMavenProject()); + setVariableValueToObject(invokerMojo, "project", mavenProject); + setVariableValueToObject(invokerMojo, "interpolatorUtils", new InterpolatorUtils(mavenProject)); setVariableValueToObject(invokerMojo, "invokerTest", "*dummy*"); setVariableValueToObject(invokerMojo, "settings", new Settings()); @@ -67,11 +69,13 @@ void testSingleInvokerTest() throws Exception { @Test void testMultiInvokerTest() throws Exception { // given + MavenProject mavenProject = getMavenProject(); InvokerMojo invokerMojo = new InvokerMojo(); String dirPath = getBasedir() + "/src/test/resources/unit"; setVariableValueToObject(invokerMojo, "projectsDirectory", new File(dirPath)); setVariableValueToObject(invokerMojo, "invokerPropertiesFile", "invoker.properties"); - setVariableValueToObject(invokerMojo, "project", getMavenProject()); + setVariableValueToObject(invokerMojo, "project", mavenProject); + setVariableValueToObject(invokerMojo, "interpolatorUtils", new InterpolatorUtils(mavenProject)); setVariableValueToObject(invokerMojo, "invokerTest", "*dummy*,*terpolatio*"); setVariableValueToObject(invokerMojo, "settings", new Settings()); @@ -85,11 +89,13 @@ void testMultiInvokerTest() throws Exception { @Test void testFullPatternInvokerTest() throws Exception { // given + MavenProject mavenProject = getMavenProject(); InvokerMojo invokerMojo = new InvokerMojo(); String dirPath = getBasedir() + "/src/test/resources/unit"; setVariableValueToObject(invokerMojo, "projectsDirectory", new File(dirPath)); setVariableValueToObject(invokerMojo, "invokerPropertiesFile", "invoker.properties"); - setVariableValueToObject(invokerMojo, "project", getMavenProject()); + setVariableValueToObject(invokerMojo, "project", mavenProject); + setVariableValueToObject(invokerMojo, "interpolatorUtils", new InterpolatorUtils(mavenProject)); setVariableValueToObject(invokerMojo, "invokerTest", "*"); setVariableValueToObject(invokerMojo, "settings", new Settings()); @@ -106,11 +112,13 @@ void testFullPatternInvokerTest() throws Exception { @Test void testSetupInProjectList() throws Exception { // given + MavenProject mavenProject = getMavenProject(); InvokerMojo invokerMojo = new InvokerMojo(); String dirPath = getBasedir() + "/src/test/resources/unit"; setVariableValueToObject(invokerMojo, "projectsDirectory", new File(dirPath)); setVariableValueToObject(invokerMojo, "invokerPropertiesFile", "invoker.properties"); - setVariableValueToObject(invokerMojo, "project", getMavenProject()); + setVariableValueToObject(invokerMojo, "project", mavenProject); + setVariableValueToObject(invokerMojo, "interpolatorUtils", new InterpolatorUtils(mavenProject)); setVariableValueToObject(invokerMojo, "settings", new Settings()); setVariableValueToObject(invokerMojo, "setupIncludes", Collections.singletonList("dum*/pom.xml")); @@ -134,11 +142,13 @@ void testSetupInProjectList() throws Exception { @Test void testSetupProjectIsFiltered() throws Exception { // given + MavenProject mavenProject = getMavenProject(); InvokerMojo invokerMojo = new InvokerMojo(); String dirPath = getBasedir() + "/src/test/resources/unit"; setVariableValueToObject(invokerMojo, "projectsDirectory", new File(dirPath)); setVariableValueToObject(invokerMojo, "invokerPropertiesFile", "invoker.properties"); - setVariableValueToObject(invokerMojo, "project", getMavenProject()); + setVariableValueToObject(invokerMojo, "project", mavenProject); + setVariableValueToObject(invokerMojo, "interpolatorUtils", new InterpolatorUtils(mavenProject)); setVariableValueToObject(invokerMojo, "settings", new Settings()); setVariableValueToObject(invokerMojo, "setupIncludes", Collections.singletonList("dum*/pom.xml")); setVariableValueToObject(invokerMojo, "invokerTest", "*project-dir*"); From 74a87f63712967d5c52c2ac00a16c0bb24e4ac45 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 22 May 2024 23:31:17 +0200 Subject: [PATCH 72/92] [MINVOKER-351] Escape special xml character in junit report (#242) --------- Co-authored-by: Michael Osipov --- pom.xml | 13 +++ src/it/MINVOKER-351/invoker.properties | 21 +++++ src/it/MINVOKER-351/pom.xml | 92 +++++++++++++++++++ .../MINVOKER-351/src/it/minvoker-351/pom.xml | 35 +++++++ .../src/it/minvoker-351/postbuild.groovy | 20 ++++ src/it/MINVOKER-351/verify.groovy | 31 +++++++ 6 files changed, 212 insertions(+) create mode 100644 src/it/MINVOKER-351/invoker.properties create mode 100644 src/it/MINVOKER-351/pom.xml create mode 100644 src/it/MINVOKER-351/src/it/minvoker-351/pom.xml create mode 100644 src/it/MINVOKER-351/src/it/minvoker-351/postbuild.groovy create mode 100644 src/it/MINVOKER-351/verify.groovy diff --git a/pom.xml b/pom.xml index cc87562d..a7c01d08 100644 --- a/pom.xml +++ b/pom.xml @@ -145,6 +145,12 @@ under the License. ${mavenVersion} provided
+ + org.apache.maven.resolver + maven-resolver-api + 1.4.1 + provided + org.apache.maven.resolver maven-resolver-util @@ -205,6 +211,11 @@ under the License. maven-script-interpreter 1.6 + + org.slf4j + slf4j-api + 1.7.36 + ${beanshell-groupId} @@ -236,6 +247,8 @@ under the License. org.codehaus.plexus plexus-xml + + 3.0.1 org.codehaus.plexus diff --git a/src/it/MINVOKER-351/invoker.properties b/src/it/MINVOKER-351/invoker.properties new file mode 100644 index 00000000..d3ffde37 --- /dev/null +++ b/src/it/MINVOKER-351/invoker.properties @@ -0,0 +1,21 @@ +# 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. + +invoker.goals.1 = initialize +invoker.buildResult.1 = failure + +invoker.goals.2 = site diff --git a/src/it/MINVOKER-351/pom.xml b/src/it/MINVOKER-351/pom.xml new file mode 100644 index 00000000..a38261e0 --- /dev/null +++ b/src/it/MINVOKER-351/pom.xml @@ -0,0 +1,92 @@ + + + + + + 4.0.0 + + example.minvoker351 + minvoker-351 + 1.0-SNAPSHOT + pom + + Special XML chars in build-job, junit reports + + + UTF-8 + @version.maven-compiler-plugin@ + @version.maven-surefire@ + + + + + + org.apache.maven.plugins + maven-site-plugin + @version.maven-site-plugin@ + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it + ${project.build.directory}/local-repo + true + + + + integration-test + initialize + + install + run + + + + + + + + + + true + + + org.apache.maven.plugins + maven-surefire-report-plugin + ${version.maven-surefire} + + + ${project.build.directory}/invoker-reports-test + + + + + + report-only + + + + + + + diff --git a/src/it/MINVOKER-351/src/it/minvoker-351/pom.xml b/src/it/MINVOKER-351/src/it/minvoker-351/pom.xml new file mode 100644 index 00000000..1e327cb6 --- /dev/null +++ b/src/it/MINVOKER-351/src/it/minvoker-351/pom.xml @@ -0,0 +1,35 @@ + + + + + + 4.0.0 + + example.minvoker351 + minvoker-351 + 1.0-SNAPSHOT + pom + + + UTF-8 + + + diff --git a/src/it/MINVOKER-351/src/it/minvoker-351/postbuild.groovy b/src/it/MINVOKER-351/src/it/minvoker-351/postbuild.groovy new file mode 100644 index 00000000..cc511ba0 --- /dev/null +++ b/src/it/MINVOKER-351/src/it/minvoker-351/postbuild.groovy @@ -0,0 +1,20 @@ +/* + * 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. + */ + +throw new Exception("Special chars \tcharName=" + Character.getName(7) + ": " + (char) 7) diff --git a/src/it/MINVOKER-351/verify.groovy b/src/it/MINVOKER-351/verify.groovy new file mode 100644 index 00000000..afc487b0 --- /dev/null +++ b/src/it/MINVOKER-351/verify.groovy @@ -0,0 +1,31 @@ +/* + * 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. + */ + +// we have a special chars in build.log +def buildLog = new File(basedir, 'target/it/minvoker-351/build.log').text +buildLog.contains('Special chars \tcharName=BEL: \u0007') + +def surefireReport = new File(basedir, 'target/site/surefire-report.html').text +assert surefireReport.contains('maven.invoker.it.minvoker-351') + +// TODO remove after next release +// Due to error parsing junit-reports by Jenkins with forbidden chars +new File(basedir, 'build.log').delete() + +return true \ No newline at end of file From 07a1977742c8461e30b209ec476c7b1caef0146f Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 22 May 2024 23:52:47 +0200 Subject: [PATCH 73/92] [maven-release-plugin] prepare release maven-invoker-plugin-3.7.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a7c01d08..91f6db93 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.7.0-SNAPSHOT + 3.7.0 maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://github.com/apache/maven-invoker-plugin.git scm:git:https://github.com/apache/maven-invoker-plugin.git - HEAD + maven-invoker-plugin-3.7.0 https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -66,7 +66,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2024-05-05T11:44:43Z + 2024-05-22T21:52:39Z 4.0.21 From 40a10b7e2b0e764b5e916bf8d82c76d44eb4b6de Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 22 May 2024 23:52:51 +0200 Subject: [PATCH 74/92] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 91f6db93..8e7194eb 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.7.0 + 3.7.1-SNAPSHOT maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://github.com/apache/maven-invoker-plugin.git scm:git:https://github.com/apache/maven-invoker-plugin.git - maven-invoker-plugin-3.7.0 + HEAD https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -66,7 +66,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2024-05-22T21:52:39Z + 2024-05-22T21:52:51Z 4.0.21 From affa7beadb96e934ce1fe0124d0cc7eb3d16f245 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 1 Jun 2024 22:40:16 +0200 Subject: [PATCH 75/92] Add missing dependency --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 8e7194eb..05269406 100644 --- a/pom.xml +++ b/pom.xml @@ -205,6 +205,12 @@ under the License. maven-plugin-annotations provided + + javax.inject + javax.inject + 1 + provided + org.apache.maven.shared From 1bd7bb2d009b40d747fad3808458d984c4abde21 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 6 Jul 2024 09:11:50 +0200 Subject: [PATCH 76/92] [MINVOKER-368] Filter artifacts by scope before resolving in install --- .../MINVOKER-368-install-filter-scope/pom.xml | 76 +++++++++++++++++++ .../verify.groovy | 32 ++++++++ .../maven/plugins/invoker/InstallMojo.java | 13 +--- 3 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 src/it/MINVOKER-368-install-filter-scope/pom.xml create mode 100644 src/it/MINVOKER-368-install-filter-scope/verify.groovy diff --git a/src/it/MINVOKER-368-install-filter-scope/pom.xml b/src/it/MINVOKER-368-install-filter-scope/pom.xml new file mode 100644 index 00000000..ed5374e6 --- /dev/null +++ b/src/it/MINVOKER-368-install-filter-scope/pom.xml @@ -0,0 +1,76 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + MINVOKER-368 + 1.0-SNAPSHOT + pom + + + Test to check for scope filtering during installation. + + + + UTF-8 + + + + + + + org.apache.maven.shared + maven-shared-utils + 3.4.2 + + + commons-io + commons-io + 2.16.1 + test + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it-repo + + + + integration-test + initialize + + install + + + + + + + + diff --git a/src/it/MINVOKER-368-install-filter-scope/verify.groovy b/src/it/MINVOKER-368-install-filter-scope/verify.groovy new file mode 100644 index 00000000..1a8e1c28 --- /dev/null +++ b/src/it/MINVOKER-368-install-filter-scope/verify.groovy @@ -0,0 +1,32 @@ +/* + * 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. + */ + + +def expected = [ + 'org/apache/maven/shared/maven-shared-utils/3.4.2/maven-shared-utils-3.4.2.pom', + 'org/apache/maven/shared/maven-shared-utils/3.4.2/maven-shared-utils-3.4.2.jar', + 'commons-io/commons-io/2.11.0/commons-io-2.11.0.pom', + 'commons-io/commons-io/2.11.0/commons-io-2.11.0.jar' +] + +def localRepo = new File(basedir, 'target/it-repo') + +def missingFiles = expected.findAll { !new File(localRepo, it).isFile() } + +assert missingFiles == [] diff --git a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java index 0a7ec02e..8894ef9d 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java @@ -52,6 +52,7 @@ import org.eclipse.aether.artifact.ArtifactTypeRegistry; import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.graph.DefaultDependencyNode; import org.eclipse.aether.graph.Dependency; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.installation.InstallRequest; @@ -59,7 +60,6 @@ import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.LocalRepositoryManager; import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.resolution.ArtifactDescriptorException; import org.eclipse.aether.resolution.ArtifactRequest; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.ArtifactResult; @@ -172,10 +172,7 @@ public void execute() throws MojoExecutionException { resolveExtraArtifacts(resolvedArtifacts); installArtifacts(resolvedArtifacts); - } catch (DependencyResolutionException - | InstallationException - | ArtifactDescriptorException - | ArtifactResolutionException e) { + } catch (DependencyResolutionException | InstallationException | ArtifactResolutionException e) { throw new MojoExecutionException(e.getMessage(), e); } } @@ -227,6 +224,7 @@ private void resolveProjectDependencies(Map resolvedArtifacts) List dependencies = project.getDependencies().stream() .map(d -> RepositoryUtils.toDependency(d, artifactTypeRegistry)) + .filter(d -> classpathFilter.accept(new DefaultDependencyNode(d), null)) .collect(Collectors.toList()); CollectRequest collectRequest = new CollectRequest(); @@ -251,12 +249,9 @@ private void resolveProjectDependencies(Map resolvedArtifacts) /** * Resolve extra artifacts. - * - * @return */ private void resolveExtraArtifacts(Map resolvedArtifacts) - throws MojoExecutionException, DependencyResolutionException, ArtifactDescriptorException, - ArtifactResolutionException { + throws MojoExecutionException, DependencyResolutionException, ArtifactResolutionException { if (extraArtifacts == null) { return; From b2f40e87d7bfd69cd1f1ced4caf5eea0586e6741 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 04:45:30 +0000 Subject: [PATCH 77/92] Bump commons-codec:commons-codec from 1.17.0 to 1.17.1 Bumps [commons-codec:commons-codec](https://github.com/apache/commons-codec) from 1.17.0 to 1.17.1. - [Changelog](https://github.com/apache/commons-codec/blob/master/RELEASE-NOTES.txt) - [Commits](https://github.com/apache/commons-codec/compare/rel/commons-codec-1.17.0...rel/commons-codec-1.17.1) --- updated-dependencies: - dependency-name: commons-codec:commons-codec dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 05269406..f439ed87 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ under the License. commons-codec commons-codec - 1.17.0 + 1.17.1 commons-collections From afacc74360cc52e26b312a91191ccd141a09952e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 Aug 2024 15:01:18 +0000 Subject: [PATCH 78/92] Bump org.apache.groovy:groovy-bom from 4.0.21 to 4.0.22 Bumps [org.apache.groovy:groovy-bom](https://github.com/apache/groovy) from 4.0.21 to 4.0.22. - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f439ed87..73dba466 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ under the License. bsh 2.0b6 2024-05-22T21:52:51Z - 4.0.21 + 4.0.22 From 7a0d04874d1f3a22e366185cd307dc4d20ad0c0d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 Aug 2024 15:08:05 +0000 Subject: [PATCH 79/92] Bump org.assertj:assertj-core from 3.25.3 to 3.26.3 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.25.3 to 3.26.3. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.25.3...assertj-build-3.26.3) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 73dba466..ac9c5879 100644 --- a/pom.xml +++ b/pom.xml @@ -303,7 +303,7 @@ under the License. org.assertj assertj-core - 3.25.3 + 3.26.3 test From aeba2b62427e4a9fbd05bc1c7e95f57a0bb99e7e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 Aug 2024 15:57:47 +0000 Subject: [PATCH 80/92] Bump org.apache.maven.plugins:maven-plugins from 42 to 43 Bumps [org.apache.maven.plugins:maven-plugins](https://github.com/apache/maven-parent) from 42 to 43. - [Release notes](https://github.com/apache/maven-parent/releases) - [Commits](https://github.com/apache/maven-parent/commits) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-plugins dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 3 ++- src/config/checkstyle-suppressions.xml | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/config/checkstyle-suppressions.xml diff --git a/pom.xml b/pom.xml index ac9c5879..933393f5 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 42 + 43 @@ -334,6 +334,7 @@ under the License. maven-checkstyle-plugin true + src/config/checkstyle-suppressions.xml diff --git a/src/config/checkstyle-suppressions.xml b/src/config/checkstyle-suppressions.xml new file mode 100644 index 00000000..9409ed9b --- /dev/null +++ b/src/config/checkstyle-suppressions.xml @@ -0,0 +1,25 @@ + + + + + + From 36bcf123d864bdb9fb698f78f7c7524a8d58f6ee Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 19 Feb 2023 18:13:51 +0100 Subject: [PATCH 81/92] [MINVOKER-354] Upgrade to Doxia 2.0.0 Milestone Stack This closes #187 --- pom.xml | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/pom.xml b/pom.xml index 933393f5..843bbbb2 100644 --- a/pom.xml +++ b/pom.xml @@ -63,6 +63,7 @@ under the License. 8 3.6.3 + 1.4.1 org.apache-extras.beanshell bsh 2.0b6 @@ -148,56 +149,32 @@ under the License. org.apache.maven.resolver maven-resolver-api - 1.4.1 + ${resolverVersion} provided org.apache.maven.resolver maven-resolver-util - 1.4.1 + ${resolverVersion} org.apache.maven.reporting maven-reporting-api - 3.1.1 + 4.0.0-M12 org.apache.maven.reporting maven-reporting-impl - 3.2.0 - - - org.codehaus.plexus - plexus-container-default - - - org.apache.maven - maven-artifact - - - org.apache.maven - maven-core - - - org.apache.maven - maven-plugin-api - - + 4.0.0-M15 org.apache.maven.doxia doxia-sink-api - 1.12.0 - - - org.codehaus.plexus - plexus-container-default - - + 2.0.0-M12 @@ -412,6 +389,10 @@ under the License. run-its + + + 3.20.0 + From 843ddcf999cd54ab6360e13d64898943c824bd83 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 1 Jan 2024 22:15:56 +0100 Subject: [PATCH 82/92] [MINVOKER-346] Align report output name --- src/it/invoker-report/verify.bsh | 2 +- .../java/org/apache/maven/plugins/invoker/InvokerReport.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/it/invoker-report/verify.bsh b/src/it/invoker-report/verify.bsh index 3d507db7..d2607dc9 100644 --- a/src/it/invoker-report/verify.bsh +++ b/src/it/invoker-report/verify.bsh @@ -20,7 +20,7 @@ import java.io.*; import java.util.*; -File reportFile = new File( basedir, "target/site/invoker-report.html"); +File reportFile = new File( basedir, "target/site/invoker.html"); passed = true; diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java index b3adabfb..ebc47b3d 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java @@ -95,7 +95,7 @@ public String getDescription(Locale locale) { } public String getOutputName() { - return "invoker-report"; + return "invoker"; } private File[] getReportFiles() { From 3542f383610f5f1ce55ee2e6a9f6e04616c28e9f Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 18 Aug 2024 20:54:19 +0200 Subject: [PATCH 83/92] [maven-release-plugin] prepare release maven-invoker-plugin-3.8.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 843bbbb2..50630216 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.7.1-SNAPSHOT + 3.8.0 maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://github.com/apache/maven-invoker-plugin.git scm:git:https://github.com/apache/maven-invoker-plugin.git - HEAD + maven-invoker-plugin-3.8.0 https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -67,7 +67,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2024-05-22T21:52:51Z + 2024-08-18T18:53:57Z 4.0.22 From 2a2e488b106c352084314245466757f70e15d3da Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sun, 18 Aug 2024 20:54:23 +0200 Subject: [PATCH 84/92] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 50630216..03859cdd 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.8.0 + 3.8.1-SNAPSHOT maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://github.com/apache/maven-invoker-plugin.git scm:git:https://github.com/apache/maven-invoker-plugin.git - maven-invoker-plugin-3.8.0 + HEAD https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -67,7 +67,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2024-08-18T18:53:57Z + 2024-08-18T18:54:23Z 4.0.22 From e28603cf3839b190af4a2744813ced06e2a96c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 19 Aug 2024 01:20:57 +0200 Subject: [PATCH 85/92] use new Reproducible Central badge endpoint --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2faf6ca8..147abdbe 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Contributing to [Apache Maven Invoker Plugin](https://maven.apache.org/plugins/m [![ASF Jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fmaven.apache.org%2Fbadges%2Fasf_jira-MINVOKER.json)][jira] [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license] [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-invoker-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.apache.maven.plugins/maven-invoker-plugin) -[![Reproducible Builds](https://img.shields.io/badge/Reproducible_Builds-ok-green?labelColor=blue)](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/apache/maven/plugins/maven-invoker-plugin/README.md) +[![Reproducible Builds](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/jvm-repo-rebuild/reproducible-central/master/content/org/apache/maven/plugins/maven-invoker-plugin/badge.json)](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/apache/maven/plugins/maven-invoker-plugin/README.md) [![Jenkins Status](https://img.shields.io/jenkins/s/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-invoker-plugin/job/master.svg?)][build] [![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-invoker-plugin/job/master.svg?)][test-results] From a46d0f7d26e692107f5777ec6512ed02d4db3cf0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2024 04:43:45 +0000 Subject: [PATCH 86/92] Bump commons-io:commons-io from 2.16.1 to 2.17.0 Bumps commons-io:commons-io from 2.16.1 to 2.17.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 03859cdd..ee7629f2 100644 --- a/pom.xml +++ b/pom.xml @@ -92,7 +92,7 @@ under the License. commons-io commons-io - 2.16.1 + 2.17.0 org.apache.groovy From 557a85c2d28020751b208f626a02041b6d398d05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:48:46 +0000 Subject: [PATCH 87/92] Bump org.apache.groovy:groovy-bom from 4.0.22 to 4.0.23 Bumps [org.apache.groovy:groovy-bom](https://github.com/apache/groovy) from 4.0.22 to 4.0.23. - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ee7629f2..29cf618b 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ under the License. bsh 2.0b6 2024-08-18T18:54:23Z - 4.0.22 + 4.0.23 From b050650fff111a8d641f640327611946b96f3a59 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 18 Oct 2024 17:55:25 +0200 Subject: [PATCH 88/92] [MINVOKER-371] Upgrade to Doxia 2.0.0 GA Stack This closes #261 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 29cf618b..cab4afb1 100644 --- a/pom.xml +++ b/pom.xml @@ -162,19 +162,19 @@ under the License. org.apache.maven.reporting maven-reporting-api - 4.0.0-M12 + 4.0.0 org.apache.maven.reporting maven-reporting-impl - 4.0.0-M15 + 4.0.0 org.apache.maven.doxia doxia-sink-api - 2.0.0-M12 + 2.0.0 From ff4b44025f3202c5ffe382528e3cde7de8dcf476 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 18 Oct 2024 18:49:11 +0200 Subject: [PATCH 89/92] [maven-release-plugin] prepare release maven-invoker-plugin-3.8.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index cab4afb1..1bd3cd1a 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.8.1-SNAPSHOT + 3.8.1 maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://github.com/apache/maven-invoker-plugin.git scm:git:https://github.com/apache/maven-invoker-plugin.git - HEAD + maven-invoker-plugin-3.8.1 https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -67,7 +67,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2024-08-18T18:54:23Z + 2024-10-18T16:48:48Z 4.0.23 From 4fd53223b46f0ff2add4feb51b3103bcc2a5595b Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Fri, 18 Oct 2024 18:49:16 +0200 Subject: [PATCH 90/92] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 1bd3cd1a..58c8ee20 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-invoker-plugin - 3.8.1 + 3.8.2-SNAPSHOT maven-plugin Apache Maven Invoker Plugin @@ -42,7 +42,7 @@ under the License. scm:git:https://github.com/apache/maven-invoker-plugin.git scm:git:https://github.com/apache/maven-invoker-plugin.git - maven-invoker-plugin-3.8.1 + HEAD https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} @@ -67,7 +67,7 @@ under the License. org.apache-extras.beanshell bsh 2.0b6 - 2024-10-18T16:48:48Z + 2024-10-18T16:49:15Z 4.0.23 From 30731f1a568f67b969e340aeaa22ce2d2500cda9 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 17 Nov 2024 14:56:17 +0100 Subject: [PATCH 91/92] [MINVOKER-373] Switch to Doxia 2 --- pom.xml | 11 +++++------ src/it/script-classpath-duplicates/pom.xml | 2 +- src/site/apt/groovy-version.apt.vm | 8 ++++---- src/site/site.xml | 6 +++--- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 58c8ee20..6ee4640c 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,10 @@ under the License. bsh 2.0b6 2024-10-18T16:49:15Z - 4.0.23 + 4.0.23 + + 3.21.0 + 2.0.0 @@ -97,7 +100,7 @@ under the License. org.apache.groovy groovy-bom - ${groovy-version} + ${groovyVersion} pom import @@ -389,10 +392,6 @@ under the License. run-its - - - 3.20.0 - diff --git a/src/it/script-classpath-duplicates/pom.xml b/src/it/script-classpath-duplicates/pom.xml index 589db482..04b3a6d0 100644 --- a/src/it/script-classpath-duplicates/pom.xml +++ b/src/it/script-classpath-duplicates/pom.xml @@ -43,7 +43,7 @@ under the License. org.apache.groovy groovy - @groovy-version@ + @groovyVersion@ pom test diff --git a/src/site/apt/groovy-version.apt.vm b/src/site/apt/groovy-version.apt.vm index 76a1aad6..959886c6 100644 --- a/src/site/apt/groovy-version.apt.vm +++ b/src/site/apt/groovy-version.apt.vm @@ -33,11 +33,11 @@ Groovy version and extensions Plugin <<>> in version <<<3.4.0>>> has only dependency on <<>> core add common extensions: - * <<>> + * <<>> - * <<>> + * <<>> - * <<>> + * <<>> [] @@ -56,7 +56,7 @@ Groovy version and extensions org.apache.groovy groovy-yaml - ${groovy-version} + ${groovyVersion} diff --git a/src/site/site.xml b/src/site/site.xml index a0932f76..89bcd9ef 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -19,8 +19,8 @@ specific language governing permissions and limitations under the License. --> - +

@@ -56,4 +56,4 @@ under the License. -
+ From 6ab7d6ed54690543817ff9f9a3b1bbb2837e0323 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 27 Nov 2024 17:21:12 +0100 Subject: [PATCH 92/92] Ability to skip project collection --- .../plugins/invoker/AbstractInvokerMojo.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java index 5644fe2a..4dfac9de 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java +++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -217,6 +217,9 @@ public abstract class AbstractInvokerMojo extends AbstractMojo { @Parameter(defaultValue = "true") private boolean cloneClean; + @Parameter + private List collectedProjects; + /** * A single POM to build, skipping any scanning parameters and behavior. * @@ -802,11 +805,6 @@ public void execute() throws MojoExecutionException, MojoFailureException { handleScriptRunnerWithScriptClassPath(); - Collection collectedProjects = new LinkedHashSet<>(); - for (BuildJob buildJob : buildJobs) { - collectProjects(projectsDirectory, buildJob.getProject(), collectedProjects, true); - } - File projectsDir = projectsDirectory; if (cloneProjectsTo == null && "maven-plugin".equals(project.getPackaging())) { @@ -826,6 +824,13 @@ public void execute() throws MojoExecutionException, MojoFailureException { } if (cloneProjectsTo != null) { + Collection collectedProjects = this.collectedProjects; + if (collectedProjects == null) { + collectedProjects = new LinkedHashSet<>(); + for (BuildJob buildJob : buildJobs) { + collectProjects(projectsDirectory, buildJob.getProject(), collectedProjects, true); + } + } cloneProjects(collectedProjects); addMissingDotMvnDirectory(cloneProjectsTo, buildJobs); projectsDir = cloneProjectsTo; @@ -1088,7 +1093,7 @@ private boolean isNotEmpty(String s) { * * @param projectPaths The paths to the projects to clone, relative to the projects directory, must not be * null nor contain null elements. - * @throws org.apache.maven.plugin.MojoExecutionException If the the projects could not be copied/filtered. + * @throws org.apache.maven.plugin.MojoExecutionException If the projects could not be copied/filtered. */ private void cloneProjects(Collection projectPaths) throws MojoExecutionException { if (!cloneProjectsTo.mkdirs() && cloneClean) {