Skip to content

Commit

Permalink
Windows Installer
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Nguyen committed Feb 7, 2018
1 parent 2f1642f commit f931f48
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 66 deletions.
6 changes: 3 additions & 3 deletions clavis_exe_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>/Users/andrew_nguyen/Desktop/Builds/Clavis_Wallet_main.jar</jar>
<jar>/Users/andrew_nguyen/Desktop/test.jar</jar>
<outfile>/Users/andrew_nguyen/Desktop/Builds/Windows/Clavis Wallet3.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
Expand All @@ -24,11 +24,11 @@
<runtimeBits>64/32</runtimeBits>
</jre>
<versionInfo>
<fileVersion>1.1.1.0</fileVersion>
<fileVersion>1.1.2.0</fileVersion>
<txtFileVersion>Clavis Wallet Alpha Release</txtFileVersion>
<fileDescription>Clavis Wallet Alpha</fileDescription>
<copyright>Bitcoin Latina Foundation</copyright>
<productVersion>1.1.1.0</productVersion>
<productVersion>1.1.2.0</productVersion>
<txtProductVersion>Clavis Wallet Alpha</txtProductVersion>
<productName>Clavis Wallet</productName>
<companyName></companyName>
Expand Down
57 changes: 31 additions & 26 deletions src/main/java/build_structure/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.logging.Logger;

