|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: "Deployment" |
| 4 | +category: doc |
| 5 | +date: 2016-08-08 09:46:53 |
| 6 | +order: 201 |
| 7 | +--- |
| 8 | + |
| 9 | +### Packaging |
| 10 | + |
| 11 | +The recommended way to deploy Pippo applications is as a normal executable application with an embedded web server. |
| 12 | + |
| 13 | +In order to create a .zip file consisting of your application and its dependencies, complete the following steps: |
| 14 | + |
| 15 | +* Create a `src/main/assembly/assembly.xml` file with the following content: |
| 16 | + |
| 17 | +```xml |
| 18 | +<assembly> |
| 19 | + <id>app</id> |
| 20 | + <formats> |
| 21 | + <format>zip</format> |
| 22 | + </formats> |
| 23 | + <includeBaseDirectory>false</includeBaseDirectory> |
| 24 | + <dependencySets> |
| 25 | + <dependencySet> |
| 26 | + <useProjectArtifact>false</useProjectArtifact> |
| 27 | + <scope>runtime</scope> |
| 28 | + <outputDirectory>lib</outputDirectory> |
| 29 | + <includes> |
| 30 | + <include>*:jar:*</include> |
| 31 | + </includes> |
| 32 | + </dependencySet> |
| 33 | + </dependencySets> |
| 34 | + <fileSets> |
| 35 | + <fileSet> |
| 36 | + <directory>${project.build.directory}</directory> |
| 37 | + <outputDirectory>.</outputDirectory> |
| 38 | + <includes> |
| 39 | + <include>*.jar</include> |
| 40 | + </includes> |
| 41 | + <excludes> |
| 42 | + <exclude>*-javadoc.jar</exclude> |
| 43 | + <exclude>*-sources.jar</exclude> |
| 44 | + </excludes> |
| 45 | + </fileSet> |
| 46 | + </fileSets> |
| 47 | +</assembly> |
| 48 | +``` |
| 49 | + |
| 50 | +* Add the following to your `pom.xml` file: |
| 51 | + |
| 52 | +```xml |
| 53 | +<build> |
| 54 | + <plugins> |
| 55 | + <plugin> |
| 56 | + <artifactId>maven-assembly-plugin</artifactId> |
| 57 | + <version>2.3</version> |
| 58 | + <configuration> |
| 59 | + <descriptors> |
| 60 | + <descriptor>src/main/assembly/assembly.xml</descriptor> |
| 61 | + </descriptors> |
| 62 | + <appendAssemblyId>false</appendAssemblyId> |
| 63 | + </configuration> |
| 64 | + <executions> |
| 65 | + <execution> |
| 66 | + <id>make-assembly</id> |
| 67 | + <phase>package</phase> |
| 68 | + <goals> |
| 69 | + <goal>attached</goal> |
| 70 | + </goals> |
| 71 | + </execution> |
| 72 | + </executions> |
| 73 | + </plugin> |
| 74 | + <plugin> |
| 75 | + <groupId>org.apache.maven.plugins</groupId> |
| 76 | + <artifactId>maven-jar-plugin</artifactId> |
| 77 | + <version>2.3.1</version> |
| 78 | + <configuration> |
| 79 | + <archive> |
| 80 | + <manifest> |
| 81 | + <addClasspath>true</addClasspath> |
| 82 | + <classpathPrefix>lib/</classpathPrefix> |
| 83 | + <mainClass>${main.class}</mainClass> |
| 84 | + </manifest> |
| 85 | + </archive> |
| 86 | + </configuration> |
| 87 | + </plugin> |
| 88 | + </plugins> |
| 89 | +</build> |
| 90 | +``` |
| 91 | + |
| 92 | +* Add `<main.class>com.path.to.your.MainClass</main.class>` to the `properties` element in your `pom.xml`, replacing the given path with one for the file containing your main method |
| 93 | + |
| 94 | +* Execute `mvn clean package` and view your packaged application at `target/yourappname-#.#.#.zip` |
| 95 | + |
| 96 | +### Deployment |
| 97 | + |
| 98 | +* Transfer the .zip file to your server |
| 99 | +* Unzip it |
| 100 | +* Execute `java -jar yourappname-#.#.#.jar` |
| 101 | + |
| 102 | +### Snapshot Workaround |
| 103 | + |
| 104 | +If you are using a SNAPSHOT version of Pippo as described in the [Maven section](../dev/maven.html), a small workaround is necessary due to a Maven bug: |
| 105 | + |
| 106 | +* Add `<outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>` to the `dependencySet` element inside `assembly.xml` |
| 107 | + |
| 108 | +* Add `<useUniqueVersions>false</useUniqueVersions>` to the maven-jar-plugin's `manifest` section inside `pom.xml` |
| 109 | + |
| 110 | + |
0 commit comments