1515import org .gradle .api .provider .Property ;
1616import org .gradle .api .tasks .Input ;
1717import org .gradle .api .tasks .InputFiles ;
18+ import org .gradle .api .tasks .Optional ;
1819import org .gradle .api .tasks .OutputDirectory ;
1920import org .gradle .api .tasks .TaskAction ;
2021import org .objectweb .asm .ClassReader ;
@@ -54,6 +55,10 @@ public GenerateTestBuildInfoTask() {
5455 setDescription (DESCRIPTION );
5556 }
5657
58+ @ Input
59+ @ Optional
60+ public abstract Property <String > getModuleName ();
61+
5762 @ Input
5863 public abstract Property <String > getComponentName ();
5964
@@ -205,7 +210,6 @@ private String extractModuleNameFromJar(File file, JarFile jarFile) throws IOExc
205210 private void extractFromDirectory (File file , Map <String , String > classesToModules ) throws IOException {
206211 String className = extractClassNameFromDirectory (file );
207212 String moduleName = extractModuleNameFromDirectory (file );
208- getLogger ().lifecycle ("DIRECTORY: " + className + " -> " + moduleName );
209213 if (className != null && moduleName != null ) {
210214 classesToModules .put (className , moduleName );
211215 }
@@ -215,7 +219,6 @@ private String extractClassNameFromDirectory(File file) {
215219 List <File > files = new ArrayList <>(List .of (file ));
216220 while (files .isEmpty () == false ) {
217221 File find = files .removeFirst ();
218- getLogger ().lifecycle ("FIND: " + find .getAbsolutePath ());
219222 if (find .exists ()) {
220223 if (find .getName ().endsWith (".class" )
221224 && find .getName ().equals ("module-info.class" ) == false
@@ -234,7 +237,6 @@ private String extractModuleNameFromDirectory(File file) throws IOException {
234237 List <File > files = new ArrayList <>(List .of (file ));
235238 while (files .isEmpty () == false ) {
236239 File find = files .removeFirst ();
237- getLogger ().lifecycle ("FIND: " + find .getAbsolutePath ());
238240 if (find .exists ()) {
239241 if (find .getName ().equals ("module-info.class" )) {
240242 try (InputStream inputStream = new FileInputStream (find )) {
@@ -245,7 +247,7 @@ private String extractModuleNameFromDirectory(File file) throws IOException {
245247 }
246248 }
247249 }
248- return null ;
250+ return getModuleName (). isPresent () ? getModuleName (). get () : null ;
249251 }
250252
251253 private String extractModuleNameFromModuleInfo (InputStream inputStream ) throws IOException {
0 commit comments