Skip to content

Commit 19e7d61

Browse files
author
Maxim Amelchenko
committed
Change structure of project to allow Gradle import from IDEs and change build to produce Jar as library and do copy dependencies
1 parent 7b074e4 commit 19e7d61

26 files changed

+107
-99
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ Written in Java 8.
3232

3333
Built with Gradle.
3434

35+
# Installation
36+
37+
Get the code and build:
38+
39+
```
40+
git clone https://github.com/maxmale/GDH.git
41+
cd GDH
42+
gradle clean build
43+
```
44+
45+
Get the generated Jar from the root of the project. Add it to the build path of your project and start using it.
46+
3547
# Usage
3648

3749
The basic usage of the library is spinning up verticles and initiating a key exchange between them.

build.gradle

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ apply plugin: 'findbugs'
1616
}
1717

1818
libsDirName = '../'
19-
version = '0.91'
19+
version = '0.92'
2020
archivesBaseName = 'GDH'
2121

2222
repositories {
@@ -48,14 +48,15 @@ clean {
4848
delete "libs/"
4949
delete "build/"
5050
delete "bin/"
51-
delete "GDH-1.1.jar"
51+
delete project.name+"-"+project.version+".jar"
5252
}
5353

5454
jar {
5555
dependsOn configurations.runtime
5656
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
5757
manifest {
58-
attributes 'Main-Class': 'main.java.gdh.Main'
58+
attributes 'Implementation-Title': project.name,
59+
'Implementation-Version': project.version
5960
}
6061
exclude "META-INF/*.SF"
6162
exclude "META-INF/*.DSA"
@@ -65,14 +66,10 @@ jar {
6566
task testSuite(type: Test) {
6667
include '**VertxTestSuite.class'
6768
}
68-
task copyDeps(type: Copy) {
69-
into 'libs'
70-
from configurations.testRuntime
71-
}
69+
7270
task deleteBuild(type: Delete) {
7371
delete "build/"
7472
delete "bin/"
7573
}
76-
copyDeps.dependsOn(testSuite)
74+
7775
build.dependsOn(deleteBuild)
78-
deleteBuild.dependsOn(copyDeps)

src/main/java/crypto/CipherAgent.java renamed to src/main/java/com/gdh/crypto/CipherAgent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main.java.crypto;
1+
package com.gdh.crypto;
22

33
import java.io.IOException;
44
import java.io.UnsupportedEncodingException;

src/main/java/crypto/CipherAgentImpl.java renamed to src/main/java/com/gdh/crypto/CipherAgentImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main.java.crypto;
1+
package com.gdh.crypto;
22

33
import java.io.ByteArrayInputStream;
44
import java.io.ByteArrayOutputStream;
@@ -17,7 +17,7 @@
1717
import javax.crypto.spec.IvParameterSpec;
1818

1919
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
20-
import main.java.gdh.Constants;
20+
import com.gdh.main.Constants;
2121

2222
/**
2323
*

src/main/java/gdh/Configuration.java renamed to src/main/java/com/gdh/main/Configuration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main.java.gdh;
1+
package com.gdh.main;
22

33
import java.io.OutputStreamWriter;
44
import java.io.PrintWriter;
@@ -37,7 +37,7 @@
3737
*/
3838
public class Configuration {
3939
private String IP = "localhost";
40-
private String port = "1080";
40+
private String port = "1090";
4141
private int retries = 5;
4242
private int exchangeTimeout = 60000;
4343
private String prime = "AD107E1E9123A9D0D660FAA79559C51FA20D64E5683B9FD1B54B1597B61D0A75E6FA141DF95A56DBAF9A3C"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main.java.gdh;
1+
package com.gdh.main;
22

33
public final class Constants {
44

src/main/java/gdh/ExchangeState.java renamed to src/main/java/com/gdh/main/ExchangeState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main.java.gdh;
1+
package com.gdh.main;
22

33
import java.math.BigInteger;
44
import java.security.SecureRandom;
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main.java.gdh;
1+
package com.gdh.main;
22

33
import java.util.HashMap;
44
import java.util.Map;
@@ -17,9 +17,9 @@
1717
import io.vertx.core.net.NetServer;
1818
import io.vertx.core.net.NetServerOptions;
1919
import io.vertx.core.net.NetSocket;
20-
import main.java.parser.JsonMessageParser;
21-
import main.java.parser.MessageConstructor;
22-
import main.java.parser.MessageParser;
20+
import com.gdh.parser.JsonMessageParser;
21+
import com.gdh.parser.MessageConstructor;
22+
import com.gdh.parser.MessageParser;
2323

2424
import java.math.BigInteger;
2525

@@ -86,7 +86,7 @@ public void start(Future<Void> future) throws Exception {
8686
conf.getLogger().info(getNode().toString() + " started listening on: " + conf.getPort());
8787
} else {
8888
future.fail(res.cause());
89-
conf.getLogger().info(getNode().toString() + " startup failure: " + conf.getPort());
89+
conf.getLogger().info(getNode().toString() + " startup failure: " + conf.getPort() + " " + res.cause().getMessage());
9090
}
9191
});
9292

@@ -251,13 +251,13 @@ private CompletableFuture<Boolean> sendMessage(Node n, JsonObject msg) {
251251
if (timingAndRetries[1] == conf.getRetries()) {
252252
// No more retries left. Exit...
253253
conf.getLogger().error(getNode().toString() + " Retry parameter exceeded " + conf.getRetries());
254+
future.completeExceptionally(
255+
new TimeoutException(Constants.EXCEPTIONRETRIESEXCEEDED + conf.getRetries()));
254256
if (socket != null)
255257
socket.close();
256258
vertx.cancelTimer(timingAndRetries[0]);
257259
tcpClient.close();
258260
server.close();
259-
future.completeExceptionally(
260-
new TimeoutException(Constants.EXCEPTIONRETRIESEXCEEDED + conf.getRetries()));
261261
}
262262
}));
263263
}));
@@ -272,7 +272,7 @@ public void stop(Future<Void> future) throws Exception {
272272
conf.getLogger().info(getNode().toString() + " stopped listening on: " + conf.getPort());
273273
} else {
274274
future.fail(res.cause());
275-
conf.getLogger().info(getNode().toString() + " stoppage failure: " + conf.getPort());
275+
conf.getLogger().info(getNode().toString() + " stoppage failure: " + conf.getPort() + res.cause().getMessage());
276276
}
277277
});
278278
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main.java.gdh;
1+
package com.gdh.main;
22

33
import java.math.BigInteger;
44
import java.util.Arrays;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main.java.gdh;
1+
package com.gdh.main;
22

33
/**
44
*

0 commit comments

Comments
 (0)