Commit 492c1c0b authored by Benoit Lavenier's avatar Benoit Lavenier

- Client: Add i18n

- Client: Add ZIP assembly
- Client: network add highlight
- Add license header
parent 3d618c63
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<component
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2 http://maven.apache.org/xsd/component-1.1.2.xsd">
<fileSets>
<fileSet>
<includes>
<include>LICENSE*</include>
</includes>
</fileSet>
<!-- Duniter4j component -->
<fileSet>
<directory>target</directory>
<outputDirectory>duniter4j</outputDirectory>
<includes>
<include>${project.build.finalName}.${project.packaging}</include>
</includes>
</fileSet>
<fileSet>
<directory>target/lib</directory>
<outputDirectory>duniter4j/lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
<excludes>
<exclude>junit-*.jar</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>src/main/assembly/min</directory>
<outputDirectory/>
<filtered>true</filtered>
<fileMode>0755</fileMode>
<includes>
<include>*.sh</include>
</includes>
</fileSet>
<fileSet>
<directory>src/main/assembly/min</directory>
<outputDirectory>duniter4j</outputDirectory>
<filtered>true</filtered>
<includes>
<include>*</include>
</includes>
<excludes>
<exclude>*.sh</exclude>
<exclude>*.bat</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>src/main/assembly/min</directory>
<outputDirectory>i18n</outputDirectory>
<filtered>true</filtered>
<includes>
<include>version.appup</include>
</includes>
</fileSet>
<!-- I18N component -->
<fileSet>
<directory>target/classes/META-INF</directory>
<outputDirectory>i18n</outputDirectory>
<includes>
<include>duniter4j-client-i18n*.properties</include>
<include>duniter4j-client-i18n*.csv</include>
</includes>
</fileSet>
<fileSet>
<directory>src/main/assembly/min</directory>
<outputDirectory>i18n</outputDirectory>
<filtered>true</filtered>
<includes>
<include>version.appup</include>
</includes>
</fileSet>
</fileSets>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>full-linux-i586</id>
<formats>
<format>zip</format>
</formats>
<componentDescriptors>
<componentDescriptor>
src/main/assembly/full-linux-component.xml
</componentDescriptor>
</componentDescriptors>
<fileSets>
<fileSet>
<directory>${project.build.directory}/jre-linux-i586/jre</directory>
<outputDirectory>jre</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>full-linux-x64</id>
<formats>
<format>zip</format>
</formats>
<componentDescriptors>
<componentDescriptor>
src/main/assembly/full-linux-component.xml
</componentDescriptor>
</componentDescriptors>
<fileSets>
<fileSet>
<directory>${project.build.directory}/jre-linux-x64/jre</directory>
<outputDirectory>/jre</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
<?xml version="1.0" encoding="UTF-8"?>
<component
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2 http://maven.apache.org/xsd/component-1.1.2.xsd">
<fileSets>
<fileSet>
<directory>src/main/assembly/min</directory>
<outputDirectory/>
<filtered>true</filtered>
<fileMode>0755</fileMode>
<includes>
<include>*.bat</include>
</includes>
</fileSet>
<fileSet>
<includes>
<include>LICENSE*</include>
</includes>
</fileSet>
<!-- Reef DB component -->
<fileSet>
<directory>target</directory>
<outputDirectory>duniter4j</outputDirectory>
<includes>
<include>${project.build.finalName}.${project.packaging}</include>
</includes>
</fileSet>
<fileSet>
<directory>target/lib</directory>
<outputDirectory>duniter4j/lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
<excludes>
<exclude>junit-*.jar</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>src/main/assembly/min</directory>
<outputDirectory>duniter4j</outputDirectory>
<filtered>true</filtered>
<includes>
<include>*</include>
</includes>
<excludes>
<exclude>*.sh</exclude>
<exclude>*.bat</exclude>
</excludes>
</fileSet>
<!-- I18N component -->
<fileSet>
<directory>target/classes/META-INF</directory>
<outputDirectory>i18n</outputDirectory>
<includes>
<include>duniter4j-client-i18n*.properties</include>
<include>duniter4j-client-i18n*.csv</include>
</includes>
</fileSet>
<fileSet>
<directory>src/main/assembly/min</directory>
<outputDirectory>i18n</outputDirectory>
<filtered>true</filtered>
<includes>
<include>version.appup</include>
</includes>
</fileSet>
</fileSets>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>full-windows-i586</id>
<formats>
<format>zip</format>
</formats>
<componentDescriptors>
<componentDescriptor>
src/main/assembly/full-windows-component.xml
</componentDescriptor>
</componentDescriptors>
<fileSets>
<fileSet>
<directory>${project.build.directory}/jre-windows-i586/jre</directory>
<outputDirectory>jre</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>full-windows-x64</id>
<formats>
<format>zip</format>
</formats>
<componentDescriptors>
<componentDescriptor>
src/main/assembly/full-windows-component.xml
</componentDescriptor>
</componentDescriptors>
<fileSets>
<fileSet>
<directory>${project.build.directory}/jre-windows-x64/jre</directory>
<outputDirectory>jre</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>i18n</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>target/classes/META-INF</directory>
<outputDirectory/>
<includes>
<include>duniter4j-client-i18n*.properties</include>
<include>duniter4j-client-i18n*.csv</include>
</includes>
</fileSet>
<fileSet>
<directory>src/main/assembly/min</directory>
<outputDirectory/>
<filtered>true</filtered>
<includes>
<include>version.appup</include>
</includes>
</fileSet>
</fileSets>
</assembly>
-----------------------------
-- README Duniter4j Client --
-----------------------------
# Linux
./duniter4j.sh <command> <options>
# Windows
duniter4j.bat <command> <options>
Need HELP ?
-----------
# Linux
./duniter4j.sh --help
# Windows
duniter4j.bar --help
\ No newline at end of file
@echo off
set OLDDIR=%CD%
cd /d %~dp0%
set DUNITER4j_BASEDIR="%CD%"
set JAVA_HOME=%DUNITER4j_BASEDIR%\jre
set JAVA_COMMAND=%JAVA_HOME%\bin\java
set DUNITER4j_CONFIG_DIR=%DUNITER4j_BASEDIR%\config
echo "Running Duniter4j Client..."
echo " basedir: %DUNITER4j_BASEDIR%"
echo " jre home: %JAVA_HOME%"
:start
call duniter4j\launch.bat --option duniter4j.launch.mode full --option duniter4j.basedir %DUNITER4j_BASEDIR% --option config.path %DUNITER4j_CONFIG_DIR%
if errorlevel 88 goto start
goto quit
:quit
cd %OLDDIR%
#!/bin/bash
READLINK=`which readlink`
if [ -z "$READLINK" ]; then
message "Required tool 'readlink' is missing. Please install before launch \"$0\" file."
exit 1
fi
# ------------------------------------------------------------------
# Ensure BASEDIR points to the directory where the soft is installed.
# ------------------------------------------------------------------
SCRIPT_LOCATION=$0
if [ -x "$READLINK" ]; then
while [ -L "$SCRIPT_LOCATION" ]; do
SCRIPT_LOCATION=`"$READLINK" -e "$SCRIPT_LOCATION"`
done
fi
export APPDIR=`dirname "$SCRIPT_LOCATION"`
export JARDIR="$APPDIR/duniter4j"
export JAR="$JARDIR/${project.build.finalName}.${project.packaging}"
export I18N_DIR="$APPDIR/i18n"
# Retrieve the JAVA installation
if [ "~$JAVA_HOME" -eq "~" ]; then
export JAVA_HOME="$APPDIR/jre"
export JAVA_COMMAND="$JAVA_HOME/bin/java"
if [ -f "$JAVA_HOME/bin/java" ]; then
# If embedded JRE exists, make sure java is executable
chmod +x "$JAVA_COMMAND"
else
# If not Embedded JRE, use the default binary
export JAVA_COMMAND=java
fi
else
export JAVA_COMMAND="$JAVA_HOME/bin/java"
fi
if [ -d "$HOME" ]; then
export BASEDIR="$HOME/.config/duniter4j"
export CONFIG_DIR="$BASEDIR/config"
export CONFIG_FILE="$CONFIG_DIR/duniter4j-client.config"
export LOG_FILE="$BASEDIR/logs/${project.build.finalName}.log"
else
export BASEDIR="$APPDIR"
export CONFIG_DIR="$APPDIR/config"
export CONFIG_FILE="$CONFIG_DIR/config/duniter4j-client.config"
export LOG_FILE="$APPDIR/logs/${project.build.finalName}.log"
echo "Using base"
fi
# Create the config dir if need
mkdir -p "$CONFIG_DIR"
# Create the config file (if need)
if [ ! -f "$CONFIG_FILE" ]; then
echo "INFO - Initialized configuration file: $CONFIG_FILE"
cp -u $JARDIR/duniter4j-client.config $CONFIG_FILE
fi
cd $APPDIR
while true; do
$JAVA_COMMAND $JAVA_OPTS -Dduniter4j.log.file=$LOG_FILE -Dduniter4j.i18n.directory=$I18N_DIR -jar $JAR --basedir $BASEDIR --config $CONFIG_FILE $*
exitcode=$?
if [ ! "$exitcode" -eq "130" ]; then
echo "INFO - Application stopped with exitcode: $exitcode"
fi
## Continue only if exitcode=88 (will restart the application)
if [ ! "$exitcode" -eq "88" ]; then
# quit now!
exit $exitcode
fi
done
${project.version}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>standalone</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>target</directory>
<outputDirectory/>
<includes>
<include>${project.build.finalName}.${project.packaging}</include>
</includes>
</fileSet>
<fileSet>
<directory>target/lib</directory>
<outputDirectory>lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
<excludes>
<exclude>junit-*.jar</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>src/main/assembly/full</directory>
<outputDirectory/>
<filtered>true</filtered>
<includes>
<include>*.sh</include>
<include>*.bat</include>
</includes>
</fileSet>
<fileSet>
<directory>src/main/assembly/min</directory>
<outputDirectory/>
<filtered>true</filtered>
<includes>
<include>version.appup</include>
</includes>
</fileSet>
<fileSet>
<includes>
<include>README*</include>
<include>LICENSE*</include>
</includes>
</fileSet>
<!--add basic configuration-->
<fileSet>
<directory>src/main/assembly/min</directory>
<outputDirectory>config</outputDirectory>
<includes>
<include>duniter4j-client.config</include>
</includes>
</fileSet>
</fileSets>
</assembly>
# Static config:
duniter4j.version=${project.version}
duniter4j.inceptionYear=${project.inceptionYear}
duniter4j.organizationName=${license.organizationName}
duniter4j.node.host=192.168.0.5
duniter4j.node.port=10901
......
......@@ -9,7 +9,7 @@ log4j.appender.stdout.layout.ConversionPattern=%p - %m%n
# File appender
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.file=duniter4j-client.log
log4j.appender.file.file=${duniter4j.log.file}
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=4
......@@ -18,12 +18,9 @@ log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p %c - %m%n
# Duniter4j levels
log4j.logger.org.duniter=INFO
#log4j.logger.org.duniter.cmd=INFO
#log4j.logger.org.duniter.core.client.service=DEBUG
#log4j.logger.org.duniter.core.client.service.local=DEBUG
#log4j.logger.org.duniter.core.client.service.bma=DEBUG
log4j.logger.org.duniter.core.beans=WARN
#log4j.logger.org.duniter.core.client.service=TRACE
# Avoid warning on leaf not found (Duniter issue)
log4j.logger.org.duniter.core.client.service.local.NetworkServiceImpl=ERROR
# Other frameworks levels
log4j.logger.org.apache.http=ERROR
......
package fr.duniter.cmd;
package fr.duniter.client;
/*
* #%L
* Duniter4j :: Client
* %%
* Copyright (C) 2014 - 2017 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterDescription;
import com.beust.jcommander.ParameterException;
import com.beust.jcommander.Parameters;
import com.google.common.collect.Lists;
import fr.duniter.cmd.actions.NetworkAction;
import fr.duniter.cmd.actions.TransactionAction;
import fr.duniter.client.actions.NetworkAction;
import fr.duniter.client.actions.TransactionAction;
import org.apache.commons.io.FileUtils;
import org.duniter.core.client.config.Configuration;
import org.duniter.core.client.config.ConfigurationOption;
import org.duniter.core.client.service.ServiceLocator;
import org.duniter.core.util.StringUtils;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.DefaultI18nInitializer;
import org.nuiton.i18n.init.UserI18nInitializer;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/**
* Created by blavenie on 22/03/17.
*/
@Parameters(resourceBundle = "i18n.duniter4j-client")
public class Main {
@Parameter(names = "-debug", description = "Debug mode", arity = 1)
@Parameter(names = "-debug", description = "Debug mode", descriptionKey = "duniter4j.params.debug")
private boolean debug = false;
@Parameter(names = "--help", help = true)
private boolean help;
@Parameter(names = "-config", description = "Configuration file path")
private String configFilename = "duniter-cmd.config";
@Parameter(names = "--basedir", hidden = true)
private File basedir;
@Parameter(names = "--config", description = "Configuration file path", descriptionKey="duniter4j.params.config" )
private String configFilename = "duniter-client.config";
public static void main(String ... args) {
Main main = new Main();
......@@ -104,7 +135,7 @@ public class Main {
protected String getI18nBundleName() {
return "duniter4j-core-client-i18n";
return "duniter4j-client-i18n";
}
/* -- -- */
......@@ -113,7 +144,6 @@ public class Main {
* Convenience methods that could be override to initialize other configuration
*
* @param configFilename
* @param configArgs
*/
protected void initConfiguration(String configFilename) {
String[] configArgs = getConfigArgs();
......@@ -127,7 +157,7 @@ public class Main {
// --------------------------------------------------------------------//
// init i18n
// --------------------------------------------------------------------//
File i18nDirectory = new File(config.getDataDirectory(), "i18n");
File i18nDirectory = config.getI18nDirectory();
if (i18nDirectory.exists()) {
// clean i18n cache
FileUtils.cleanDirectory(i18nDirectory);
......@@ -136,13 +166,21 @@ public class Main {
FileUtils.forceMkdir(i18nDirectory);
if (debug) {
System.out.println("I18N directory: " + i18nDirectory);
System.out.println("INFO - I18N directory: " + i18nDirectory);
}
Locale i18nLocale = config.getI18nLocale();
// Fix locale
if (i18nLocale.equals(Locale.FRENCH)) {
i18nLocale = Locale.FRANCE;
}
else if (i18nLocale.equals(Locale.ENGLISH)) {