public class Build {
/**
* This Class Is Used To Insert Config Files And Binaries
*/
private static final Logger LOGGER = Logger.getLogger(Build.class.getName());
private static final Logger LOGGER = Logger.getLogger(Init.class.getName());
private String mainFolder = Global.getPath() + File.separator + "BCL_CL";
//>> External Paths
final private String winEthminerBinary = Global.getPath() + File.separator + "ethminer.exe";
Expand All @@ -40,13 +39,18 @@ public class Build {

public void BCLFolder() {
LOGGER.addHandler(Global.getLog_fh());
LOGGER.config("Adding BCL Folder");
LOGGER.info("Adding BCL Folder");
try {
Path path = Paths.get(mainFolder);
Files.createDirectories(path);
//Create BCL_Node Folder
Path path2 = Paths.get(mainFolder+File.separator+"BCL_Node");
Files.createDirectories(path2);
//Create Geth Folder For Static Nodes
Path path3 = Paths.get(mainFolder+File.separator+"BCL_Node"+File.separator+"geth");
Files.createDirectories(path3);
} catch (IOException e) {
e.printStackTrace();
LOGGER.warning("COULDN'T CREATE BCL_FOLDER \n\n" + Arrays.toString(e.getStackTrace()));
LOGGER.warning("COULDN'T CREATE BCL_FOLDER \n\n" + e.getStackTrace());
LOGGER.warning("Attempted creating BCL Folder at " + mainFolder);
//Create Alert ->
Alert alert = new Alert(Alert.AlertType.ERROR);
Expand All @@ -59,49 +63,50 @@ public void BCLFolder() {

public void binaries() {
LOGGER.addHandler(Global.getLog_fh());
LOGGER.config("Adding Binaries");
LOGGER.info("Adding Binaries");
LOGGER.info("PATH IS " + Global.getPath());
if (Global.getOS().contains("win")) {
String winGethBinaryRes = "/binaries/windows/geth.exe";
String winGethBinaryRes = "binaries"+File.separator+"windows"+File.separator+"geth.exe";
Utils.export_resource(winGethBinaryRes, winGethBinary);
LOGGER.config("Windows Geth Added");
String winGenesisRes = "/json/genesis.json";
LOGGER.info("Windows Geth Added");
String winGenesisRes = "json"+File.separator+"genesis.json";
Utils.export_resource(winGenesisRes, winGenesis);
LOGGER.config("Windows Genesis File Added");
String winEthminerBinaryRes = "/binaries/windows/ethminer.exe";
LOGGER.info("Windows Genesis File Added");
String winEthminerBinaryRes = "binaries"+File.separator+"windows"+File.separator+"ethminer.exe";
Utils.export_resource(winEthminerBinaryRes, winEthminerBinary);
LOGGER.config("Windows Ethminer Added");
String winStaticNodeRes = "/json/static-nodes.json";
LOGGER.info("Windows Ethminer Added");
String winStaticNodeRes = "json"+File.separator+"static-nodes.json";
Utils.export_resource(winStaticNodeRes, winStaticNode);
} else if (Global.getOS().contains("mac")) {
String macGethBinaryRes = "/binaries/mac/geth";
String macGethBinaryRes = "binaries"+File.separator+"mac"+File.separator+"geth";
Utils.export_resource(macGethBinaryRes, macGethBinary);
LOGGER.config("Mac Geth Added");
String macGenesisRes = "/json/genesis.json";
LOGGER.info("Mac Geth Added");
String macGenesisRes = "json"+File.separator+"genesis.json";
Utils.export_resource(macGenesisRes, macGenesis);
LOGGER.config("Mac Genesis File Added");
String macEthminerBinaryRes = "/binaries/mac/ethminer";
LOGGER.info("Mac Genesis File Added");
String macEthminerBinaryRes = "binaries"+File.separator+"mac"+File.separator+"ethminer";
Utils.export_resource(macEthminerBinaryRes, macEthminerBinary);
LOGGER.config("Mac Ethminer Added");
String macStaticNodeRes = "/json/static-nodes.json";
LOGGER.info("Mac Ethminer Added");
String macStaticNodeRes = "json"+File.separator+"static-nodes.json";
Utils.export_resource(macStaticNodeRes, macStaticNode);
}
//Linux Support Coming...
}

public void commands() {
if (Global.getOS().contains("win")) {
String winStartCommandRes = "/commands/windows/start.cmd";
String winStartCommandRes = "commands"+File.separator+"windows"+File.separator+"start.cmd";
Utils.export_resource(winStartCommandRes, winStartCommand);
String winGethCommandRes = "/commands/windows/geth.cmd";
String winGethCommandRes = "commands"+File.separator+"windows"+File.separator+"geth.cmd";
Utils.export_resource(winGethCommandRes, winGethCommand);
String winEthMinerCommandRes = "/commands/windows/ethminer.cmd";
String winEthMinerCommandRes = "commands"+File.separator+"windows"+File.separator+"ethminer.cmd";
Utils.export_resource(winEthMinerCommandRes, winEthMinerCommand);
} else if (Global.getOS().contains("mac")) {
String macStartCommandRes = "/commands/mac/start.command";
String macStartCommandRes = "commands"+File.separator+"mac"+File.separator+"start.command";
Utils.export_resource(macStartCommandRes, macStartCommand);
String macGethCommandRes = "/commands/mac/geth.command";
String macGethCommandRes = "commands"+File.separator+"mac"+File.separator+"geth.command";
Utils.export_resource(macGethCommandRes, macGethCommand);
String macEthMinerCommandRes = "/commands/mac/ethminer.command";
String macEthMinerCommandRes = "commands"+File.separator+"mac"+File.separator+"ethminer.command";
Utils.export_resource(macEthMinerCommandRes, macEthMinerCommand);
}
//Linux Support Coming...
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/build_structure/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public void start() {
}
startProcess(pb);
} catch (IOException e) {
e.printStackTrace();
LOGGER.warning("UNABLE TO RUN START COMMAND \n\n"+ Arrays.toString(e.getStackTrace()));
System.exit(1);
}
Expand Down Expand Up @@ -70,7 +69,6 @@ public void geth() {
}
startProcess(pb);
} catch (IOException e) {
e.printStackTrace();
LOGGER.warning("UNABLE TO RUN GETH COMMAND \n\n"+ Arrays.toString(e.getStackTrace()));
System.exit(1);
}
Expand All @@ -93,7 +91,6 @@ public void mine() {
}
Global.getAppProcesses().add(p);
} catch (IOException e) {
e.printStackTrace();
LOGGER.warning("UNABLE TO RUN MINING COMMAND " + Arrays.toString(e.getStackTrace()));
System.exit(1);
}
Expand Down Expand Up @@ -123,11 +120,10 @@ public static void kill_geth_ethminer() {
}
}
} catch (IOException e) {
e.printStackTrace();
LOGGER.warning("Unable to Kill Ethminer/Geth" + Arrays.toString(e.getStackTrace()));
System.exit(1);
} catch (InterruptedException e) {
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/build_structure/Permission_Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public static void permission() {
}
}
} catch (IOException e) {
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
LOGGER.warning("COULDN'T CHANGE THE BCL_CL Permissions\n\n"+ Arrays.toString(e.getStackTrace()));
System.exit(1);
} catch (InterruptedException e) {
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
}
}
}
7 changes: 3 additions & 4 deletions src/main/java/build_structure/Structure_Check.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@ public static void check_Structure() {
!commandCheck() || !staticNodeCheck()) {
LOGGER.warning("Certain Files Were Not Found in BCL_CL Dir");
Global.setState(0);
LOGGER.config("Building Binaries");
LOGGER.info("Building Binaries");
new Build().binaries();
LOGGER.config("Building Command Files");
LOGGER.info("Building Command Files");
new Build().commands();
Permission_Commands.permission();
}

if (Global.getState() == 0) {
//Uninitialized
LOGGER.config("Geth Start Command Issued");
LOGGER.info("Geth Start Command Issued");
new Commands().start();
} else {
//Initialized
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rpc/RPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static String sendRPC(JSONObject j, Boolean popups) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/ui/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.logging.FileHandler;
Expand Down Expand Up @@ -179,7 +180,7 @@ public static void update_information() {
}
Global.setMain_account(new Accounts().getAccounts().get(0));
} catch (Exception e) {
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
}
}

Expand All @@ -193,7 +194,7 @@ public static void setup_logger_fh(){
SimpleFormatter formatter = new SimpleFormatter();
log_fh.setFormatter(formatter);
} catch (SecurityException | IOException e) {
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
}
}
private static void syncingCheck(){
Expand Down
17 changes: 14 additions & 3 deletions src/main/java/ui/Init.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ui;

import build_structure.Commands;
import build_structure.Permission_Commands;
import build_structure.Structure_Check;
import javafx.animation.PauseTransition;
import javafx.application.Application;
Expand All @@ -17,7 +18,9 @@
import web3j.Subscribe;
import web3j.accounts.Accounts;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -67,7 +70,15 @@ public static void initialize() {
//Get OS
Utils.set_os(System.getProperty("os.name").toLowerCase());
//Check folder Structure
Structure_Check.check_Structure();
//TODO IF ADDING WINDOWS INSTALLER CAN CHECK FOR OS
if(Global.getOS().contains("win")){
//Initialized
Global.setPath(Global.getPath() + File.separator + "BCL_CL");
Permission_Commands.permission();
new Commands().geth();
}else{
Structure_Check.check_Structure();
}
//Get Web3j
//Initialize web3j functionality
new Setup().setupWeb3();
Expand All @@ -77,7 +88,7 @@ public static void initialize() {
try {
new New_Account_Popup().start(new Stage());
} catch (Exception e) {
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
}
} else {
start();
Expand Down Expand Up @@ -152,7 +163,7 @@ public static void toAnotherPage(String page_name) {
break;
}
} catch (IOException e) {
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ui/controllers/Dashboard_Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private void setOtherAccounts(List<Account> list) {
} catch (Exception e) {
LOGGER.warning("UNABLE TO CREATE COPY POPUP\n\n" +
Arrays.toString(e.getStackTrace()));
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
}
}
}
Expand Down Expand Up @@ -241,7 +241,7 @@ private void mining_popup() {
try {
new Mining_Popup().start(new Stage());
} catch (Exception e) {
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ui/controllers/Personal_Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;

Expand Down Expand Up @@ -86,7 +87,7 @@ private void createNewAccount(){
set_dropdown(new Accounts().getAccounts());
} catch (IOException e) {
LOGGER.warning("COULD NOT SETUP DROPDOWWN");
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
}
}
}
Expand Down
30 changes: 23 additions & 7 deletions src/main/java/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Objects;
import java.util.logging.Logger;
Expand Down Expand Up @@ -38,18 +41,31 @@ public static boolean Is_Empty_File(String path) {
return true;
}
}

public static void export_resource(String from, String to) {
LOGGER.addHandler(Global.getLog_fh());
URL from_u = Utils.class.getClass().getResource(from);
File to_u = new File(to);
public static void export_resource(String from, String to){
// this is the path within the jar file
InputStream input = Utils.class.getResourceAsStream("/resources/" + from);
if (input == null) {
// this is how we load file within editor (eg eclipse)
input = Utils.class.getClassLoader().getResourceAsStream(from);
}
try {
FileUtils.copyURLToFile(from_u, to_u);
Files.copy(input, Paths.get(to));
} catch (IOException e) {
LOGGER.warning("UNABLE TO EXPORT " + from_u + "\n\n" + Arrays.toString(e.getStackTrace()));
e.printStackTrace();
}
}
// public static void export_resource(String from, String to) {
// LOGGER.addHandler(Global.getLog_fh());
// URL from_u = Utils.class.getResource(File.separator+from);
// File to_u = new File(to);
// LOGGER.warning("\n\nFrom U "+ File.separator+from_u + "\n\n");
// try {
// FileUtils.copyURLToFile(from_u, to_u);
// } catch (IOException e) {
// LOGGER.warning("UNABLE TO EXPORT " + from_u + "\n\n" + Arrays.toString(e.getStackTrace()));
// e.printStackTrace();
// }
// }

static BigInteger conversion = BigInteger.valueOf(1000000000000000000l);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/web3j/Blocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void subscribe() {
//Update Every 5 Seconds
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
LOGGER.warning(Arrays.toString(e.getStackTrace()));
}
try {
//Update Ui From Background Thread
Expand Down
Loading

0 comments on commit f931f48

Please sign in to comment.