Im creating a java rest service using spring mvc, gradle and tomcat. I want to create a war from this project to be deployed in tomcat, and I want a jar from all model packages. I managed to create war and it works well. But I don't know to create a jar from my specified classes to be used as a client jar. I know i have to use include('com/a/b/**/model/**') for selecting classes but thats all. This jar i want to be installed in .m2 local repo so it can be used as a dependency for another projects. Below is my build.gradle file:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'maven'
apply from: 'dependencies.gradle'
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
mavenLocal()
}
def tomcatHome = 'E:\\apache-tomcat-7.0.62'
//change the name of war because default it is mywar.1.0.0.war
war.archiveName "mywar.war"
//move the war into tomcat webapps folder
task deployToTomcat(type: Copy) {
from war
into "$tomcatHome/webapps"
}
You should split the module into two modules: the API JAR and the WAR. Depend on the API JAR from the WAR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With