The article describes the configuration one would need to create WAR file for an Eclipse-base web application (Dynamic Web) project.
Below code represents whats needed to compile your Java Eclipse-based web application project and create WAR file which can be deployed later, on any Java server such as Tomcat. Pay attention to some of the following facts:
apply plugin: 'java'
apply plugin: 'war'
// Depending upon the fact that one uses default
// WebContent folder to store web resources. Change
// name to name of WebContent folder appropriately.
def webInfPath = "WebContent/WEB-INF"
// Repositories accessed from local directory
repositories {
flatDir { dirs webInfPath + "/" + "lib" }
}
// Source folder defined as Eclipse stores Java source code
// in non-maven based folder structure
sourceSets {
main {
java { srcDir 'src' }
}
}
dependencies {
// Compile time dependencies read from local directory
compile fileTree(dir: webInfPath + "/" + "lib", include: '*.jar')
}
war {
webInf { from webInfPath} // adds a file-set to the WEB-INF dir.
classpath fileTree(webInfPath + "/" + "lib") // adds a file-set to the WEB-INF/lib dir.
webXml = file(webInfPath + "/" + "web.xml") // copies a file to WEB-INF/web.xml
from('WebContent') { include ('bootstrap/css/*.css', 'bootstrap/js/*.js', 'bootstrap/img/*.*') } //Copy Bootstrap folder to WEB-INF level
}
[adsenseyu1]
Last updated: 28th April, 2024 As a data scientist, understanding the nuances of various cost…
Last updated: 28th April, 2024 In this post, you will learn the concepts related to…
Last updated: 26th April, 2024 In this blog post, we will discuss the logistic regression…
Last updated: 22nd April, 2024 As data scientists, we navigate a sea of metrics to…
Last updated: 22nd April, 2024 This post will teach you about the gradient descent algorithm…
Last updated: 19th April, 2024 Among the terminologies used in training machine learning models, the…
View Comments
I have a small problem connected to Gradle and web plugin.
I got spring mvc resources imported to my web project. But after running my web project under Tomcat, it seems that I have no src/main/resources files under my classpath. I was expecting gradle to take care of it, but it seems I have to config war manually. Any hints on this?