-
Notifications
You must be signed in to change notification settings - Fork 5
Setting up project structure
AppOps client projects are best built using maven multi module structure.
This page walks you through the steps needed to set it up.
You can use the pom-root archetype or create a simple project ( skip archetype ) and manually change the packaging type to pom. i.e. as in our example its named gims (Great institution management system).
Create a maven module with under the already created parent e.g. gims-ui. Use archetype maven-archetype-webapp or skip archetype and change packaging to war. This creates a J2EE web project structure with a sample page that you can use to test your project setup. Easiest way is to configure a jetty plugin to test running your webapp. This project will be your actual webapp containing all the services on the backend and client code in your webcontent folder.
Jetty plugin sample
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.20.v20161216</version>
<configuration>
<webapp>
<contextPath>/</contextPath>
</webapp>
<webAppSourceDirectory>${project.basedir}/WebContent</webAppSourceDirectory>
<stopWait>10</stopWait>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.29</version>
</dependency>
</dependencies>
<!-- <requestLog implementation="org.mortbay.jetty.NCSARequestLog">
<filename>./target/yyyy_mm_dd.request.log</filename> <retainDays>90</retainDays>
<append>true</append> <extended>false</extended> <logTimeZone>GMT</logTimeZone>
</requestLog> -->
</configuration>
</plugin>
Few other plugins you will need are below in this project i.e. maven compiler plugin / maven war plugin.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
Add all the above to the build > plugin section in your gims-ui web module .
Now its time to configure the project to behave as an appops web server.
For this you will need all the below dependencies to the dependencies section in your pom. [ **Note **- I haven't yet deployed the artifacts on maven central as a single dependency group and work is in progress on it. So if you can help that would be great ]
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.appops</groupId>
<artifactId>appops-infra-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>org.appops</groupId>
<artifactId>appops-infra-tsgenerator</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>4.0</version>
</dependency>