Gradle build JAR with embedded jetty and WAR without it

I’d like to build a project with and without embedded jetty.

The Jar output have to contain the dependency for Jetty and the static main function with the Jetty initialization, and the WAR file output does not include the Jetty, and the class file with the static main method which starts the embedded Jetty.

What is the best way to do this? Should I use multiple project with single source folder? How to do this?