Added full build process.

This commit is contained in:
Christian Pierre MOMON 2016-09-05 12:33:29 +02:00
parent 5692ef87d9
commit 7dd725456e
13 changed files with 386 additions and 92 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
/bin/
/test-output/
/javaDoc/
/build/
/dist/

3
build.num Normal file
View File

@ -0,0 +1,3 @@
#Build Number for ANT. Do not edit!
#Mon Sep 05 12:43:48 CEST 2016
build.number=1

3
build.properties Normal file
View File

@ -0,0 +1,3 @@
product.name=siba
product.revision.major=0
product.revision.minor=0

233
build.xml
View File

@ -1,93 +1,144 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. --><project basedir="." default="build" name="Siba">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="../../Bin/eclipse-mars_sav/"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.8"/>
<property name="source" value="1.8"/>
<path id="Siba.classpath">
<pathelement location="bin"/>
<pathelement location="lib/commons-compress-1.10.jar"/>
<pathelement location="lib/jgoodies-forms-1.8.0.jar"/>
<pathelement location="lib/jgoodies-common-1.8.1.jar"/>
<pathelement location="lib/commons-compress-1.10-sources.jar"/>
<pathelement location="lib/commons-lang3-3.4.jar"/>
<pathelement location="lib/commons-lang3-3.4-javadoc.jar"/>
<pathelement location="lib/commons-io-2.5.jar"/>
<pathelement location="lib/UnitTesting/jcommander-1.48.jar"/>
<pathelement location="lib/UnitTesting/testng-6.9.10.jar"/>
<pathelement location="lib/Logs/log4j-1.2.17.jar"/>
<pathelement location="lib/Logs/slf4j-api-1.7.21.jar"/>
<pathelement location="lib/Logs/slf4j-log4j12-1.7.21.jar"/>
<pathelement location="lib/commons-io-2.5-src.jar"/>
<pathelement location="lib/commons-lang3-3.4-src.jar"/>
<pathelement location="lib/jgoodies-forms-1.8.0-sources.jar"/>
</path>
<target name="init">
<mkdir dir="bin"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.launch"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="bin">
<fileset dir="test">
<exclude name="**/*.launch"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="bin"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project" name="build"/>
<target name="build-subprojects"/>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
<src path="src"/>
<src path="test"/>
<classpath refid="Siba.classpath"/>
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
<target name="SibaLauncher">
<java classname="Siba.SibaLauncher" failonerror="true" fork="yes">
<classpath refid="Siba.classpath"/>
</java>
</target>
<target name="SibaCLI">
<java classname="org.dclermonte.siba.cli.SibaCLI" failonerror="true" fork="yes">
<classpath refid="Siba.classpath"/>
</java>
</target>
<target name="SibaGUI">
<java classname="org.dclermonte.siba.gui.SibaGUI" failonerror="true" fork="yes">
<classpath refid="Siba.classpath"/>
</java>
</target>
<target name="Siba">
<java classname="org.dclermonte.siba.Siba" failonerror="true" fork="yes">
<classpath refid="Siba.classpath"/>
</java>
</target>
<project default="main" name="Create Runnable Jar for project Siba">
<!--ANT 1.7 is required -->
<property file="build.properties"/>
<property name="build.dir" value="${basedir}/build" />
<path id="project.libs">
<fileset dir="${basedir}/lib" includes="**.jar" excludes="*sources* *src*" />
<fileset dir="${basedir}/lib/Logs" includes="**.jar" excludes="*sources* *src*" />
</path>
<!-- TARGET MAIN -->
<target name="main" description="Manage distribution build" depends="dist, clean">
<echo>Done.</echo>
</target>
<!-- TARGET HELP -->
<target name="help" description="Display detailed usage information">
<echo>Type ant -p</echo>
</target>
<!-- TARGET CLEAN -->
<target name="clean" description="Remove build directory">
<echo>=======================================================================</echo>
<delete dir="${build.dir}" />
</target>
<!-- TARGET COMPILE -->
<target name="compile" description="Compile project">
<echo>=======================================================================</echo>
<delete dir="${build.dir}" />
<mkdir dir="${build.dir}" />
<echo>classpath=${toString:project.libs}</echo>
<javac srcdir="src" destdir="${build.dir}" classpath="${toString:project.libs}" includeantruntime="no" />
</target>
<!-- COPY SOURCE STUFF -->
<target name="copysourcestuff" description="Compile project">
<echo>=======================================================================</echo>
<copy todir="${build.dir}">
<fileset dir="${basedir}/src" excludes="**/*.java" />
</copy>
</target>
<!-- TARGET DIST -->
<target name="dist" description="Build distribution directory" depends="compile, copysourcestuff">
<echo>=======================================================================</echo>
<buildnumber file="build.num" description="Id of the build"/>
<property name="dist.version" value="${product.revision.major}.${product.revision.minor}.${build.number}" />
<!-- AUTOMATIC MANAGEMENT -->
<property name="dist.name" value="${product.name}-${version}" />
<property name="dist.dir" value="${basedir}/dist/siba-${dist.version}" />
<property name="dist.zip" value="${basedir}/dist/siba-${dist.version}.zip" />
<tstamp>
<format property="dist.time" pattern="dd/MM/yyyy HH:mm:ss" />
</tstamp>
<delete dir="${dist.dir}" />
<!-- delete file="${distzip}" /-->
<mkdir dir="${dist.dir}"/>
<!-- Update build_information.properties file -->
<property name="build.information.file" value="${build.dir}/build_information.properties" />
<propertyfile file="${build.information.file}" >
<entry key="product.name" value="${product.name}"/>
<entry key="product.revision.major" value="${product.revision.major}"/>
<entry key="product.revision.minor" value="${product.revision.minor}"/>
<entry key="product.revision.build" value="${build.number}"/>
<entry key="product.revision.date" type="date" value="now"/>
<entry key="product.revision.generator" value="Ant"/>
<entry key="product.revision.author" value="${user.name}"/>
</propertyfile>
<!-- Build the jar file list. -->
<manifestclasspath property="lib.list" jarfile="${basedir}/lib/siba.jar">
<classpath path="${toString:project.libs}" />
</manifestclasspath>
<!-- Make full jar file -->
<jar destfile="${dist.dir}/siba.jar">
<manifest>
<attribute name="Built-By" value="${user.name} using Siba ANT"/>
<attribute name="Built-Date" value="${dist.time}"/>
<attribute name="Implementation-Version" value="Siba ${dist.version} ${TODAY}"/>
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/>
<attribute name="Rsrc-Main-Class" value="org.dclermonte.siba.Siba"/>
<attribute name="Class-Path" value="siba.jar ." />
<attribute name="Rsrc-Class-Path" value="./ ${lib.list}"/>
</manifest>
<zipfileset src="lib/jar-in-jar-loader.zip"/>
<fileset dir="${build.dir}/" excludes="**/*Test.class"/>
<zipfileset dir="${basedir}/lib" includes="${lib.list}" />
</jar>
<!-- Make sources file -->
<property name="dist.srczip" value="${dist.dir}/siba-${dist.version}-sources.zip" />
<zip destfile="${dist.srczip}" update="true" preserve0permissions="true">
<fileset dir="${basedir}/src" />
<zipfileset dir="${basedir}/" includes="LICENSE" />
</zip>
<!-- Make core jar file -->
<property name="dist.core.jar" value="${dist.dir}/siba-core-${dist.version}.jar" />
<jar destfile="${dist.core.jar}">
<manifest>
<attribute name="Built-By" value="${user.name} using ANT" />
<attribute name="Built-Date" value="${dist.time}" />
</manifest>
<fileset dir="${build.dir}" excludes="org/dclermonte/siba/gui/**" />
<zipfileset dir="${basedir}/" includes="LICENSE" />
</jar>
<!-- Make core jar source file -->
<property name="dist.core.srczip" value="${dist.dir}/siba-core-${dist.version}-sources.zip" />
<zip destfile="${dist.core.srczip}" update="true" preserve0permissions="true">
<fileset dir="${basedir}/src" />
<fileset dir="${basedir}/src" excludes="org/dclermonte/siba/gui/**" />
<zipfileset dir="${basedir}/" includes="LICENSE" />
</zip>
<!-- Copy stuff -->
<copy file="scripts/siba.sh" todir="${dist.dir}/" overwrite="true" />
<chmod file="${dist.dir}/siba.sh" perm="ugo+rx" />
<copy file="scripts/siba.command" todir="${dist.dir}/" overwrite="true" />
<chmod file="${dist.dir}/siba.command" perm="ugo+rx" />
<copy file="scripts/siba.bat" todir="${dist.dir}/" overwrite="true" />
<copy file="README.md" todir="${dist.dir}/" overwrite="true" />
<copy file="LICENSE" todir="${dist.dir}/" overwrite="true" />
<copy file="scripts/log4j.properties" todir="${dist.dir}/" overwrite="true" />
<!--zip destfile="${distzip}"
basedir="dist"
includes="${dist.name}/**"
update="true"
preserve0permissions="true"
/-->
<delete file="${build.information.file}" />
</target>
</project>

