AMWST313
AMWST313

Reputation: 19

Build .jar file instead of .war file

following a DevOps Course using Jenkins - Maven, steps:

what can i do so Package will be with .war file not .jar file. is there a Configuration i can use. so beginner with Java. grateful with any tips.

Tried to change many pom.xml files. Tried to change configs into pom files. Not much still Beginner for Java.

Upvotes: 0

Views: 605

Answers (1)

Atxulo
Atxulo

Reputation: 494

If you want to build a WAR you need two things:

  1. You must have <packaging>war</packaging> in your pom.xml. If nothing has been specified, Maven assumes the packaging type is a jar.
<project>
  ...
  <groupId>com.example.projects</groupId>
  <artifactId>documentedproject</artifactId>
  <packaging>war</packaging>
  1. Your project must follow this structure (unless you configure the plugin to use a different structure, but i guess you aren´t)
 |-- pom.xml
 `-- src
     `-- main
         |-- java
         |   `-- com
         |       `-- example
         |           `-- projects
         |               `-- SampleAction.java
         |-- resources
         |   `-- images
         |       `-- sampleimage.jpg
         `-- webapp
             |-- WEB-INF
             |   `-- web.xml
             |-- index.jsp
             `-- jsp
                 `-- websource.jsp

See https://maven.apache.org/plugins/maven-war-plugin/usage.html for more info.

Upvotes: 1

Related Questions