35
35
import org .apache .ivy .plugins .repository .Resource ;
36
36
import org .apache .ivy .plugins .repository .url .URLResource ;
37
37
import org .yaml .snakeyaml .Yaml ;
38
+ import org .yaml .snakeyaml .constructor .SafeConstructor ;
38
39
39
40
import play .Logger ;
40
41
import play .Play ;
@@ -53,15 +54,13 @@ public boolean accept(Resource rsrc) {
53
54
return rsrc .exists () && rsrc .getName ().endsWith (".yml" );
54
55
}
55
56
56
-
57
-
58
57
@ Override
59
58
public ModuleDescriptor parseDescriptor (ParserSettings ps , URL url , Resource rsrc , boolean bln ) throws ParseException , IOException {
60
59
try {
61
60
InputStream srcStream = rsrc .openStream ();
62
61
long lastModified = (rsrc != null ?rsrc .getLastModified ():0L );
63
-
64
- Yaml yaml = new Yaml ();
62
+
63
+ Yaml yaml = new Yaml (new SafeConstructor ( new LoaderOptions ()) );
65
64
Object o = null ;
66
65
67
66
// Try to parse the yaml
@@ -112,7 +111,7 @@ public ModuleDescriptorParser getParser() {
112
111
descriptor .setLastModified (lastModified );
113
112
114
113
boolean transitiveDependencies = get (data , "transitiveDependencies" , boolean .class , true );
115
-
114
+
116
115
List <String > confs = new ArrayList <>();
117
116
if (data .containsKey ("configurations" )) {
118
117
if (data .get ("configurations" ) instanceof List ) {
@@ -121,7 +120,7 @@ public ModuleDescriptorParser getParser() {
121
120
for (Object conf : configurations ) {
122
121
String confName ;
123
122
Map options ;
124
-
123
+
125
124
if (conf instanceof String ) {
126
125
confName = ((String ) conf ).trim ();
127
126
options = new HashMap ();
@@ -135,7 +134,7 @@ public ModuleDescriptorParser getParser() {
135
134
allExcludes &= exclude ;
136
135
confs .add ((exclude ? "!" : "" ) + confName );
137
136
}
138
-
137
+
139
138
if (allExcludes ) {
140
139
confs .add (0 , "*" );
141
140
}
@@ -145,7 +144,7 @@ public ModuleDescriptorParser getParser() {
145
144
} else {
146
145
confs .add ("*" );
147
146
}
148
-
147
+
149
148
if (data .containsKey ("require" )) {
150
149
if (data .get ("require" ) instanceof List ) {
151
150
@@ -304,7 +303,7 @@ public static Set<String> getOrderedModuleList(File file) throws ParseException,
304
303
System .setProperty ("application.path" , Play .applicationPath .getAbsolutePath ());
305
304
return getOrderedModuleList (modules , file );
306
305
}
307
-
306
+
308
307
private static Set <String > getOrderedModuleList (Set <String > modules , File file ) throws ParseException , IOException {
309
308
if (file == null || !file .exists ()) {
310
309
throw new FileNotFoundException ("There was a problem to find the file" );
@@ -317,28 +316,28 @@ private static Set<String> getOrderedModuleList(Set<String> modules, File file)
317
316
DependencyDescriptor [] rules = md .getDependencies ();
318
317
File localModules = Play .getFile ("modules" );
319
318
for (DependencyDescriptor dep : rules ) {
320
- ModuleRevisionId rev = dep .getDependencyRevisionId ();
319
+ ModuleRevisionId rev = dep .getDependencyRevisionId ();
321
320
String moduleName = filterModuleName (rev );
322
-
321
+
323
322
// Check if the module was already load to avoid circular parsing
324
323
if (moduleName != null && !modules .contains (moduleName )) {
325
324
// Add the given module
326
325
modules .add (moduleName );
327
-
328
- // Need to load module dependencies of this given module
326
+
327
+ // Need to load module dependencies of this given module
329
328
File module = new File (localModules , moduleName );
330
- if (module != null && module .isDirectory ()) {
329
+ if (module != null && module .isDirectory ()) {
331
330
File ivyModule = new File (module , "conf/dependencies.yml" );
332
331
if (ivyModule != null && ivyModule .exists ()) {
333
332
getOrderedModuleList (modules , ivyModule );
334
- }
333
+ }
335
334
} else {
336
335
File modulePath = new File (IO .readContentAsString (module ).trim ());
337
336
if (modulePath .exists () && modulePath .isDirectory ()) {
338
337
File ivyModule = new File (modulePath , "conf/dependencies.yml" );
339
338
if (ivyModule != null && ivyModule .exists ()) {
340
339
getOrderedModuleList (modules , ivyModule );
341
- }
340
+ }
342
341
}
343
342
}
344
343
} else if (moduleName == null && rev .getRevision ().equals ("->" )){
@@ -347,8 +346,8 @@ private static Set<String> getOrderedModuleList(Set<String> modules, File file)
347
346
}
348
347
return modules ;
349
348
}
350
-
351
-
349
+
350
+
352
351
private static String filterModuleName (ModuleRevisionId rev ) {
353
352
if (rev != null && !"play" .equals (rev .getName ())) {
354
353
File moduleDir = new File (Play .applicationPath , "modules" );
0 commit comments