29
buildandgit.xml Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<project default="buildandgit" name="Siba">
<!-- ***** Core ***** -->
<import file="build.xml" />
<!-- ***** Dist ***** -->
<target name="buildandgit" depends="dist">
<!-- GIT actions-->
<echo message="Commit build.num"/>
<exec executable="git" outputproperty="git.commit.out" failifexecutionfails="true">
<arg line="commit -m 'Build ${dist.version}' build.num"/>
</exec>
<echo message="${git.commit.out}" />
<echo message="Tag"/>
<exec executable="git" outputproperty="git.tag.out" failifexecutionfails="true">
<arg line="tag -a ${dist.version} -m 'Build ${dist.version}'"/>
</exec>
<echo message="${git.tag.out}" />
<echo message="Push"/>
<exec executable="git" outputproperty="git.push.out" failifexecutionfails="true">
<arg line="push --follow-tags"/>
</exec>
<echo message="${git.push.out}" />
</target>
</project>

BIN
lib/jar-in-jar-loader.zip Normal file

Binary file not shown.

11
scripts/log4j.properties Normal file
View File

@ -0,0 +1,11 @@
# Log information (priority setting : DEBUG < INFO < WARN < ERROR)
# ################
log4j.rootLogger = CONSOLE
log4j.logger.org.dclermonte.siba = WARN
#--
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern = %d{ISO8601} - SIBA [%-5p] %34.34c.%25M - %m%n

