lmazgon
lmazgon

Reputation: 1254

Package project as jar into war project (Gradle)

I have a Gradle project which consists of 3 modules:

I don't want to manually add the plugin to the classpath of project-web every time I make a WAR, so I would like to extend the WAR task and create a "warWithPlugin" task, which adds the plugin jar to the libs folder as well.

Obviously I can't add project-plugin as a dependency, because I get a circular dependency. What other options do I have to package the plugin jar into the WAR?

Upvotes: 3

Views: 1351

Answers (1)

Mark Vieira
Mark Vieira

Reputation: 13466

Sure, you can just create a new configuration with project-plugin as a dependency then add that configuration to your WEB-INF/lib directory.

configurations {
    plugin
}

dependencies {
    plugin project(':plugin')
}

war {
    into('WEB-INF/lib') {
        duplicatesStrategy 'exclude'
        from configurations.plugin
    }
}

Upvotes: 1

Related Questions