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