3
scripts/siba.bat Normal file
View File

@ -0,0 +1,3 @@
ECHO OFF
java -Xms368m -Xmx1024m -jar siba.jar %1 %2 %3 %4 %5 %6 %7

7
scripts/siba.command Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
# Set the current directory with the Siba directory.
cd "`dirname "$0"`"
#
java -Xms368m -Xmx1024m -jar siba.jar $@

7
scripts/siba.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
# Set the current directory with the Siba directory.
cd "`dirname "$0"`"
#
java -Xms368m -Xmx1024m -jar siba.jar $@

View File

@ -25,6 +25,7 @@ import java.util.ResourceBundle;
import org.apache.commons.lang3.StringUtils;
import org.dclermonte.siba.SibaException;
import org.dclermonte.siba.model.SibaManager;
import org.dclermonte.siba.util.BuildInformation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -110,6 +111,7 @@ public final class SibaCLI
{
StringList message = new StringList();
message.append("Siba version ").appendln(new BuildInformation().version());
message.appendln("Usage:");
message.appendln(" siba [ -h | -help | --help ]");
message.appendln(" siba backup directoryToSave [ target ]");

View File

@ -52,6 +52,7 @@ import javax.swing.UnsupportedLookAndFeelException;
import org.apache.commons.lang3.StringUtils;
import org.dclermonte.siba.SibaException;
import org.dclermonte.siba.gui.utils.GUIToolBox;
import org.dclermonte.siba.util.BuildInformation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -180,7 +181,7 @@ public final class SibaGUI
this.frmSimpleBackup.setFont(new Font("DejaVu Sans", Font.BOLD, 12));
this.frmSimpleBackup.setForeground(new Color(0, 100, 0));
this.frmSimpleBackup.setBackground(new Color(102, 205, 170));
this.frmSimpleBackup.setTitle("Simple Backup");
this.frmSimpleBackup.setTitle(String.format("Simple Backup - v%s", new BuildInformation().version()));
this.frmSimpleBackup.setBounds(100, 100, 450, 300);
this.frmSimpleBackup.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

View File

@ -0,0 +1,175 @@
/*
* Copyright (C) 2016 Didier Clermonté <dclermonte@april.org>
* Copyright (C) 2016 Christian Pierre Momon <christian.momon@devinsy.fr>
*
* This file is part of Siba.
*
* Siba is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.dclermonte.siba.util;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/
public class BuildInformation
{
private static final Logger logger = LoggerFactory.getLogger(BuildInformation.class);
private static String BUILD_INFORMATION_FILE = "/build_information.properties";
private String productName;
private String majorRevision;
private String minorRevision;
private String buildNumber;
private String buildDate;
private String generator;
private String author;
/**
*
*/
public BuildInformation()
{
Properties build = new Properties();
try
{
//
URL buildInformationFile = BuildInformation.class.getResource(BUILD_INFORMATION_FILE);
if (buildInformationFile != null)
{
build.load(BuildInformation.class.getResource(BUILD_INFORMATION_FILE).openStream());
}
//
this.productName = build.getProperty("product.name", "PuckInstaller");
this.majorRevision = build.getProperty("product.revision.major", "d");
this.minorRevision = build.getProperty("product.revision.minor", "e");
this.buildNumber = build.getProperty("product.revision.build", "v");
this.buildDate = build.getProperty("product.revision.date", "today");
this.generator = build.getProperty("product.revision.generator", "n/a");
this.author = build.getProperty("product.revision.author", "n/a");
}
catch (IOException exception)
{
//
logger.error("Error loading the build.properties file: " + exception.getMessage());
logger.error(ExceptionUtils.getStackTrace(exception));
//
this.productName = "n/a";
this.majorRevision = "n/a";
this.minorRevision = "n/a";
this.buildNumber = "n/a";
this.buildDate = "n/a";
this.generator = "n/a";
this.author = "n/a";
}
}
public String author()
{
return this.author;
}
public String buildDate()
{
return this.buildDate;
}
public String buildNumber()
{
return this.buildNumber;
}
public String generator()
{
return this.generator;
}
public String majorRevision()
{
return this.majorRevision;
}
public String minorRevision()
{
return this.minorRevision;
}
public String productName()
{
return this.productName;
}
/**
*
*/
@Override
public String toString()
{
String result;
result = String.format("%s %s.%s.%s built on %s by %s", this.productName, this.majorRevision,
this.minorRevision, this.buildNumber, this.buildDate, this.author);
//
return result;
}
/**
*
* @return
*/
public String version()
{
String result;
result = String.format("%s.%s.%s", this.majorRevision, this.minorRevision, this.buildNumber);
//
return result;
}
/**
*
*/
public static boolean isDefined()
{
boolean result;
if (BuildInformation.class.getResource(BUILD_INFORMATION_FILE) == null)
{
result = false;
}
else
{
result = true;
}
//
return result;
}
}