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]
In recent years, artificial intelligence (AI) has evolved to include more sophisticated and capable agents,…
Adaptive learning helps in tailoring learning experiences to fit the unique needs of each student.…
With the increasing demand for more powerful machine learning (ML) systems that can handle diverse…
Anxiety is a common mental health condition that affects millions of people around the world.…
In machine learning, confounder features or variables can significantly affect the accuracy and validity of…
Last updated: 26 Sept, 2024 Credit card fraud detection is a major concern for credit…
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?