// Path: src/main/java/com/mageddo/commons/MigrationUtils.java
// public final class MigrationUtils {
// 
//   private MigrationUtils() {
//   }
// 
//   public static void migrate(final Environment env) {
//     final Flyway flyway = getFlyway(env);
//     flyway.repair();
//     flyway.migrate();
//   }
// 
//   public static Flyway getFlyway(Environment env) {
//     return Flyway.configure()
//         .locations(getLocations(env))
//         .dataSource(get(env, "datasources.default.jdbc-url"), get(env, "datasources.default.username"),
//             get(env, "datasources.default.password")
//         )
//         .schemas(get(env, "flyway.schema"))
//         .load();
//   }
// 
//   private static String get(Environment env, String k) {
//     return env.get(k, String.class, "");
//   }
// 
//   private static String getLocations(Environment env) {
//     if (ImageInfo.inImageRuntimeCode()) {
//       return String.format("filesystem:%s/%s", getExecutablePath(), get(env, "flyway.locations-image"));
//     }
//     return "classpath:" + get(env, "flyway.locations-java");
//   }
// 
//   private static Path getExecutablePath() {
//     return Paths.get(ProcessProperties.getExecutableName())
//         .getParent();
//   }
// 
// }
// 
// Path: src/main/java/com/mageddo/config/ApplicationContextUtils.java
// public final class ApplicationContextUtils {
// 
//   private static ApplicationContext context;
// 
//   private ApplicationContextUtils() {
//   }
// 
//   public static ApplicationContext context() {
//     return context;
//   }
// 
//   public static void context(ApplicationContext context) {
//     ApplicationContextUtils.context = context;
//   }
// }
// 
// Path: src/main/java/thymeleaf/ThymeleafUtils.java
// public final class ThymeleafUtils {
// 
//   private ThymeleafUtils() {
//   }
// 
//   public static String[] splitTags(String tags) {
//     return tags == null ? null : tags.split(",");
//   }
// 
//   public static String encodePath(String path) {
//     return UrlUtils.encode(path);
//   }
// 
//   public static String createBookmarkUrl(long id, String name) {
//     return SiteMapService.formatUrl(id, name);
//   }
// 
//   public static String analyticsId() {
//     return context().getEnvironment()
//         .get("analytics.id", String.class, "");
//   }
// 
//   public static String headerHtml(){
//     return HtmlEscape.unescapeHtml(context()
//         .getBean(SettingsService.class)
//         .findSetting(Setting.PUBLIC_PAGES_HEADER_HTML.name())
//         .getValue())
//         ;
//   }
// }


import com.mageddo.commons.MigrationUtils;
import com.mageddo.config.ApplicationContextUtils;
import io.micronaut.context.ApplicationContext;
import io.micronaut.runtime.Micronaut;
import io.micronaut.runtime.event.annotation.EventListener;
import io.micronaut.runtime.server.event.ServerStartupEvent;
import nativeimage.Reflection;
import nativeimage.Reflections;
import org.flywaydb.core.internal.logging.javautil.JavaUtilLogCreator;
import thymeleaf.ThymeleafUtils;
import java.lang.reflect.InvocationTargetException;
package com.mageddo;







public class Application {

  public static void main(String[] args) {

    setupProperties();
    setupEnv();

    Micronaut.run(Application.class);

  }

  static void setupEnv() {
    final String osEnvs = System.getenv("MICRONAUT_ENVIRONMENTS");
    final String javaEnvs = System.getProperty("micronaut.environments");
    if (osEnvs == null && javaEnvs == null) {
      System.setProperty("micronaut.environments", "pg");
    }
  }

  static void setupProperties() {
    commonsLoggingFix();
  }

  private static void commonsLoggingFix() {
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
    System.setProperty("org.apache.commons.logging.diagnostics.dest", "STDOUT");
  }

  @EventListener
  public void onStartup(ServerStartupEvent event)
      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    final ApplicationContext ctx = event.getSource()
        .getApplicationContext();
    ApplicationContextUtils.context(ctx);
// Path: src/main/java/com/mageddo/commons/MigrationUtils.java
// public final class MigrationUtils {
// 
//   private MigrationUtils() {
//   }
// 
//   public static void migrate(final Environment env) {
//     final Flyway flyway = getFlyway(env);
//     flyway.repair();
//     flyway.migrate();
//   }
// 
//   public static Flyway getFlyway(Environment env) {
//     return Flyway.configure()
//         .locations(getLocations(env))
//         .dataSource(get(env, "datasources.default.jdbc-url"), get(env, "datasources.default.username"),
//             get(env, "datasources.default.password")
//         )
//         .schemas(get(env, "flyway.schema"))
//         .load();
//   }
// 
//   private static String get(Environment env, String k) {
//     return env.get(k, String.class, "");
//   }
// 
//   private static String getLocations(Environment env) {
//     if (ImageInfo.inImageRuntimeCode()) {
//       return String.format("filesystem:%s/%s", getExecutablePath(), get(env, "flyway.locations-image"));
//     }
//     return "classpath:" + get(env, "flyway.locations-java");
//   }
// 
//   private static Path getExecutablePath() {
//     return Paths.get(ProcessProperties.getExecutableName())
//         .getParent();
//   }
// 
// }
// 
// Path: src/main/java/com/mageddo/config/ApplicationContextUtils.java
// public final class ApplicationContextUtils {
// 
//   private static ApplicationContext context;
// 
//   private ApplicationContextUtils() {
//   }
// 
//   public static ApplicationContext context() {
//     return context;
//   }
// 
//   public static void context(ApplicationContext context) {
//     ApplicationContextUtils.context = context;
//   }
// }
// 
// Path: src/main/java/thymeleaf/ThymeleafUtils.java
// public final class ThymeleafUtils {
// 
//   private ThymeleafUtils() {
//   }
// 
//   public static String[] splitTags(String tags) {
//     return tags == null ? null : tags.split(",");
//   }
// 
//   public static String encodePath(String path) {
//     return UrlUtils.encode(path);
//   }
// 
//   public static String createBookmarkUrl(long id, String name) {
//     return SiteMapService.formatUrl(id, name);
//   }
// 
//   public static String analyticsId() {
//     return context().getEnvironment()
//         .get("analytics.id", String.class, "");
//   }
// 
//   public static String headerHtml(){
//     return HtmlEscape.unescapeHtml(context()
//         .getBean(SettingsService.class)
//         .findSetting(Setting.PUBLIC_PAGES_HEADER_HTML.name())
//         .getValue())
//         ;
//   }
// }


// Path: src/main/java/com/mageddo/Application.java
import com.mageddo.commons.MigrationUtils;
import com.mageddo.config.ApplicationContextUtils;
import io.micronaut.context.ApplicationContext;
import io.micronaut.runtime.Micronaut;
import io.micronaut.runtime.event.annotation.EventListener;
import io.micronaut.runtime.server.event.ServerStartupEvent;
import nativeimage.Reflection;
import nativeimage.Reflections;
import org.flywaydb.core.internal.logging.javautil.JavaUtilLogCreator;
import thymeleaf.ThymeleafUtils;
import java.lang.reflect.InvocationTargetException;

package com.mageddo;







public class Application {

  public static void main(String[] args) {

    setupProperties();
    setupEnv();

    Micronaut.run(Application.class);

  }

  static void setupEnv() {
    final String osEnvs = System.getenv("MICRONAUT_ENVIRONMENTS");
    final String javaEnvs = System.getProperty("micronaut.environments");
    if (osEnvs == null && javaEnvs == null) {
      System.setProperty("micronaut.environments", "pg");
    }
  }

  static void setupProperties() {
    commonsLoggingFix();
  }

  private static void commonsLoggingFix() {
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
    System.setProperty("org.apache.commons.logging.diagnostics.dest", "STDOUT");
  }

  @EventListener
  public void onStartup(ServerStartupEvent event)
      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    final ApplicationContext ctx = event.getSource()
        .getApplicationContext();
    ApplicationContextUtils.context(ctx);
    MigrationUtils.migrate(ctx.getEnvironment());