This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new e4236a7  [MINVOKER-286] Remove unused code corresponding to goals.txt, 
profiles.txt
e4236a7 is described below

commit e4236a7b489bae2595f9209be74a074813120549
Author: Slawomir Jaranowski <s.jaranow...@gmail.com>
AuthorDate: Wed Dec 1 20:48:26 2021 +0100

    [MINVOKER-286] Remove unused code corresponding to goals.txt, profiles.txt
---
 .../maven/plugins/invoker/AbstractInvokerMojo.java | 148 ---------------------
 src/site/apt/examples/filtering.apt.vm             |   2 -
 .../maven/plugins/invoker/InterpolationTest.java   |  18 ---
 .../maven/plugins/invoker/InvokerMojoTest.java     |  14 +-
 src/test/resources/unit/goals-from-file/verify.bsh |  48 -------
 .../unit/profiles-from-file/emptyProfiles.txt      |   0
 .../resources/unit/profiles-from-file/profiles.txt |   1 -
 .../pom.xml                                        |   0
 .../pom.xml => without-pom-project-dir/mark.txt}   |  10 --
 9 files changed, 7 insertions(+), 234 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 fc2d7b8..2228acf 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
@@ -72,7 +72,6 @@ import org.codehaus.plexus.util.cli.StreamConsumer;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.Xpp3DomWriter;
 
