From e44303cff8dad3443b101283779abcd4d9a4dcee Mon Sep 17 00:00:00 2001 From: Abdelrahman Baz <31491326+BedoMagdi@users.noreply.github.com> Date: Fri, 4 Oct 2024 11:40:38 -0500 Subject: [PATCH] update getTest() to read from a file, if one is provided (#13) --- .../maven/plugin/surefire/SurefirePlugin.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java index 20fba421fd..c534218635 100644 --- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java +++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java @@ -20,6 +20,9 @@ */ import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -686,6 +689,24 @@ public void setReportsDirectory( File reportsDirectory ) @Override public String getTest() { + File f = new File( test ); + if ( f.exists() && !f.isDirectory ( ) ) + { + try + { + List l = Files.readAllLines( f.toPath(), Charset.defaultCharset( ) ); + StringBuilder sb = new StringBuilder( ); + for ( String s : l ) + { + sb.append( s + "," ); + } + String s = sb.toString( ); + return s.substring( 0 , s.length( ) - 1 ); + } + catch ( IOException e ) + { + } + } return test; }