Commit e922d689 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Created installation scripts, removed hardcoded configuration

parent ee235930
Pipeline #100 passed with stage
in 29 seconds
/TASMAN-webapp/nb-configuration.xml
/TASMAN-webapp/nbactions.xml
/TASMAN-webapp/faces-config.NavData
/TASMAN-core/target/
/TASMAN-webapp/target/
/TASMAN-core/nb-configuration.xml
/TASMAN-embedded/target/
/TASMAN-core/nbproject/
/TASMAN-bom/target/
config.properties
test.properties
/**/pom.xml.versionsBackup
install.sh
build:
script: "cd TASMAN-core; mvn clean install -P Test -Dmysql_host=localhost -Dmysql_port=3306 -Dmysql_user=tasman_tester -D mysql_password=tasman_tester -Dpostgres_host=localhost -Dpostgres_port=5432 -Dpostgres_user=tasman_tester -Dpostgres_password=tasman_tester -Dpostgres_database=tasman_test"
...@@ -5,41 +5,24 @@ See also the [CHANGELOG](CHANGELOG.md). ...@@ -5,41 +5,24 @@ See also the [CHANGELOG](CHANGELOG.md).
## Build ## Build
### Build the API 1. Create a `config.properties` file (copy it from `config.properties.example`). In this file it is specified:
* **ucd_service_url**: the URL for the UCD REST web service.
cd TASMAN-core * IA2 UCD service is at http://ia2-vo.oats.inaf.it/ucd/
mvn install * if the UCD web service is unreachable the web app will work anyway, but without the UCD search functionality.
* **config_file_path**: the location where the web app will store the generated XML configuration (the location needs to be writable by the application server in which TASMAN will run).
#### WARNING: test
Test suite for the TASMAN-core assumes some hardcoded values. If they 2. `chmod +x build.sh`
fail simply put an _@Ignore_ in front on the test class. 3. `./build.sh <command>`, commands are:
* **core** build only TASMAN core
### Build the Web application * **test**: run tests; you need to create a `test.properties` file containing a configuration for connecting to a MySQL and a Postgres test database
* **glassfish**: build GlassFish war package
cd TASMAN-webapp * **tomcat**: build Tomcat war package (using config.properties file)
* **embedded**: build embedded package (to be run _locally!_)
Edit configuration properties file (`src/main/resources/webapp.properties`): * **installer**: build install script (produce self-extracting install.sh script)
ucd_service_url=<URL for the UCD REST web service>
config_file_path=<location where the web app will store the generated XML configuration>
IA2 UCD service is at http://ia2-vo.oats.inaf.it:8080/ucd/
If the UCD web service is unreachable the web app will work anyway, but without the UCD search functionality.
Then build the web application:
* GlassFish war package (default):
mvn install
* Tomcat war package:
mvn -P Tomcat install
## Supported application servers ## Supported application servers
The web app was tested with: The web app has been tested with:
* GlassFish 4.1 * GlassFish 4.1
* Tomcat 8.0.33 * Tomcat 8.0.33
...@@ -51,9 +34,8 @@ Build requires _Ucidy_ and _Unity_ that are not available at central ...@@ -51,9 +34,8 @@ Build requires _Ucidy_ and _Unity_ that are not available at central
maven repo. You should have them installed in a local maven repo. maven repo. You should have them installed in a local maven repo.
To do this: download the jar files listed in the following To do this: download the jar files listed in the following
credits section and runn a couple of `mvn install:install-file` credits section and run a couple of `mvn install:install-file`
commands based upond the dependencies description in the _TASMAN-webapp_ commands based upond the dependencies description in the _TASMAN-webapp_ _pom.xml_ file.
_pom.xml_ file.
## Credits ## Credits
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.inaf.ia2.tsm</groupId>
<artifactId>tasman-bom</artifactId>
<version>1.3.2</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<netbeans.hint.license>inaf-license-netbeans</netbeans.hint.license>
<maven.test.skip>true</maven.test.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<show>public</show>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>it.inaf.ia2.tap</groupId>
<parent>
<groupId>it.inaf.ia2.tsm</groupId>
<artifactId>tasman-bom</artifactId>
<version>1.3.2</version>
</parent>
<artifactId>tasman-core</artifactId> <artifactId>tasman-core</artifactId>
<version>1.3.2</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>tasman-core</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<netbeans.hint.license>inaf-license-netbeans</netbeans.hint.license>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.tomcat</groupId> <groupId>org.apache.tomcat</groupId>
...@@ -31,36 +30,22 @@ ...@@ -31,36 +30,22 @@
<version>9.3-1104-jdbc41</version> <version>9.3-1104-jdbc41</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build>
<plugins> <profiles>
<plugin> <profile>
<groupId>org.apache.maven.plugins</groupId> <id>test</id>
<artifactId>maven-javadoc-plugin</artifactId> <properties>
<version>2.10.4</version> <maven.test.skip>false</maven.test.skip>
<configuration> </properties>
<show>public</show> <build>
</configuration> <testResources>
</plugin> <testResource>
<plugin> <directory>src/test/resources</directory>
<groupId>org.apache.maven.plugins</groupId> <filtering>true</filtering>
<artifactId>maven-surefire-plugin</artifactId> </testResource>
<version>2.20</version> </testResources>
<configuration> </build>
<trimStackTrace>false</trimStackTrace> </profile>
</configuration> </profiles>
</plugin>
</plugins>
</build>
</project> </project>
\ No newline at end of file
...@@ -28,6 +28,8 @@ import it.inaf.ia2.tsm.datalayer.Credentials; ...@@ -28,6 +28,8 @@ import it.inaf.ia2.tsm.datalayer.Credentials;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.sql.Connection; import java.sql.Connection;
...@@ -37,6 +39,7 @@ import java.sql.Statement; ...@@ -37,6 +39,7 @@ import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Properties;
import java.util.Set; import java.util.Set;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
...@@ -44,7 +47,6 @@ import org.junit.Before; ...@@ -44,7 +47,6 @@ import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Ignore;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -66,21 +68,29 @@ public class TestAll { ...@@ -66,21 +68,29 @@ public class TestAll {
} }
@BeforeClass @BeforeClass
public static void setUpClass() throws SQLException { public static void setUpClass() throws SQLException, IOException {
Properties props = new Properties();
try (InputStream in = TestAll.class.getClassLoader().getResourceAsStream("test.properties")) {
props.load(in);
}
dbWrappers = new ArrayList<>(); dbWrappers = new ArrayList<>();
// MYSQL // MYSQL
Credentials mysqlCredentials = new Credentials(DatabaseType.MYSQL); Credentials mysqlCredentials = new Credentials(DatabaseType.MYSQL);
mysqlCredentials.setHostname("localhost"); mysqlCredentials.setHostname(props.getProperty("mysql_host"));
mysqlCredentials.setUsername("root"); mysqlCredentials.setPort(Integer.parseInt(props.getProperty("mysql_port")));
mysqlCredentials.setPassword("root"); mysqlCredentials.setUsername(props.getProperty("mysql_user"));
mysqlCredentials.setPassword(props.getProperty("mysql_password"));
// POSTGRES // POSTGRES
Credentials postgresCredentials = new Credentials(DatabaseType.POSTGRES); Credentials postgresCredentials = new Credentials(DatabaseType.POSTGRES);
postgresCredentials.setHostname("localhost"); postgresCredentials.setHostname(props.getProperty("postgres_host"));
postgresCredentials.setUsername("postgres"); postgresCredentials.setPort(Integer.parseInt(props.getProperty("postgres_port")));
postgresCredentials.setPassword("pippo"); postgresCredentials.setUsername(props.getProperty("postgres_user"));
postgresCredentials.setPassword(props.getProperty("postgres_password"));
postgresCredentials.setDatabase(props.getProperty("postgres_database"));
DBWrapper dbWrapper = new DBWrapper(mysqlCredentials); DBWrapper dbWrapper = new DBWrapper(mysqlCredentials);
dbWrapper.testConnections(); dbWrapper.testConnections();
......
...@@ -2,15 +2,16 @@ ...@@ -2,15 +2,16 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>it.inaf.ia2.tap</groupId> <parent>
<groupId>it.inaf.ia2.tsm</groupId>
<artifactId>tasman-bom</artifactId>
<version>1.3.2</version>
</parent>
<artifactId>tasman-embedded</artifactId> <artifactId>tasman-embedded</artifactId>
<version>1.2.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<jetty.version>9.4.6.v20170531</jetty.version> <jetty.version>9.4.6.v20170531</jetty.version>
</properties> </properties>
...@@ -36,6 +37,12 @@ ...@@ -36,6 +37,12 @@
</dependencies> </dependencies>
<build> <build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
......
warFilePath=/home/sonia/git/TASMAN/TASMAN-webapp/target/tasman-webapp-1.3.2.war warFilePath=${war_file_path}
defaultPort=8080 defaultPort=8080
\ No newline at end of file
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>it.inaf.ia2.tap</groupId> <parent>
<groupId>it.inaf.ia2.tsm</groupId>
<artifactId>tasman-bom</artifactId>
<version>1.3.2</version>
</parent>
<artifactId>tasman-webapp</artifactId> <artifactId>tasman-webapp</artifactId>
<version>1.3.2</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>tasman-webapp</name>
<properties> <properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans.hint.license>inaf-license-netbeans</netbeans.hint.license>
<jersey.version>2.23.2</jersey.version> <jersey.version>2.23.2</jersey.version>
<deltaspike.version>1.7.2</deltaspike.version> <deltaspike.version>1.7.2</deltaspike.version>
<enable.weld.config.start></enable.weld.config.start> <enable.weld.config.start></enable.weld.config.start>
...@@ -128,9 +128,9 @@ ...@@ -128,9 +128,9 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>it.inaf.ia2.tap</groupId> <groupId>${project.groupId}</groupId>
<artifactId>tasman-core</artifactId> <artifactId>tasman-core</artifactId>
<version>1.3.2</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ari.ucidy</groupId> <groupId>ari.ucidy</groupId>
...@@ -155,17 +155,6 @@ ...@@ -155,17 +155,6 @@
<type>jar</type> <type>jar</type>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.deltaspike.modules</groupId> <groupId>org.apache.deltaspike.modules</groupId>
<artifactId>deltaspike-jsf-module-impl</artifactId> <artifactId>deltaspike-jsf-module-impl</artifactId>
...@@ -228,6 +217,7 @@ ...@@ -228,6 +217,7 @@
<filtering>true</filtering> <filtering>true</filtering>
<includes> <includes>
<include>**/version.txt</include> <include>**/version.txt</include>
<include>**/webapp.properties</include>
</includes> </includes>
</resource> </resource>
<!-- Include all other files without filtering them --> <!-- Include all other files without filtering them -->
...@@ -236,6 +226,7 @@ ...@@ -236,6 +226,7 @@
<filtering>false</filtering> <filtering>false</filtering>
<excludes> <excludes>
<exclude>**/version.txt</exclude> <exclude>**/version.txt</exclude>
<exclude>**/webapp.properties</exclude>
</excludes> </excludes>
</resource> </resource>
</resources> </resources>
...@@ -245,8 +236,8 @@ ...@@ -245,8 +236,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version> <version>3.1</version>
<configuration> <configuration>
<source>1.7</source> <source>${maven.compiler.source}</source>
<target>1.7</target> <target>${maven.compiler.target}</target>
<compilerArguments> <compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs> <endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments> </compilerArguments>
......
ucd_service_url=http://ia2-vo.oats.inaf.it/ucd/ # URL for the UCD REST web service
config_directory=/home/sonia/.tasman ucd_service_url=${ucd_service_url}
\ No newline at end of file # location where the web app will store the generated XML configuration
config_directory=${config_directory}
\ No newline at end of file
#!/bin/bash
config_file="config.properties"
test_config_file="test.properties"
if [ ! -f "$config_file" ]; then
echo "$config_file doesn't exist!"
exit 1
fi
# Append to a command a list of environment variables defined into a file
function add_properties {
command=$1
properties_file=$2
while read line
do
if [[ ! -z "$line" ]] && [[ ! "$line" =~ ^\# ]]; then
command="$command -D$line"
fi
done <<< "$(cat ../$properties_file)"
echo $command
}
function build_core {
cd TASMAN-core
mvn -q clean install
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-core built"
cd ..
}
function test_core {
cd TASMAN-core
$(add_properties "mvn clean install -P test" $test_config_file)
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
cd ..
}
function build_web_glassfish {
build_core
# build webapp
cd TASMAN-webapp
$(add_properties "mvn -q clean install" $config_file)
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-webapp built"
cd ..
}
function build_web_tomcat {
build_core
# build webapp
cd TASMAN-webapp
$(add_properties "mvn -q clean install -P ServletContainer" $config_file)
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-webapp built"
cd ..
}
function build_web_embedded {
build_core
# build webapp
cd TASMAN-webapp
$(add_properties "mvn -q clean install -P ServletContainer,Jetty" $config_file)
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-webapp built"
cd ..
# build embedded
cd TASMAN-embedded
war_file_path=`dirname ${PWD}`/TASMAN-webapp/target/tasman-webapp-*.war
war_file_path=`ls $war_file_path`
mvn clean -q install -Dwar_file_path=$war_file_path
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-embedded built"
cd ..
}
function build_installer_package {
build_core
# build webapp
cd TASMAN-webapp
mvn -q clean install -P ServletContainer,Jetty
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-webapp built"
cd ..
# build embedded
cd TASMAN-embedded
mvn -q clean install
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-embedded built"
cd ..
# copy TASMAN files
cp TASMAN-webapp/target/tasman-webapp-*.war .
cp TASMAN-embedded/target/tasman-embedded.jar .
mv tasman-webapp-*.war tasman-webapp.war
# create tar for self-extracting installer
tar cfz tasman.tar.gz tasman-webapp.war tasman-embedded.jar
rm tasman-webapp.war
rm tasman-embedded.jar
cp install_template.sh install.sh
cat tasman.tar.gz >> install.sh
rm tasman.tar.gz
echo "TASMAN install.sh built"
}