-import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileInputStream;
@@ -102,7 +101,6 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
-import java.util.StringTokenizer;
 import java.util.TreeSet;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -959,26 +957,6 @@ public abstract class AbstractInvokerMojo
         throws MojoFailureException;
 
     /**
-     * Creates a new reader for the specified file, using the plugin's {@link 
#encoding} parameter.
-     *
-     * @param file The file to create a reader for, must not be 
<code>null</code>.
-     * @return The reader for the file, never <code>null</code>.
-     * @throws java.io.IOException If the specified file was not found or the 
configured encoding is not supported.
-     */
-    private Reader newReader( File file )
-        throws IOException
-    {
-        if ( StringUtils.isNotEmpty( encoding ) )
-        {
-            return ReaderFactory.newReader( file, encoding );
-        }
-        else
-        {
-            return ReaderFactory.newPlatformReader( file );
-        }
-    }
-
-    /**
      * Collects all projects locally reachable from the specified project. The 
method will as such try to read the POM
      * and recursively follow its parent/module elements.
      *
@@ -2018,10 +1996,6 @@ public abstract class AbstractInvokerMojo
             }
         }
 
-        List<String> goals = getGoals( basedir );
-
-        List<String> profiles = getProfiles( basedir );
-
         Map<String, Object> context = new LinkedHashMap<>();
 
         boolean selectorResult = true;
@@ -2354,48 +2328,6 @@ public abstract class AbstractInvokerMojo
         }
     }
 
-    /**
-     * Gets the goal list for the specified project.
-     *
-     * @param basedir The base directory of the project, must not be 
<code>null</code>.
-     * @return The list of goals to run when building the project, may be 
empty but never <code>null</code>.
-     * @throws org.apache.maven.plugin.MojoExecutionException If the profile 
file could not be read.
-     */
-    List<String> getGoals( final File basedir )
-        throws MojoExecutionException
-    {
-        try
-        {
-            // FIXME: Currently we have null for goalsFile which has been 
removed.
-            // This might mean we can remove getGoals() at all ? Check this.
-            return getTokens( basedir, null, goals );
-        }
-        catch ( IOException e )
-        {
-            throw new MojoExecutionException( "error reading goals", e );
-        }
-    }
-
-    /**
-     * Gets the profile list for the specified project.
-     *
-     * @param basedir The base directory of the project, must not be 
<code>null</code>.
-     * @return The list of profiles to activate when building the project, may 
be empty but never <code>null</code>.
-     * @throws org.apache.maven.plugin.MojoExecutionException If the profile 
file could not be read.
-     */
-    List<String> getProfiles( File basedir )
-        throws MojoExecutionException
-    {
-        try
-        {
-            return getTokens( basedir, null, profiles );
-        }
-        catch ( IOException e )
-        {
-            throw new MojoExecutionException( "error reading profiles", e );
-        }
-    }
-
     private List<String> calculateIncludes()
     {
         if ( invokerTest != null )
@@ -2672,86 +2604,6 @@ public abstract class AbstractInvokerMojo
     }
 
     /**
-     * Gets goal/profile names for the specified project, either directly from 
the plugin configuration or from an
-     * external token file.
-     *
-     * @param basedir The base directory of the test project, must not be 
<code>null</code>.
-     * @param filename The (simple) name of an optional file in the project 
base directory from which to read
-     *            goals/profiles, may be <code>null</code>.
-     * @param defaultTokens The list of tokens to return in case the specified 
token file does not exist, may be
-     *            <code>null</code>.
-     * @return The list of goal/profile names, may be empty but never 
<code>null</code>.
-     * @throws java.io.IOException If the token file exists but could not be 
parsed.
-     */
-    private List<String> getTokens( File basedir, String filename, 
List<String> defaultTokens )
-        throws IOException
-    {
-        List<String> tokens = ( defaultTokens != null ) ? defaultTokens : new 
ArrayList<String>();
-
-        if ( StringUtils.isNotEmpty( filename ) )
-        {
-            File tokenFile = new File( basedir, filename );
-
-            if ( tokenFile.exists() )
-            {
-                tokens = readTokens( tokenFile );
-            }
-        }
-
-        return tokens;
-    }
-
-    /**
-     * Reads the tokens from the specified file. Tokens are separated either 
by line terminators or commas. During
-     * parsing, the file contents will be interpolated.
-     *
-     * @param tokenFile The file to read the tokens from, must not be 
<code>null</code>.
-     * @return The list of tokens, may be empty but never <code>null</code>.
-     * @throws java.io.IOException If the token file could not be read.
-     */
-    private List<String> readTokens( final File tokenFile )
-        throws IOException
-    {
-        List<String> result = new ArrayList<>();
-
-        Map<String, Object> composite = getInterpolationValueSource( false );
-
-        try ( BufferedReader reader =
-            new BufferedReader( new InterpolationFilterReader( newReader( 
tokenFile ), composite ) ) )
-        {
-            for ( String line = reader.readLine(); line != null; line = 
reader.readLine() )
-            {
-                result.addAll( collectListFromCSV( line ) );
-            }
-        }
-
-        return result;
-    }
-
-    /**
-     * Gets a list of comma separated tokens from the specified line.
-     *
-     * @param csv The line with comma separated tokens, may be 
<code>null</code>.
-     * @return The list of tokens from the line, may be empty but never 
<code>null</code>.
-     */
-    private List<String> collectListFromCSV( final String csv )
-    {
-        final List<String> result = new ArrayList<>();
-
-        if ( ( csv != null ) && ( csv.trim().length() > 0 ) )
-        {
-            final StringTokenizer st = new StringTokenizer( csv, "," );
-
-            while ( st.hasMoreTokens() )
-            {
-                result.add( st.nextToken().trim() );
-            }
-        }
-
-        return result;
-    }
-
-    /**
      * Interpolates the specified POM/settings file to a temporary file. The 
destination file may be same as the input
      * file, i.e. interpolation can be performed in-place.
      * <p>
diff --git a/src/site/apt/examples/filtering.apt.vm 
b/src/site/apt/examples/filtering.apt.vm
index 0f5c09e..7a98acb 100644
--- a/src/site/apt/examples/filtering.apt.vm
+++ b/src/site/apt/examples/filtering.apt.vm
@@ -58,8 +58,6 @@ Filtering Files
          |  +- pom.xml                 <- Filtered
          +- pom.xml                    <- Filtered
          +- invoker.properties         <- Filtered
-         +- goals.txt                  <- Filtered
-         +- profiles.txt               <- Filtered
 +------------------
 
   Below is the corresponding POM snippet for the plugin configuration:
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 cd75a75..8f96fb9 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java
@@ -21,8 +21,6 @@ package org.apache.maven.plugins.invoker;
 
 import java.io.File;
 import java.io.Reader;
-import java.util.Collections;
-import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -57,7 +55,6 @@ public class InterpolationTest
     }
 
     public void testCompositeMap()
-        throws Exception
     {
 
         Properties properties = new Properties();
@@ -108,19 +105,4 @@ public class InterpolationTest
             IOUtil.close( reader );
         }
     }
-
-    public void testProfilesWithNoFile()
-        throws Exception
-    {
-
-        InvokerMojo invokerMojo = new InvokerMojo();
-        setVariableValueToObject( invokerMojo, "profiles", 
Collections.singletonList( "zloug" ) );
-        setVariableValueToObject( invokerMojo, "settings", new Settings() );
-        String dirPath = getBasedir() + File.separatorChar + "src" + 
File.separatorChar + "test" + File.separatorChar
-            + "resources" + File.separatorChar + "unit" + File.separatorChar + 
"profiles-from-file";
-        List<String> profiles = invokerMojo.getProfiles( new File( dirPath ) );
-        assertTrue( profiles.contains( "zloug" ) );
-        assertEquals( 1, profiles.size() );
-
-    }
 }
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 94f69f4..b1f704b 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java
@@ -38,9 +38,9 @@ public class InvokerMojoTest extends AbstractMojoTestCase
 {
 
     private static final String DUMMY_PROJECT = "dummy" + File.separator + 
"pom.xml";
-    private static final String GOALS_FROM_FILE_PROJECT = "goals-from-file" + 
File.separator + "pom.xml";
+    private static final String WITH_POM_DIR_PROJECT = "with-pom-project-dir" 
+ File.separator + "pom.xml";
     private static final String INTERPOLATION_PROJECT = "interpolation" + 
File.separator + "pom.xml";
-    private static final String PROFILES_FROM_FILE_PROJECT = 
"profiles-from-file";
+    private static final String WITHOUT_POM_PROJECT = 
"without-pom-project-dir";
 
     private MavenProject getMavenProject()
     {
@@ -107,8 +107,8 @@ public class InvokerMojoTest extends AbstractMojoTestCase
         assertThat( jobs )
                 .map( BuildJob::getProject )
                 .containsExactlyInAnyOrder(
-                        DUMMY_PROJECT, GOALS_FROM_FILE_PROJECT,
-                        INTERPOLATION_PROJECT, PROFILES_FROM_FILE_PROJECT );
+                        DUMMY_PROJECT, WITH_POM_DIR_PROJECT, 
WITHOUT_POM_PROJECT,
+                        INTERPOLATION_PROJECT );
     }
 
     public void testSetupInProjectList() throws Exception
@@ -131,7 +131,7 @@ public class InvokerMojoTest extends AbstractMojoTestCase
         assertThat( jobs )
                 .map( BuildJob::getProject )
                 .containsExactlyInAnyOrder(
-                        DUMMY_PROJECT, GOALS_FROM_FILE_PROJECT, 
INTERPOLATION_PROJECT );
+                        DUMMY_PROJECT, WITH_POM_DIR_PROJECT, 
INTERPOLATION_PROJECT );
 
         // and we have one setup project
         assertThat( jobs )
@@ -150,7 +150,7 @@ public class InvokerMojoTest extends AbstractMojoTestCase
         setVariableValueToObject( invokerMojo, "project", getMavenProject() );
         setVariableValueToObject( invokerMojo, "settings", new Settings() );
         setVariableValueToObject( invokerMojo, "setupIncludes", 
Collections.singletonList( "dum*/pom.xml" ) );
-        setVariableValueToObject( invokerMojo, "invokerTest", "*from-file*" );
+        setVariableValueToObject( invokerMojo, "invokerTest", "*project-dir*" 
);
 
 
         // when
