Commit bffea8e4 authored by Administrator's avatar Administrator

Adds auto-redeploy execution with independent backend and frontend

The POM and other configuration files have been updated to support a new
execution mode where Cargo is used to execute the backend and NPM to
execute the frontend, both in auto-redeploy mode.
parent 86dcfc66
......@@ -9,7 +9,7 @@ Ingeniería Informática de la Universidad de Vigo.
La configuración de Maven ha sido preparada para permitir varios tipos de
ejecución.
### Ejecución de la aplicación con Tomcat y MySQL
### Ejecución
El proyecto está configurado para poder ejecutar la aplicación sin tener que
realizar ninguna configuración adicional salvo tener disponible un servidor
......@@ -26,24 +26,40 @@ comandos (desde la raíz el proyecto):
Una vez configurada la base de datos podemos lanzar la ejecución con el comando:
`mvn -Prun-tomcat-mysql -DskipTests=true package cargo:run`
`mvn -Prun package cargo:run`
La aplicación se servirá en la URL local: http://localhost:9080/DAAExample
Para detener la ejecución podemos utilizar `Ctrl+C`.
### Ejecución de la aplicación con Tomcat y MySQL con redespliegue automático
### Ejecución con redespliegue automático
Durante el desarrollo es interesante que la apliación se redespliegue de forma
automática cada vez que se hace un cambio. Para ello podemos utilizar el
siguiente comand:
`mvn -Prun-tomcat-mysql -DskipTests=true package cargo:start fizzed-watcher:run`
`mvn -Prun package cargo:start fizzed-watcher:run`
La aplicación se servirá en la URL local: http://localhost:9080/DAAExample
Para detener la ejecución podemos utilizar `Ctrl+C`.
### Ejecución con redespliegue automático independiente para backend y frontend (recomendado)
A diferencia del modo de redespliegue automático anterior, en este caso
*backend* y *frontend* se ejecutarán de forma independiente. Esto hace que los
cambios en las clases Java harán que se redespliegue el *backend*, mientras que
los cambios en Angular harán que se redespliegue el *frontend*.
`mvn -Prun-independent-autoredeploy exec:exec@npm-build exec:exec@npm-start package cargo:start fizzed-watcher:run`
La aplicación se servirá en local:
* **Backend**: http://localhost:9080/DAAExample
* **Frontend**: http://localhost:4200
Para detener la ejecución podemos utilizar `Ctrl+C`.
### Construcción con tests de unidad e integración
En esta construcción se ejecutarán todos los tests relacionados con el backend:
......
......@@ -24,6 +24,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.servers.directory>${project.basedir}/servers</project.servers.directory>
<cargo.tomcat.start.skip>false</cargo.tomcat.start.skip>
<skip-npm-build>false</skip-npm-build>
<cargo.tomcat.run.skip>true</cargo.tomcat.run.skip>
<tomcat.version>8.5.27</tomcat.version>
<jacoco.port>6300</jacoco.port>
......@@ -201,7 +202,6 @@
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
......@@ -247,6 +247,7 @@
<id>exec-npm-ng-build</id>
<phase>generate-sources</phase>
<configuration>
<skip>${skip-npm-build}</skip>
<workingDirectory>${project.basedir}/src/main/angular</workingDirectory>
<executable>npm</executable>
<arguments>
......@@ -360,6 +361,7 @@
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
......@@ -597,11 +599,12 @@
</profile>
<profile>
<id>run-tomcat-mysql</id>
<id>run</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<skipTests>true</skipTests>
<skip-npm-install>true</skip-npm-install>
</properties>
......@@ -674,6 +677,119 @@
</build>
</profile>
<profile>
<id>run-independent-autoredeploy</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<skipTests>true</skipTests>
<skip-npm-install>true</skip-npm-install>
<skip-npm-build>true</skip-npm-build>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<configuration>
<workingDirectory>${project.basedir}/src/main/angular</workingDirectory>
<executable>npm</executable>
<goal>exec</goal>
</configuration>
<executions>
<execution>
<id>npm-build</id>
<configuration>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>npm-start</id>
<configuration>
<async>true</async>
<asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
<arguments>
<argument>start</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.fizzed</groupId>
<artifactId>fizzed-watcher-maven-plugin</artifactId>
<version>${fizzed-watcher-maven-plugin.version}</version>
<configuration>
<skipTouch>true</skipTouch>
<watches>
<watch>
<directory>src/main</directory>
<exclude>src/main/angular</exclude>
</watch>
</watches>
<goals>
<goal>package</goal>
<goal>cargo:redeploy</goal>
</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>${cargo-maven2-plugin.version}</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<zipUrlInstaller>
<url>https://repo1.maven.org/maven2/org/apache/tomcat/tomcat/${tomcat.version}/tomcat-${tomcat.version}.zip</url>
<downloadDir>${project.servers.directory}/downloads</downloadDir>
<extractDir>${project.servers.directory}/extracts</extractDir>
</zipUrlInstaller>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
</container>
<configuration>
<home>${project.build.directory}/catalina-base</home>
<files>
<copy>
<file>tomcat/server.mysql.xml</file>
<tofile>conf/server.xml</tofile>
</copy>
</files>
<properties>
<cargo.servlet.port>9080</cargo.servlet.port>
<cargo.datasource.datasource.h2>
cargo.datasource.jndi=jdbc/daaexample|
cargo.datasource.driver=com.mysql.jdbc.Driver|
cargo.datasource.url=jdbc:mysql://localhost/daaexample|
cargo.datasource.username=daa|
cargo.datasource.password=daa|
cargo.datasource.maxActive=8|
cargo.datasource.maxIdle=4|
cargo.datasource.maxWait=10000
</cargo.datasource.datasource.h2>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>geckodriver-download-unix</id>
<activation>
......
{
"name": "daa-example",
"version": "0.2.0-alpha.6",
"version": "0.2.0-alpha.7",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "daa-example",
"version": "0.2.0-alpha.6",
"version": "0.2.0-alpha.7",
"scripts": {
"ng": "./node_modules/.bin/ng",
"start": "./node_modules/.bin/ng serve",
......
......@@ -9,7 +9,7 @@
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
......@@ -17,6 +17,14 @@
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Authorization</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET, POST, DELETE, PUT</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
......@@ -31,7 +39,6 @@
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>OPTIONS</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
......@@ -43,11 +50,10 @@
<web-resource-collection>
<web-resource-name>Admin Area</web-resource-name>
<url-pattern>/rest/people/*</url-pattern>
<http-method>GET</http-method>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>OPTIONS</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment