prepare application to deploy as a jar with lib of dependencies

This commit is contained in:
romanman 2014-05-22 16:56:30 +03:00
parent cff3395b78
commit 23250da8eb
6 changed files with 64 additions and 14 deletions

View File

@ -8,9 +8,15 @@
<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.
<!--
* 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>
@ -81,12 +87,7 @@ mvn clean package dependency:copy-dependencies -Dmaven.test.skip=true
</dependency>
<dependency>
<groupId>org.python</groupId>
<artifactId>jython</artifactId>
<version>2.5.3</version>
</dependency>
<!-- Consumers are expected to provide their own SLF4J adapters such as
<!-- Consumers are expected to provide their own SLF4J adapters such as
logback, slf4j-log4j12, slf4j-jcl and so on see http://www.slf4j.org/faq.html -->
<dependency>
<groupId>org.slf4j</groupId>
@ -123,17 +124,46 @@ mvn clean package dependency:copy-dependencies -Dmaven.test.skip=true
<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>
<executions>
<execution>
<id>make-assembly</id>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>org.ethereum.gui.ToolBar</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>

View File

@ -2,6 +2,7 @@ package org.ethereum.geodb;
import java.io.File;
import java.net.InetAddress;
import java.net.URISyntaxException;
import java.net.URL;
import com.maxmind.geoip.Location;
@ -16,8 +17,17 @@ public class IpGeoDB { // change
static{
try {
URL geiIpDBFile = ClassLoader.getSystemResource("GeoLiteCity.dat");
File file = new File(geiIpDBFile.toURI());
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";
file = new File(fileName);
}
cl = new LookupService(file);
} catch (Throwable e) {
e.printStackTrace();

View File

@ -58,7 +58,7 @@ public class PeersTableModel extends AbstractTableModel {
if (column == 0){
String countryCode = peerInfo.getLocation().countryCode;
URL flagURL = ClassLoader.getSystemResource("flags/" + countryCode + ".png");
URL flagURL = ClassLoader.getSystemResource("flags/" + countryCode.toLowerCase() + ".png");
ImageIcon flagIcon = new ImageIcon(flagURL);
return flagIcon;
}

View File

@ -78,7 +78,6 @@ public class PeersTableWindow extends JFrame{
public void run() {
table.revalidate();
table.repaint();
System.out.println("repaint");
}
}, 1000, 1000);

View File

@ -140,7 +140,9 @@ public class MainData {
Location location = IpGeoDB.getLocationForIp(peer.getInetAddress());
if (location != null){
this.peers.add(peer);
peerDiscovery.addNewPeerData(peer);
if (peerDiscovery.isStarted())
peerDiscovery.addNewPeerData(peer);
}
}
}

View File

@ -20,6 +20,8 @@ public class PeerDiscovery {
PeerDiscoveryMonitorThread monitor;
List<PeerData> peers;
boolean started = false;
public PeerDiscovery(List<PeerData> peers) {
this.peers = peers;
}
@ -45,6 +47,7 @@ public class PeerDiscovery {
executorPool.execute(new WorkerThread(peerData, executorPool));
}
started = true;
}
public void addNewPeerData(PeerData peerData){
@ -57,6 +60,10 @@ public class PeerDiscovery {
}
public boolean isStarted() {
return started;
}
// todo: this main here for test erase it once upon a time
public static void main(String args[]) throws InterruptedException{
@ -93,5 +100,7 @@ public class PeerDiscovery {
monitor.shutdown();
}
}