210210import com .typesafe .config .Config ;
211211import com .typesafe .config .ConfigFactory ;
212212import static com .typesafe .config .ConfigFactory .empty ;
213- import com .typesafe .config .ConfigValueType ;
214213import static java .util .Objects .requireNonNull ;
215214import org .flywaydb .core .Flyway ;
216215import org .jooby .Env ;
@@ -361,7 +360,7 @@ public Flywaydb() {
361360 @ Override
362361 public void configure (final Env env , final Config conf , final Binder binder ) {
363362 Config $base = flyway (conf .getConfig ("flyway" ));
364- Config $flyway = Try .apply (() -> conf .getConfig (name ).withFallback ($base ))
363+ Config $flyway = Try .apply (() -> flyway ( conf .getConfig (name ) ).withFallback ($base ))
365364 .orElse ($base );
366365
367366 Flyway flyway = new Flyway ();
@@ -377,15 +376,15 @@ public void configure(final Env env, final Config conf, final Binder binder) {
377376 env .serviceKey ()
378377 .generate (Flyway .class , name , key -> binder .bind (key ).toInstance (flyway ));
379378 // commands:
380- Iterable <Command > cmds = commands ($flyway );
379+ Iterable <Command > cmds = commands (conf );
381380
382381 // eager initialization
383382 cmds .forEach (cmd -> cmd .run (flyway ));
384383 }
385384
386- private Config flyway (Config conf ) {
385+ static Config flyway (Config conf ) {
387386 Config flyway = conf .root ().entrySet ().stream ()
388- .filter (it -> it .getValue (). valueType () != ConfigValueType . OBJECT )
387+ .filter (it -> isFlywayProperty ( it .getKey ()) )
389388 .reduce (empty (), (seed , entry ) -> seed .withValue (entry .getKey (), entry .getValue ()),
390389 Config ::withFallback );
391390 return flyway ;
@@ -404,10 +403,7 @@ private static Properties props(final Config config) {
404403 if (value instanceof List ) {
405404 value = ((List ) value ).stream ().collect (Collectors .joining ("," ));
406405 }
407- String propertyName = prop .getKey ();
408- if (isFlywayProperty (propertyName )) {
409- props .setProperty ("flyway." + prop .getKey (), value .toString ());
410- }
406+ props .setProperty ("flyway." + prop .getKey (), value .toString ());
411407 });
412408 return props ;
413409 }
@@ -428,7 +424,7 @@ static boolean isFlywayProperty(String name) {
428424
429425 @ SuppressWarnings ("unchecked" )
430426 private static Iterable <Command > commands (final Config config ) {
431- Object value = config .getAnyRef ("run" );
427+ Object value = config .getAnyRef ("flyway. run" );
432428 List <String > commands = new ArrayList <>();
433429 if (value instanceof List ) {
434430 commands .addAll ((List <? extends String >) value );
0 commit comments