matijan
matijan

Reputation: 21

Play 2.2 start DefaultApplication without plugins

I would like to run some of my periodic jobs in separate process than play web server using DefaultApplication. For example:

public static void main(String[] args) throws OAuthException, IOException {
    File conf = new File(args.length == 0 ? "datamerge" : args[0]);

    Application application = new DefaultApplication(conf,
            DataMerge.class.getClassLoader(), null, Mode.Prod());

    Play.start(application);

    //
    // do something here

    Play.stop();

}

This works ok, but there is a problem. Play 2.2 "web" application needs some plugins, that are registered via play.plugins file. Periodical job itself doesn't need any of these plugins, so I don't want them to be loaded. Since DefaultApplication creates default application, play.plugins is found in classpath and plugins are loaded. How can I disable this?

Most of the plugins are configurable via .conf file, so, in case of running job with DefaultApplication, this configuration is not actually needed. When running job, I pass .conf file via JVM argument, plugins are registered (which I don't want to happen), and immediately one by one complains that configuration is missing...

Is there a workaround to remove plugins from DefaultApplication?

Upvotes: 2

Views: 224

Answers (1)

johanandren
johanandren

Reputation: 11479

Maybe you could create you own version of DefaultApplication but omitting the trait WithDefaultPlugins?

Check out the sources of it and it should be pretty self explanatory. https://github.com/playframework/playframework/blob/master/framework/src/play/src/main/scala/play/api/Application.scala#L402

Upvotes: 2

Related Questions