File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
main/java/org/gradlex/javamodule/testing/internal
test/groovy/org/gradlex/javamodule/testing/internal Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -67,11 +67,14 @@ static String moduleName(String moduleInfoFileContent) {
67
67
List <String > tokens = Arrays .asList (cleanedLine .split ("\\ s+" ));
68
68
if (moduleKeywordFound && !tokens .isEmpty ()) {
69
69
return tokens .get (0 );
70
- } else if (tokens .indexOf ("module" ) == 0 ) {
71
- moduleKeywordFound = true ;
72
70
}
73
- if (tokens .size () > 1 ) {
74
- return tokens .get (1 );
71
+
72
+ int moduleKeywordIndex = tokens .indexOf ("module" );
73
+ if (moduleKeywordIndex == 0 || moduleKeywordIndex == 1 ) {
74
+ if (tokens .size () > moduleKeywordIndex ) {
75
+ return tokens .get (moduleKeywordIndex + 1 );
76
+ }
77
+ moduleKeywordFound = true ;
75
78
}
76
79
}
77
80
return null ;
Original file line number Diff line number Diff line change @@ -59,4 +59,20 @@ class ModuleInfoParseTest extends Specification {
59
59
expect :
60
60
nameFromFile == ' some.thing'
61
61
}
62
+
63
+ def " finds module name when open keyword is used" () {
64
+ given :
65
+ def nameFromFile = ModuleInfoParser . moduleName('''
66
+ open module /*module some.other*/ some.thing { /* module
67
+ odd comment*/ requires transitive foo.bar.la;
68
+ requires/* weird comment*/ static foo.bar.lo;
69
+ requires /*something to say*/foo.bar.li; /*
70
+ requires only.a.comment
71
+ */
72
+ }
73
+ ''' )
74
+
75
+ expect :
76
+ nameFromFile == ' some.thing'
77
+ }
62
78
}
You can’t perform that action at this time.
0 commit comments