Packaging the application for production structure

This commit is contained in:
romanman 2014-05-27 10:17:11 +03:00
parent 28f8fe4101
commit 51d3ed57e3
10 changed files with 144 additions and 41 deletions

51
build-post-package.xml Normal file
View File

@ -0,0 +1,51 @@
<project name="enthereumJ-postpackage" default="run" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist" />
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<echo message="Ant is taking control [assembly the package]"> </echo>
<echo message="${maven.project.artifactId}"> </echo>
<echo message="${maven.project.version}"> </echo>
</target>
<target name="make-package">
<mkdir dir="./target/package"/>
<copy todir="./target/package/lib">
<fileset dir="./target/dependency"/>
</copy>
<copy file="./target/${maven.project.artifactId}-${maven.project.version}.jar"
tofile="./target/package/ethereumj.jar"/>
<copy todir="./target/package">
<fileset dir="./target/classes/config"/>
</copy>
<copy file="./target/classes/log4j.properties" todir="./target/package/config"/>
<copy file="./target/classes/system.properties" todir="./target/package/config"/>
<copy file="./target/classes/GeoLiteCity.dat" todir="./target/package/config"/>
<zip destfile="ethereumJ-${DSTAMP}-${TSTAMP}.zip" basedir="./target/package">
</zip>
</target>
<target name="run" depends="init, make-package"></target>
</project>

View File

@ -4,18 +4,14 @@
<groupId>org.ethereum</groupId>
<artifactId>ethereumj</artifactId>
<packaging>jar</packaging>
<version>0.1-SNAPSHOT</version>
<version>0.5.1</version>
<name>EthereumJ</name>
<url>http://www.ethereumj.org</url>
<!--
* To deploy all the classes and dependencies to one jar,
* that's one option to pack stand alone.
mvn clean package dependency:copy-dependencies -Dmaven.test.skip=true
* To deploy the classes in one jar and dependencies to another dir
mvn clean package -Dmaven.test.skip=true
-->
<properties>
@ -85,6 +81,13 @@ mvn clean package -Dmaven.test.skip=true
<version>4.1</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.15.0-GA</version>
</dependency>
<!-- remove the real commons-logging from classpath -->
<!-- declare as provided or exclude from spring jars -->
@ -149,25 +152,22 @@ mvn clean package -Dmaven.test.skip=true
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<archive>
<manifest>
<mainClass>org.ethereum.gui.ToolBar</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>prepare-package</phase>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependency</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
@ -185,6 +185,29 @@ mvn clean package -Dmaven.test.skip=true
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<property name="maven.project.artifactId" value="${project.artifactId}"/>
<property name="maven.project.version" value="${project.version}"/>
<ant antfile="build-post-package.xml" target="run"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -1,5 +1,7 @@
package org.ethereum.config;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
@ -23,12 +25,23 @@ public class SystemProperties {
public SystemProperties() {
try {
String filename = "system.properties";
input = SystemProperties.class.getClassLoader().getResourceAsStream(filename);
if (input == null) {
logger.warn("Sorry, unable to find " + filename);
return;
}
File file = null;
String dir = System.getProperty("user.dir");
String fileName = dir + "/config/system.properties";
file = new File(fileName);
if (file.exists()){
input = new FileInputStream(file);
} else{
fileName = "system.properties";
input = SystemProperties.class.getClassLoader().getResourceAsStream(fileName);
if (input == null) {
logger.error("Sorry, unable to find " + fileName);
return;
}
}
//load a properties file from class path, inside static method
prop.load(input);
@ -70,10 +83,15 @@ public class SystemProperties {
public String peerDiscoveryIP(){
if(prop.isEmpty()) return "";
if(prop.isEmpty()) return "54.201.28.117";
return prop.getProperty("peer.discovery.ip");
}
public int peerDiscoveryPort(){
if(prop.isEmpty()) return 30303;
return Integer.parseInt(prop.getProperty("peer.discovery.port"));
}
public String toString() {
Enumeration<?> e = prop.propertyNames();
while (e.hasMoreElements()) {

View File

@ -19,13 +19,16 @@ public class IpGeoDB { // change
File file = null;
try {
URL geiIpDBFile = ClassLoader.getSystemResource("GeoLiteCity.dat");
file = new File(geiIpDBFile.toURI());
} catch (Throwable th) {
String dir = System.getProperty("user.dir");
String fileName = dir + "/db/GeoLiteCity.dat";
String fileName = dir + "/config/GeoLiteCity.dat";
file = new File(fileName);
if (!file.exists()){
URL geiIpDBFile = ClassLoader.getSystemResource("GeoLiteCity.dat");
file = new File(geiIpDBFile.toURI());
}
} catch (Throwable th) {
th.printStackTrace();
System.exit(-1);
}
cl = new LookupService(file);
} catch (Throwable e) {

View File

@ -235,6 +235,7 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog{
return;
}
// todo: check up how the HEX value is encoded
Object[] lexaList = msgDataTA.getText().split(",");
byte[] data = ByteUtil.encodeDataList(lexaList);

View File

@ -1,5 +1,6 @@
package org.ethereum.gui;
import org.apache.log4j.PropertyConfigurator;
import org.ethereum.manager.MainData;
import org.ethereum.util.Utils;
import org.slf4j.Logger;
@ -18,6 +19,7 @@ import java.awt.event.ItemListener;
*/
public class ToolBar extends JFrame {
Logger logger = LoggerFactory.getLogger(getClass());
Logger introLogger = LoggerFactory.getLogger("Intro");
@ -31,10 +33,10 @@ public class ToolBar extends JFrame {
public ToolBar() throws HeadlessException {
introLogger.info("");
introLogger.info(" EthereumJ [v0.5.1] by RomanJ");
introLogger.info(" Code by Roman Mandeleil, (c) 2014.");
introLogger.info(" Contribution: Nick Savers ");
introLogger.info(" Based on a design by Vitalik Buterin.");
introLogger.info("<> EthereumJ [v0.5.1] by RomanJ");
introLogger.info("<> Code by Roman Mandeleil, (c) 2014.");
introLogger.info("<> Contribution: Nick Savers ");
introLogger.info("<> Based on a design by Vitalik Buterin.");
introLogger.info("");
introLogger.info("java.version: " + System.getProperty("java.version"));
introLogger.info("java.home: " + System.getProperty("java.home"));

View File

@ -51,15 +51,17 @@ public class MainData {
public MainData() {
InetAddress ip = null;
int port = 0;
try {
ip = InetAddress.getByName(CONFIG.peerDiscoveryIP());
port = CONFIG.peerDiscoveryPort();
} catch (UnknownHostException e) {
System.exit(-1);
e.printStackTrace();
System.exit(-1);
}
PeerData peer = new PeerData(
ip.getAddress(), (short) 30303, new byte[]{00});
ip.getAddress(), port, new byte[]{00});
peers.add(peer);
byte[] cowAddr = HashUtil.sha3("cow".getBytes());

View File

@ -19,7 +19,7 @@ public class PeerData {
private transient boolean isOnline = false;
private transient long lastCheckTime = 0;
public PeerData(byte[] ip, short port, byte[] peerId) {
public PeerData(byte[] ip, int port, byte[] peerId) {
this.ip = ip;
this.port = port & 0xFFFF;
this.peerId = peerId;

View File

@ -0,0 +1,2 @@
call java -Dlog4j.configuration=file:./config/log4j.properties -jar ethereumj.jar
pause

View File

@ -6,8 +6,9 @@ server.acceptConnections = false
# one default access point to start
# discover the network e.g. [54.201.28.117]
# discover the network e.g. ip: [54.201.28.117] port: [30303]
peer.discovery.ip = 54.201.28.117
peer.discovery.port = 30303
# specify if the mechanism
# to discover more and more