@@ -162,7 +162,7 @@ public class InvokerMojoTest extends AbstractMojoTestCase
         assertThat( jobs )
                 .map( BuildJob::getProject )
                 .containsExactlyInAnyOrder(
-                        GOALS_FROM_FILE_PROJECT, PROFILES_FROM_FILE_PROJECT );
+                        WITH_POM_DIR_PROJECT, WITHOUT_POM_PROJECT );
 
         // and we don't have a setup project
         assertThat( jobs )
diff --git a/src/test/resources/unit/goals-from-file/verify.bsh 
b/src/test/resources/unit/goals-from-file/verify.bsh
deleted file mode 100644
index cdd4e7e..0000000
--- a/src/test/resources/unit/goals-from-file/verify.bsh
+++ /dev/null
@@ -1,48 +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.
- */
-
-import java.io.*;
-import org.codehaus.plexus.util.*;
-
-boolean result = true;
-
-try
-{
-    
-    File build = new File( basedir, "build.log" );
-    if ( !build.exists() || build.isDirectory() )
-    {
-        System.err.println( "build.log file is missing or a directory." );
-        return false;
-    }    
-    String buildContent = FileUtils.fileRead( build );
-    int indexOf = buildContent.indexOf( "BUILD SUCCESSFUL" );
-    if ( indexOf < 0 )
-    {
-       System.err.println( "build.log doesn't contains BUILD SUCCESSFUL" );
-    }    
-}
-catch( IOException e )
-{
-    e.printStackTrace();
-    result = false;
-}
-
-return result;
diff --git a/src/test/resources/unit/profiles-from-file/emptyProfiles.txt 
b/src/test/resources/unit/profiles-from-file/emptyProfiles.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/src/test/resources/unit/profiles-from-file/profiles.txt 
b/src/test/resources/unit/profiles-from-file/profiles.txt
deleted file mode 100644
index f33f47f..0000000
--- a/src/test/resources/unit/profiles-from-file/profiles.txt
+++ /dev/null
@@ -1 +0,0 @@
-foo, bar
diff --git a/src/test/resources/unit/goals-from-file/pom.xml 
b/src/test/resources/unit/with-pom-project-dir/pom.xml
similarity index 100%
copy from src/test/resources/unit/goals-from-file/pom.xml
copy to src/test/resources/unit/with-pom-project-dir/pom.xml
diff --git a/src/test/resources/unit/goals-from-file/pom.xml 
b/src/test/resources/unit/without-pom-project-dir/mark.txt
similarity index 63%
rename from src/test/resources/unit/goals-from-file/pom.xml
rename to src/test/resources/unit/without-pom-project-dir/mark.txt
index fc80363..60b675e 100644
--- a/src/test/resources/unit/goals-from-file/pom.xml
+++ b/src/test/resources/unit/without-pom-project-dir/mark.txt
@@ -1,5 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
 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
@@ -16,11 +14,3 @@ software distributed under the License is distributed on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.apache.maven.test</groupId>
-  <artifactId>unit</artifactId>
-  <packaging>pom</packaging>
-  <version>0.1-SNAPSHOT</version>
-</project>
\ No newline at end of file

Reply via email to