Commit 630c66cc authored by LAVENIER's avatar LAVENIER
Browse files

[enh] Initial commit (from sumaris-pod)

[enh] Add module 'sar-hubeau'
parents
This diff is collapsed.
SUMARiS
=======
[SUMARiS](http://sumaris.net) is a tool for collecting halieutic data, such as stocks, in a shared database.
## Documentation
- See the [online documentation](./src/site/markdown/index.md)
## License
Free software, distributed under a [GPL v3 license](./src/site/markdown/LICENSE.md).
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
| This is the configuration file for Maven. It can be specified at two levels:
|
| 1. User Level. This settings.xml file provides configuration for a single user,
| and is normally provided in ${user.home}/.m2/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -s /path/to/user/settings.xml
|
| 2. Global Level. This settings.xml file provides configuration for all Maven
| users on a machine (assuming they're all using the same Maven
| installation). It's normally provided in
| ${maven.home}/conf/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -gs /path/to/global/settings.xml
|
| The sections in this sample file are intended to give you a running start at
| getting the most out of your Maven installation. Where appropriate, the default
| values (values used when the setting is not specified) are provided.
|
|-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ~/.m2/repository
-->
<localRepository>/root/.m2/repository/</localRepository>
<!-- interactiveMode
| This will determine whether maven prompts you when it needs input. If set to false,
| maven will use a sensible default value, perhaps based on some other setting, for
| the parameter in question.
|
| Default: true
<interactiveMode>true</interactiveMode>
-->
<!-- offline
| Determines whether maven should attempt to connect to the network when executing a build.
| This will have an effect on artifact downloads, artifact deployment, and others.
|
| Default: false
<offline>false</offline>
-->
<!-- pluginGroups
| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
|-->
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
</pluginGroups>
<!-- proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| specification in this list marked as active will be used.
|-->
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies>
<!-- servers
| This is a list of authentication profiles, keyed by the server-id used within the system.
| Authentication profiles can be used whenever maven must make a connection to a remote server.
|-->
<servers>
<!-- server
| Specifies the authentication information to use when connecting to a particular server, identified by
| a unique name within the system (referred to by the 'id' attribute below).
|
| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
| used together.
|
<server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>
-->
<server>
<id>internal-maven</id>
<username>${env.MAVEN_REPO_USER}</username>
<password>${env.MAVEN_REPO_PASS}</password>
</server>
<server>
<id>project-maven</id>
<username>gitlab+deploy-token-62</username>
<password>54gJ-pk4XDxmjoxBdirx</password>
</server>
<server>
<id>job-maven</id>
<configuration>
<httpHeaders>
<property>
<name>Job-Token</name>
<value>${env.CI_JOB_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
<server>
<id>gitlab.ifremer.fr</id>
<username>${env.GITLAB_REPO_USER}</username>
<password>${env.GITLAB_REPO_PASS}</password>
</server>
</servers>
<!-- mirrors
| This is a list of mirrors to be used in downloading artifacts from remote repositories.
|
| It works like this: a POM may declare a repository to use in resolving certain artifacts.
| However, this repository may have problems with heavy traffic at times, so people have mirrored
| it to several places.
|
| That repository definition will have a unique id, so we can create a mirror reference for that
| repository, to be used as an alternate download site. The mirror site will be the preferred
| server for that repository.
|-->
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
</mirrors>
<!-- profiles
| This is a list of profiles which can be activated in a variety of ways, and which can modify
| the build process. Profiles provided in the settings.xml are intended to provide local machine-
| specific paths and repository locations which allow the build to work in the local environment.
|
| For example, if you have an integration testing plugin - like cactus - that needs to know where
| your Tomcat instance is installed, you can provide a variable here such that the variable is
| dereferenced during the build process to configure the cactus plugin.
|
| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
| section of this document (settings.xml) - will be discussed later. Another way essentially
| relies on the detection of a system property, either matching a particular value for the property,
| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
| Finally, the list of active profiles can be specified directly from the command line.
|
| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
| repositories, plugin repositories, and free-form properties to be used as configuration
| variables for plugins in the POM.
|
|-->
<profiles>
<!-- profile
| Specifies a set of introductions to the build process, to be activated using one or more of the
| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
| or the command line, profiles have to have an ID that is unique.
|
| An encouraged best practice for profile identification is to use a consistent naming convention
| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
| This will make it more intuitive to understand what the set of introduced profiles is attempting
| to accomplish, particularly when you only have a list of profile id's for debug.
|
| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
<profile>
<id>jdk-1.4</id>
<activation>
<jdk>1.4</jdk>
</activation>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
-->
<profile>
<id>gitlab-profile</id>
<repositories>
<repository>
<id>project-maven</id>
<url>https://gitlab.ifremer.fr/api/v4/projects/1272/packages/maven</url>
</repository>
</repositories>
<properties>
<release.server>internal-maven</release.server>
<release.repository>https://gitlab.ifremer.fr/api/v4/projects/1272/packages/maven</release.repository>
<snapshot.server>job-maven</snapshot.server>
<snapshot.repository>https://gitlab.ifremer.fr/api/v4/projects/1226/packages/maven</snapshot.repository>
</properties>
</profile>
</profiles>
<!-- activeProfiles
| List of profiles that are active for all builds.
|
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
<activeProfiles>
<activeProfile>staging</activeProfile>
</activeProfiles>-->
<activeProfiles>
<activeProfile>gitlab-profile</activeProfile>
</activeProfiles>
</settings>
\ No newline at end of file
This diff is collapsed.
#!/bin/bash
task=$1
version=$2
release_description=$3
### Control that the script is run on `dev` branch
branch=`git rev-parse --abbrev-ref HEAD`
if [[ ! "$branch" = "release/$version" ]];
then
echo ">> This script must be run under a release branch (release/$version)"
exit 1
fi
### Get version to release
current=`grep -m1 -P "\<version>[0-9A−Z.]+(-\w*)?</version>" pom.xml | grep -oP "\d+.\d+.\d+(-\w*)?"`
if [[ "_$current" == "_" ]]; then
echo "ERROR: Unable to read 'version' in the file 'pom.xml'."
echo " - Make sure the file 'pom.xml' exists and is readable."
exit 1
fi
echo "Current version: $current"
### Get repo URL
PROJECT_NAME=sumaris-pod
REMOTE_URL=`git remote -v | grep -P "push" | grep -oP "(https:\/\/github.com\/|git@github.com:)[^ ]+"`
REPO="sumaris-net/sumaris-pod"
REPO_API_URL=https://api.github.com/repos/$REPO
REPO_PUBLIC_URL=https://github.com/$REPO
### get auth token
GITHUB_TOKEN=`cat ~/.config/${PROJECT_NAME}/.github`
if [[ "_$GITHUB_TOKEN" != "_" ]]; then
GITHUT_AUTH="Authorization: token $GITHUB_TOKEN"
else
echo "ERROR: Unable to find github authentication token file: "
echo " - You can create such a token at https://github.com/settings/tokens > 'Generate a new token'."
echo " - Then copy the token and paste it in the file '~/.config/${PROJECT_NAME}/.github' using a valid token."
exit 1
fi
case "$task" in
del)
result=`curl -i "$REPO_API_URL/releases/tags/$current"`
release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "$REPO_API_URL/releases/\d+"`
if [[ $release_url != "" ]]; then
echo "Deleting existing release..."
curl -H ''"$GITHUT_AUTH"'' -XDELETE $release_url
fi
;;
pre|rel)
if [[ $1 = "pre" ]]; then
prerelease="true"
else
prerelease="false"
fi
description=`echo $release_description`
if [[ "_$description" = "_" ]]; then
description="Release $current"
fi
result=`curl -s -H ''"$GITHUT_AUTH"'' "$REPO_API_URL/releases/tags/$current"`
release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+/releases/\d+"`
if [[ "_$release_url" != "_" ]]; then
echo "Deleting existing release... $release_url"
result=`curl -H ''"$GITHUT_AUTH"'' -s -XDELETE $release_url`
if [[ "_$result" != "_" ]]; then
error_message=`echo "$result" | grep -P "\"message\": \"[^\"]+" | grep -oP ": \"[^\"]+\""`
echo "Delete existing release failed with error $error_message"
exit 1
fi
else
echo "Release not exists yet on github."
fi
echo "Creating new release..."
echo " - tag: $current"
echo " - description: $description"
result=`curl -H ''"$GITHUT_AUTH"'' -s $REPO_API_URL/releases -d '{"tag_name": "'"$current"'","target_commitish": "master","name": "'"$current"'","body": "'"$description"'","draft": false,"prerelease": '"$prerelease"'}'`
upload_url=`echo "$result" | grep -P "\"upload_url\": \"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"`
if [[ "_$upload_url" = "_" ]]; then
echo "Failed to create new release for repo $REPO."
echo "Server response:"
echo "$result"
exit 1
fi
### Sending files
echo "Uploading files to $upload_url ..."
DIRNAME=$(pwd)
WAR_FILE="${DIRNAME}/sumaris-server/target/sumaris-server-$current.war"
if [[ ! -f "${WAR_FILE}" ]]; then
echo "ERROR: Missing WAR artifact: ${WAR_FILE}. Skipping upload"
missing_file=true
else
artifact_name="sumaris-pod-$current.war"
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${WAR_FILE}" "${upload_url}?name=${artifact_name}")
browser_download_url=`echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"`
SHA256=$(sha256sum "${WAR_FILE}" | sed 's/ /\n/gi' | head -n 1)
echo " - $browser_download_url | SHA256: ${SHA256}"
echo "${SHA256} ${artifact_name}" > ${WAR_FILE}.sha256
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: text/plain' -T "${WAR_FILE}.sha256" "${upload_url}?name=${artifact_name}.sha256")
fi
ZIP_FILE="${DIRNAME}/sumaris-server/target/sumaris-server-$current-standalone.zip"
if [[ ! -f "${ZIP_FILE}" ]]; then
echo "ERROR: Missing ZIP artifact: ${ZIP_FILE}. Skipping upload"
missing_file=true
else
artifact_name="sumaris-pod-$current.zip"
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${ZIP_FILE}" "${upload_url}?name=${ZIP_FILENAME}")
browser_download_url=`echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"`
SHA256=$(sha256sum "${ZIP_FILE}" | sed 's/ /\n/gi' | head -n 1)
echo " - $browser_download_url | SHA256: ${SHA256}"
echo "${SHA256} ${artifact_name}" > ${ZIP_FILE}.sha256
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: text/plain' -T "${ZIP_FILE}.sha256" "${upload_url}?name=${artifact_name}.sha256")
fi
DB_FILE="${DIRNAME}/sumaris-core/target/sumaris-db-$current.zip"
if [[ ! -f "${DB_FILE}" ]]; then
echo "ERROR: Missing DB ZIP artifact: ${DB_FILE}. Skipping uppload"
missing_file=true
else
artifact_name="sumaris-db-$current.zip"
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${DB_FILE}" "${upload_url}?name=${artifact_name}")
browser_download_url=`echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"`
SHA256=$(sha256sum "${DB_FILE}" | sed 's/ /\n/gi' | head -n 1)
echo " - $browser_download_url | SHA256: ${SHA256}"
echo "${SHA256} ${artifact_name}" > ${DB_FILE}.sha256
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: text/plain' -T "${DB_FILE}.sha256" "${upload_url}?name=${artifact_name}.sha256")
fi
if [[ ${missing_file} == true ]]; then
echo "-----------------------------------------"
echo "ERROR: missing some artifacts (see logs)"
echo " -> Release url: ${REPO_PUBLIC_URL}/releases/tag/${current}"
# Continue if error
#exit 1
else
echo "-----------------------------------------"
echo "Successfully uploading files !"
echo " -> Release url: ${REPO_PUBLIC_URL}/releases/tag/${current}"
exit 0
fi
;;
*)
echo "Wrong arguments"
echo "Usage:"
echo " > ./release-to-github.sh del|pre|rel <release_description>"
echo "With:"
echo " - del: delete existing release"
echo " - pre: use for pre-release"
echo " - rel: for full release"
exit 1
;;
esac
#!/bin/bash
mkdir -p .local
### Control that the script is run on `develop` branch
branch=`git rev-parse --abbrev-ref HEAD`
if [[ ! "$branch" = "develop" ]];
then
echo ">> This script must be run under \`develop\` branch"
exit 1
fi
task=$1
version=$2
release_description=$3
# Check arguments
if [[ ! $task =~ ^(pre|rel)$ || ! $version =~ ^[0-9]+.[0-9]+.[0-9]+(-(alpha|beta|rc)[0-9]+)?$ ]]; then
echo "Wrong version format"
echo "Usage:"
echo " > $0 pre|rel <version> <release_description>"
echo "with:"
echo " - pre: use for pre-release"
echo " - rel: for full release"
echo " - version: x.y.z"
echo " - release_description: a comment on release"
exit 1
fi
echo "task: $task"
echo "new build version: $version"
echo "release description: $release_description"
echo "**********************************"
echo "* Preparing release..."
echo "**********************************"
mvn -B gitflow:release-start -DreleaseVersion="$version"
[[ $? -ne 0 ]] && exit 1
echo "Prepare release [OK]"
echo "**********************************"
echo "* Performing release..."
echo "**********************************"
mvn clean deploy -DperformRelease -DskipTests -Dspring.datasource.platform=hsqldb
[[ $? -ne 0 ]] && exit 1
echo "**********************************"
echo "* Generating DB..."
echo "**********************************"
dirname=`pwd`
cd $dirname/sumaris-core
version=`grep -m1 -P "\<version>[0-9A−Z.]+(-\w*)?</version>" pom.xml | grep -oP "\d+.\d+.\d+(-\w*)?"`
# Generate the DB (run InitTest class)
mvn -Prun,hsqldb -DskipTests --quiet
[[ $? -ne 0 ]] && exit 1
# Create ZIP
cd target
zip -q -r "sumaris-db-$version.zip" db
[[ $? -ne 0 ]] && exit 1
echo "Generate DB [OK]"
cd $dirname
echo "**********************************"
echo "* Uploading artifacts to Github..."
echo "**********************************"
./release-to-github.sh "$task" "$version" ''"$release_description"''
[[ $? -ne 0 ]] && exit 1
echo "Upload artifacts to github [OK]"
echo "**********************************"
echo "* Pushing changes to upstream..."
echo "**********************************"
git commit -a -m "Release $version\n$release_description"
git status
mvn gitflow:release-finish
[[ $? -ne 0 ]] && exit 1
# Remove release branch
git branch -d "release/$version"
echo "Push changes to upstream [OK]"
echo "----------------------------------"
echo "RELEASE finished !"
echo "----------------------------------"
echo "Rebuild new SNAPSHOT version..."
mvn clean install -DskipTests --quiet
[[ $? -ne 0 ]] && exit 1
echo "Rebuild new SNAPSHOT version [OK]"
This diff is collapsed.
lombok.fieldnameconstants.uppercase=true
clear lombok.log.fieldName
lombok.log.fieldName = log
\ No newline at end of file
<?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>
<parent>
<groupId>fr.milieumarinfrance</groupId>
<artifactId>sar-pod</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>sar-core-extraction</artifactId>
<packaging>jar</packaging>
<name>SAR :: Core Extraction</name>
<description>SAR core extraction library</description>
<properties>
<!-- i18n configuration -->
<i18n.bundleOutputName>sumaris-core-extraction-i18n</i18n.bundleOutputName>
<i18n.generateCsvFile>true</i18n.generateCsvFile>
<i18n.bundleCsvFile>
${project.build.directory}/generated-sources/resources/META-INF/${i18n.bundleOutputName}.csv
</i18n.bundleCsvFile>
<config.i18nBundleName>${i18n.bundleOutputName}</config.i18nBundleName>
</properties>
<dependencies>
<!-- Project dependency -->
<dependency>
<groupId>fr.milieumarinfrance</groupId>
<artifactId>sar-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>de.grundid.opendatalab</groupId>
<artifactId>geojson-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- XML Query to build SQL from XML -->
<dependency>
<groupId>fr.ifremer.common</groupId>
<artifactId>xmlquery</artifactId>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</dependency>
<!-- OpenCSV for extraction result -->
<dependency>