From f34d1f49dc0858b4885d3509fbc510b87bf8cdb3 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 6 Jan 2015 09:50:58 +0100 Subject: [PATCH 1/7] Polish changes made in pull request #189 - Organize imports using shared IDEA configuration - Format sources, including: - Normalize 4-space indentation - Wrap at 120 char right margin - Remove spaces around method arguments --- .../ethereum/net/DisconnectMessageTest.java | 28 ++++------- .../ethereum/net/GetPeersMessageTest.java | 19 ++++--- .../test/ethereum/net/HelloMessageTest.java | 49 ++++++++---------- .../test/java/test/ethereum/net/PeerTest.java | 43 ++++++++-------- .../test/ethereum/net/PeersMessageTest.java | 50 ++++++++----------- .../test/ethereum/net/StatusMessageTest.java | 30 ++++++----- 6 files changed, 101 insertions(+), 118 deletions(-) diff --git a/ethereumj-core/src/test/java/test/ethereum/net/DisconnectMessageTest.java b/ethereumj-core/src/test/java/test/ethereum/net/DisconnectMessageTest.java index f18b2fd5..0eb2741a 100644 --- a/ethereumj-core/src/test/java/test/ethereum/net/DisconnectMessageTest.java +++ b/ethereumj-core/src/test/java/test/ethereum/net/DisconnectMessageTest.java @@ -1,11 +1,5 @@ package test.ethereum.net; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; - -import java.lang.System; - import org.ethereum.net.message.ReasonCode; import org.ethereum.net.p2p.DisconnectMessage; @@ -13,7 +7,7 @@ import org.junit.Test; import org.spongycastle.util.encoders.Hex; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; public class DisconnectMessageTest { @@ -85,12 +79,12 @@ public class DisconnectMessageTest { String disconnectMessageRaw = "C19999"; byte[] payload = Hex.decode(disconnectMessageRaw); - try{ - DisconnectMessage disconnectMessage = new DisconnectMessage(payload); - disconnectMessage.toString(); //throws exception - assertTrue("Valid raw encoding for disconnectMessage", false); + try { + DisconnectMessage disconnectMessage = new DisconnectMessage(payload); + disconnectMessage.toString(); //throws exception + assertTrue("Valid raw encoding for disconnectMessage", false); } catch (RuntimeException e) { - assertTrue("Invalid raw encoding for disconnectMessage", true); + assertTrue("Invalid raw encoding for disconnectMessage", true); } } @@ -100,12 +94,12 @@ public class DisconnectMessageTest { String disconnectMessageRaw = "C28081"; byte[] payload = Hex.decode(disconnectMessageRaw); - try{ - DisconnectMessage disconnectMessage = new DisconnectMessage(payload); - disconnectMessage.toString(); //throws exception - assertTrue("Valid raw encoding for disconnectMessage", false); + try { + DisconnectMessage disconnectMessage = new DisconnectMessage(payload); + disconnectMessage.toString(); //throws exception + assertTrue("Valid raw encoding for disconnectMessage", false); } catch (RuntimeException e) { - assertTrue("Invalid raw encoding for disconnectMessage", true); + assertTrue("Invalid raw encoding for disconnectMessage", true); } } } diff --git a/ethereumj-core/src/test/java/test/ethereum/net/GetPeersMessageTest.java b/ethereumj-core/src/test/java/test/ethereum/net/GetPeersMessageTest.java index cd59fbb1..c22e2ae2 100644 --- a/ethereumj-core/src/test/java/test/ethereum/net/GetPeersMessageTest.java +++ b/ethereumj-core/src/test/java/test/ethereum/net/GetPeersMessageTest.java @@ -1,11 +1,13 @@ package test.ethereum.net; -import static org.junit.Assert.assertEquals; +import org.ethereum.net.p2p.GetPeersMessage; +import org.ethereum.net.p2p.P2pMessageCodes; + +import org.junit.Test; import org.spongycastle.util.encoders.Hex; -import org.ethereum.net.p2p.P2pMessageCodes; -import org.ethereum.net.p2p.GetPeersMessage; -import org.junit.Test; + +import static org.junit.Assert.assertEquals; public class GetPeersMessageTest { @@ -13,24 +15,21 @@ public class GetPeersMessageTest { @Test public void testGetPeers() { - + //Init GetPeersMessage getPeersMessage = new GetPeersMessage(); - //System.out.println(getPeersMessage.getEncoded()); - //toString assertEquals("[GET_PEERS]", getPeersMessage.toString()); //getEncoded - assertEquals("C104", Hex.toHexString( getPeersMessage.getEncoded() ).toUpperCase() ); + assertEquals("C104", Hex.toHexString(getPeersMessage.getEncoded()).toUpperCase()); //getAnswerMessage assertEquals(null, getPeersMessage.getAnswerMessage()); - + //getCommand assertEquals(P2pMessageCodes.GET_PEERS, getPeersMessage.getCommand()); - } } diff --git a/ethereumj-core/src/test/java/test/ethereum/net/HelloMessageTest.java b/ethereumj-core/src/test/java/test/ethereum/net/HelloMessageTest.java index 7d2c2ebf..099fc36b 100644 --- a/ethereumj-core/src/test/java/test/ethereum/net/HelloMessageTest.java +++ b/ethereumj-core/src/test/java/test/ethereum/net/HelloMessageTest.java @@ -1,17 +1,12 @@ package test.ethereum.net; -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; -import java.util.List; -import java.util.ArrayList; - import org.ethereum.net.client.Capability; import org.ethereum.net.eth.EthHandler; import org.ethereum.net.p2p.HelloMessage; -import org.ethereum.net.p2p.P2pMessageCodes; import org.ethereum.net.p2p.P2pHandler; +import org.ethereum.net.p2p.P2pMessageCodes; import org.ethereum.net.shh.ShhHandler; + import org.junit.Test; import org.slf4j.Logger; @@ -19,6 +14,9 @@ import org.slf4j.LoggerFactory; import org.spongycastle.util.encoders.Hex; +import java.util.Arrays; +import java.util.List; + import static org.junit.Assert.assertEquals; public class HelloMessageTest { @@ -41,12 +39,10 @@ public class HelloMessageTest { assertEquals(2, helloMessage.getCapabilities().size()); assertEquals(992, helloMessage.getListenPort()); assertEquals( - "1fbf1e41f08078918c9f7b6734594ee56d7f538614f602c71194db0a1af5a77f9b86eb14669fe7a8a46a2dd1b7d070b94e463f4ecd5b337c8b4d31bbf8dd5646", - helloMessage.getPeerId()); - - + "1fbf1e41f08078918c9f7b6734594ee56d7f538614f602c71194db0a1af5a77f9b86eb14669fe7a8a46a2dd1b7d070b94e463f4ecd5b337c8b4d31bbf8dd5646", + helloMessage.getPeerId()); } - + //Instantiate from constructor @Test public void test2() { @@ -54,9 +50,9 @@ public class HelloMessageTest { byte version = 2; String clientStr = "Ethereum(++)/v0.7.9/Release/Linux/g++"; List capabilities = Arrays.asList( - new Capability( Capability.ETH, EthHandler.VERSION), - new Capability( Capability.SHH, ShhHandler.VERSION), - new Capability( Capability.P2P, P2pHandler.VERSION) ); + new Capability(Capability.ETH, EthHandler.VERSION), + new Capability(Capability.SHH, ShhHandler.VERSION), + new Capability(Capability.P2P, P2pHandler.VERSION)); int listenPort = 992; String peerId = "1fbf1e41f08078918c9f7b6734594ee56d7f538614f602c71194db0a1af5a"; @@ -66,10 +62,10 @@ public class HelloMessageTest { assertEquals(P2pMessageCodes.HELLO, helloMessage.getCommand()); assertEquals(version, helloMessage.getP2PVersion()); assertEquals(clientStr, helloMessage.getClientId()); - assertEquals( 3 , helloMessage.getCapabilities().size()); - assertEquals( listenPort , helloMessage.getListenPort()); - assertEquals( peerId , helloMessage.getPeerId()); - + assertEquals(3, helloMessage.getCapabilities().size()); + assertEquals(listenPort, helloMessage.getListenPort()); + assertEquals(peerId, helloMessage.getPeerId()); + //TODO tostring? } @@ -80,21 +76,20 @@ public class HelloMessageTest { byte version = -1; //invalid version String clientStr = ""; //null id List capabilities = Arrays.asList( - new Capability( null, (byte) 0 ), - new Capability( null, (byte) 0 ), - null, //null here causes NullPointerException when using toString - new Capability( null, (byte) 0 ) ); //encoding null capabilities + new Capability(null, (byte) 0), + new Capability(null, (byte) 0), + null, //null here causes NullPointerException when using toString + new Capability(null, (byte) 0)); //encoding null capabilities int listenPort = 99999; //invalid port String peerId = ""; //null id HelloMessage helloMessage = new HelloMessage(version, clientStr, capabilities, listenPort, peerId); - //logger.info(helloMessage.toString()); assertEquals(P2pMessageCodes.HELLO, helloMessage.getCommand()); assertEquals(version, helloMessage.getP2PVersion()); assertEquals(clientStr, helloMessage.getClientId()); - assertEquals( 4 , helloMessage.getCapabilities().size()); - assertEquals( listenPort , helloMessage.getListenPort()); - assertEquals( peerId , helloMessage.getPeerId()); + assertEquals(4, helloMessage.getCapabilities().size()); + assertEquals(listenPort, helloMessage.getListenPort()); + assertEquals(peerId, helloMessage.getPeerId()); } } diff --git a/ethereumj-core/src/test/java/test/ethereum/net/PeerTest.java b/ethereumj-core/src/test/java/test/ethereum/net/PeerTest.java index 532119e1..e4b3e0c3 100644 --- a/ethereumj-core/src/test/java/test/ethereum/net/PeerTest.java +++ b/ethereumj-core/src/test/java/test/ethereum/net/PeerTest.java @@ -1,54 +1,57 @@ package test.ethereum.net; -import static org.junit.Assert.assertEquals; - import org.ethereum.net.client.Capability; import org.ethereum.net.p2p.Peer; -import org.spongycastle.util.encoders.Hex; -import java.net.InetAddress; -import java.util.List; -import java.util.ArrayList; import org.junit.Test; +import org.spongycastle.util.encoders.Hex; + +import java.net.InetAddress; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + public class PeerTest { /* PEER */ @Test public void testPeer() { - + //Init InetAddress address = InetAddress.getLoopbackAddress(); - List capabilities = new ArrayList<>(); + List capabilities = new ArrayList<>(); int port = 1010; String peerId = "1010"; - Peer peerCopy = new Peer(address, port, peerId ); + Peer peerCopy = new Peer(address, port, peerId); //Peer - Peer peer = new Peer(address, port, peerId ); + Peer peer = new Peer(address, port, peerId); //getAddress - assertEquals( "127.0.0.1" , peer.getAddress().getHostAddress() ); + assertEquals("127.0.0.1", peer.getAddress().getHostAddress()); //getPort - assertEquals( port , peer.getPort() ); + assertEquals(port, peer.getPort()); //getPeerId - assertEquals( peerId , peer.getPeerId() ); + assertEquals(peerId, peer.getPeerId()); //getCapabilities - assertEquals( capabilities , peer.getCapabilities() ); - + assertEquals(capabilities, peer.getCapabilities()); + //getEncoded - assertEquals("CC847F0000018203F2821010C0", Hex.toHexString( peer.getEncoded() ).toUpperCase() ); - + assertEquals("CC847F0000018203F2821010C0", Hex.toHexString(peer.getEncoded()).toUpperCase()); + //toString - assertEquals("[ip=" + address.getHostAddress() + " port=" + Integer.toString( port ) + " peerId=" + peerId + "]", peer.toString() ); + assertEquals("[ip=" + address.getHostAddress() + " port=" + Integer.toString(port) + " peerId=" + peerId + "]", peer.toString()); //equals - assertEquals(true, peer.equals( peerCopy ) ); - assertEquals(false, peer.equals( null ) ); + assertEquals(true, peer.equals(peerCopy)); + assertEquals(false, peer.equals(null)); //hashCode assertEquals(-1, peer.hashCode()); diff --git a/ethereumj-core/src/test/java/test/ethereum/net/PeersMessageTest.java b/ethereumj-core/src/test/java/test/ethereum/net/PeersMessageTest.java index d5fea9f7..e2987e97 100644 --- a/ethereumj-core/src/test/java/test/ethereum/net/PeersMessageTest.java +++ b/ethereumj-core/src/test/java/test/ethereum/net/PeersMessageTest.java @@ -1,17 +1,5 @@ package test.ethereum.net; -import static org.junit.Assert.assertEquals; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import org.ethereum.net.client.Capability; import org.ethereum.net.p2p.GetPeersMessage; import org.ethereum.net.p2p.P2pMessageCodes; @@ -25,7 +13,14 @@ import org.slf4j.LoggerFactory; import org.spongycastle.util.encoders.Hex; +import java.net.InetAddress; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; import java.util.Iterator; +import java.util.List; +import java.util.Set; import static org.junit.Assert.assertEquals; @@ -66,20 +61,19 @@ public class PeersMessageTest { peer.getPeerId()); } - @Test /* PeersMessage 1 from constructor */ public void testPeers_2() { //Init InetAddress address = InetAddress.getLoopbackAddress(); - List capabilities = new ArrayList<>(); + List capabilities = new ArrayList<>(); int port = 112; String peerId = "36659c3656c488437cceb11abeb9b9fc69b8055144a7e7db3584d03e606083f90e" + - "17a1d3021d674579407cdaaafdfeef485872ab719db9f2b6283f498bb90a71"; - + "17a1d3021d674579407cdaaafdfeef485872ab719db9f2b6283f498bb90a71"; + Set peers = new HashSet<>(); - peers.add(new Peer(address, port, peerId )); - - PeersMessage peersMessage= new PeersMessage(peers); + peers.add(new Peer(address, port, peerId)); + + PeersMessage peersMessage = new PeersMessage(peers); logger.info(peersMessage.toString()); assertEquals(1, peersMessage.getPeers().size()); @@ -91,7 +85,7 @@ public class PeersMessageTest { assertEquals("127.0.0.1", peer.getAddress().getHostAddress()); assertEquals(112, peer.getPort()); assertEquals("36659c3656c488437cceb11abeb9b9fc69b8055144a7e7db3584d03e6" + - "06083f90e17a1d3021d674579407cdaaafdfeef485872ab719db9f2b6283f498bb90a71", peer.getPeerId()); + "06083f90e17a1d3021d674579407cdaaafdfeef485872ab719db9f2b6283f498bb90a71", peer.getPeerId()); } @Test /* failing test */ @@ -99,16 +93,16 @@ public class PeersMessageTest { //Init InetAddress address = InetAddress.getLoopbackAddress(); List capabilities = Arrays.asList( - new Capability( null, (byte) 0 ), - null //null here can cause NullPointerException when using toString - ); //encoding null capabilities + new Capability(null, (byte) 0), + null //null here can cause NullPointerException when using toString + ); //encoding null capabilities int port = -1; //invalid port String peerId = ""; //invalid peerid - + Set peers = new HashSet<>(); - peers.add(new Peer(address, port, peerId )); - - PeersMessage peersMessage= new PeersMessage(peers); + peers.add(new Peer(address, port, peerId)); + + PeersMessage peersMessage = new PeersMessage(peers); logger.info(peersMessage.toString()); assertEquals(1, peersMessage.getPeers().size()); @@ -119,6 +113,6 @@ public class PeersMessageTest { assertEquals(P2pMessageCodes.PEERS, peersMessage.getCommand()); assertEquals("127.0.0.1", peer.getAddress().getHostAddress()); assertEquals(-1, peer.getPort()); - assertEquals( "" , peer.getPeerId()); + assertEquals("", peer.getPeerId()); } } diff --git a/ethereumj-core/src/test/java/test/ethereum/net/StatusMessageTest.java b/ethereumj-core/src/test/java/test/ethereum/net/StatusMessageTest.java index d023e908..b0c8a851 100644 --- a/ethereumj-core/src/test/java/test/ethereum/net/StatusMessageTest.java +++ b/ethereumj-core/src/test/java/test/ethereum/net/StatusMessageTest.java @@ -2,8 +2,6 @@ package test.ethereum.net; import org.ethereum.net.eth.StatusMessage; -import java.math.BigInteger; - import org.junit.Test; import org.slf4j.Logger; @@ -11,6 +9,8 @@ import org.slf4j.LoggerFactory; import org.spongycastle.util.encoders.Hex; +import java.math.BigInteger; + import static org.junit.Assert.assertEquals; public class StatusMessageTest { @@ -35,21 +35,22 @@ public class StatusMessageTest { } @Test //from constructor - public void test2(){ + public void test2() { //Init byte version = 39; byte netId = 0; byte[] difficulty = new BigInteger("25c60144", 16).toByteArray(); - byte[] bestHash = new BigInteger("832056d3c93ff2739ace7199952e5365aa29f18805be05634c4db125c5340216",16).toByteArray(); - byte[] genesisHash = new BigInteger("955f36d073ccb026b78ab3424c15cf966a7563aa270413859f78702b9e8e22cb",16).toByteArray(); + byte[] bestHash = + new BigInteger("832056d3c93ff2739ace7199952e5365aa29f18805be05634c4db125c5340216", 16).toByteArray(); + byte[] genesisHash = + new BigInteger("955f36d073ccb026b78ab3424c15cf966a7563aa270413859f78702b9e8e22cb", 16).toByteArray(); StatusMessage statusMessage = new StatusMessage(version, netId, difficulty, bestHash, genesisHash); logger.info(statusMessage.toString()); assertEquals(39, statusMessage.getProtocolVersion()); - assertEquals("25c60144", - Hex.toHexString(statusMessage.getTotalDifficulty())); + assertEquals("25c60144", Hex.toHexString(statusMessage.getTotalDifficulty())); assertEquals("00832056d3c93ff2739ace7199952e5365aa29f18805be05634c4db125c5340216", Hex.toHexString(statusMessage.getBestHash())); assertEquals("00955f36d073ccb026b78ab3424c15cf966a7563aa270413859f78702b9e8e22cb", @@ -57,25 +58,22 @@ public class StatusMessageTest { } @Test //fail test - public void test3(){ + public void test3() { //Init byte version = -1; //invalid version byte netId = -1; //invalid netid byte[] difficulty = new BigInteger("-1000000", 16).toByteArray(); //negative difficulty - byte[] bestHash = new BigInteger("-100000000000000000000000000",16).toByteArray(); //invalid hash - byte[] genesisHash = new BigInteger("-1000000000000000000000000000000",16).toByteArray(); //invalid hash + byte[] bestHash = new BigInteger("-100000000000000000000000000", 16).toByteArray(); //invalid hash + byte[] genesisHash = new BigInteger("-1000000000000000000000000000000", 16).toByteArray(); //invalid hash StatusMessage statusMessage = new StatusMessage(version, netId, difficulty, bestHash, genesisHash); logger.info(statusMessage.toString()); assertEquals(-1, statusMessage.getProtocolVersion()); - assertEquals("ff000000", - Hex.toHexString(statusMessage.getTotalDifficulty())); - assertEquals("ff00000000000000000000000000", - Hex.toHexString(statusMessage.getBestHash())); - assertEquals("ff000000000000000000000000000000", - Hex.toHexString(statusMessage.getGenesisHash())); + assertEquals("ff000000", Hex.toHexString(statusMessage.getTotalDifficulty())); + assertEquals("ff00000000000000000000000000", Hex.toHexString(statusMessage.getBestHash())); + assertEquals("ff000000000000000000000000000000", Hex.toHexString(statusMessage.getGenesisHash())); } } From 7452765d622f30f88ac03a6cd4d8452a7aaf3d62 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 6 Jan 2015 11:21:59 +0100 Subject: [PATCH 2/7] Upgrade to Gradle propdeps plugin v0.0.7 --- ethereumj-core/build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ethereumj-core/build.gradle b/ethereumj-core/build.gradle index 8d559a75..d1f5304a 100644 --- a/ethereumj-core/build.gradle +++ b/ethereumj-core/build.gradle @@ -3,7 +3,7 @@ buildscript { maven { url 'http://repo.spring.io/plugins-release' } } dependencies { - classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.6' + classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7' } } @@ -19,7 +19,6 @@ plugins { id 'com.jfrog.bintray' version '1.0' } -apply plugin: 'propdeps' apply plugin: 'propdeps-maven' sourceCompatibility = 1.7 From 04ba6c4ed7f7251cd33eb94941dee170ba1f60b0 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 6 Jan 2015 11:22:12 +0100 Subject: [PATCH 3/7] Customize pom for publication to Maven Central --- ethereumj-core/build.gradle | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/ethereumj-core/build.gradle b/ethereumj-core/build.gradle index d1f5304a..7475de73 100644 --- a/ethereumj-core/build.gradle +++ b/ethereumj-core/build.gradle @@ -171,7 +171,62 @@ bintrayUpload.onlyIf { (!pullRequest || pullRequest == 'false') && !project.version.endsWith('-SNAPSHOT') } +install { + repositories.mavenInstaller { + customizePom(pom, project) + } +} + publish { description = "Releases snapshots to oss.jfrog.org and releases to Bintray/JCenter" dependsOn artifactoryPublish, bintrayUpload } + + +def customizePom(pom, gradleProject) { + pom.whenConfigured { generatedPom -> + // eliminate test-scoped dependencies (no need in maven central poms) + generatedPom.dependencies.removeAll { dep -> + dep.scope == "test" + } + + // sort to make pom dependencies order consistent to ease comparison of older poms + generatedPom.dependencies = generatedPom.dependencies.sort { dep -> + "$dep.scope:$dep.groupId:$dep.artifactId" + } + + // add all items necessary for maven central publication + generatedPom.project { + name = "ethereumj" + description = "Java implementation of the Ethereum protocol" + url = "https://github.com/ethereum/ethereumj" + organization { + name = "Ethereum" + url = "https://ethereum.org" + } + licenses { + license { + name "The MIT License" + url "http://mit-license.org/" + distribution "repo" + } + } + scm { + url = "https://github.com/ethereum/ethereumj" + connection = "scm:git:git://github.com/ethereum/ethereumj" + developerConnection = "scm:git:git://github.com/ethereum/ethereumj" + } + developers { + developer { + id = "rmandeleil" + name = "Roman Mandeleil" + email = "roman.mandeleil@gmail.com" + } + } + issueManagement { + system = "GitHub Issues" + url = "https://github.com/ethereum/ethereumj/issues" + } + } + } +} From 00aba13a3d4bd1c9d9e4543ef57e5ed1cd9ceb3c Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 6 Jan 2015 11:50:03 +0100 Subject: [PATCH 4/7] Remove Bintray upload support for now There is a known issue with Gradle's new `maven-publish` plugin that causes all dependencies in the published pom to runtime-scoped [1]. This causes conflicts with our use of Spring's `propdeps` Gradle plugin that introduces optional and provided scopes. This commit drops down to using Gradle's older, orginal `maven` plugin, and JFrog's old-style `artifactory-publish` plugin in order to preserve propdeps support. This means removing JFrog's `bintray` plugin, as it appears to depend on the `maven-publish` plugin. For the moment, ethereumj only really needs to publish snapshots, and this is still supported. This is a stopgap measure; it will be necessary to deal with getting uploads to Bintray/JCenter working again once we're ready for a non-snapshot release, but this can be dealt with later. [1]: http://forums.gradle.org/gradle/topics/maven_publish_plugin_generated_pom_making_dependency_scope_runtime --- ethereumj-core/README.md | 2 +- ethereumj-core/build.gradle | 49 ++++++------------------------------- 2 files changed, 9 insertions(+), 42 deletions(-) diff --git a/ethereumj-core/README.md b/ethereumj-core/README.md index 719f3b76..eedfca66 100644 --- a/ethereumj-core/README.md +++ b/ethereumj-core/README.md @@ -59,4 +59,4 @@ Run `../gradlew install`. #### Publish ethereumj-core builds -Simply push to master, and [the Travis CI build](https://travis-ci.org/ethereum/ethereumj) will take care of the rest. To publish manually instead, just run `../gradlew publish`. Where the artifacts are published depends on the value of the `version` property in the [root build.gradle file](../build.gradle). Snapshots (version values ending in `-SNAPSHOT`) will be published to oss.jfrog.org, while releases will be published to Bintray (and subsequently to JCenter). **You must be a member of the [ethereum Bintray organization](https://bintray.com/ethereum) and you must supply `bintrayUser` and `bintrayKey` properties to the Gradle build in order to authenticate against these repositories**. Configure these properties in your `$HOME/.gradle/gradle.properties` for greatest convenience and security. +Simply push to master, and [the Travis CI build](https://travis-ci.org/ethereum/ethereumj) will take care of the rest. To publish manually instead, just run `../gradlew publish`. Where the artifacts are published depends on the value of the `version` property in the [root build.gradle file](../build.gradle). Snapshots (version values ending in `-SNAPSHOT`) will be published to oss.jfrog.org. **You must be a member of the [ethereum Bintray organization](https://bintray.com/ethereum) and you must supply `bintrayUser` and `bintrayKey` properties to the Gradle build in order to authenticate against these repositories**. Configure these properties in your `$HOME/.gradle/gradle.properties` for greatest convenience and security. diff --git a/ethereumj-core/build.gradle b/ethereumj-core/build.gradle index 7475de73..6d979686 100644 --- a/ethereumj-core/build.gradle +++ b/ethereumj-core/build.gradle @@ -1,25 +1,24 @@ buildscript { repositories { - maven { url 'http://repo.spring.io/plugins-release' } + jcenter() + maven { url 'http://repo.spring.io/plugins-release-local' } } dependencies { classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7' - } + classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.0.1' + } } plugins { id 'application' id 'jacoco' - id 'maven' - id 'maven-publish' id 'com.github.johnrengelman.shadow' version '1.2.0' id 'me.champeau.gradle.antlr4' version '0.1' id 'com.github.kt3k.coveralls' version '2.0.1x' - id 'com.jfrog.artifactory' version '3.0.1' - id 'com.jfrog.bintray' version '1.0' } apply plugin: 'propdeps-maven' +apply plugin: 'com.jfrog.artifactory-upload' sourceCompatibility = 1.7 @@ -115,16 +114,6 @@ jacocoTestReport { } } -publishing { - publications { - mavenJava(MavenPublication) { - from components.java - artifact sourcesJar - artifact javadocJar - } - } -} - def bintrayUsername = project.hasProperty('bintrayUser') ? project.bintrayUser : '' def bintrayPassword = project.hasProperty('bintrayKey') ? project.bintrayKey : '' def pullRequest = System.getenv('TRAVIS_PULL_REQUEST') @@ -137,9 +126,6 @@ artifactory { username = bintrayUsername password = bintrayPassword } - defaults { - publications ('mavenJava') - } } resolve { repository { @@ -153,36 +139,17 @@ artifactoryPublish.onlyIf { (!pullRequest || pullRequest == 'false') && project.version.endsWith('-SNAPSHOT') } -bintray { - user = bintrayUsername - key = bintrayPassword - - publications = ['mavenJava'] - dryRun = false //Whether to run this as dry-run, without deploying - publish = true //If version should be auto published after an upload - pkg { - userOrg = 'ethereum' //An optional organization name when the repo belongs to one of the user's orgs - repo = 'maven' - name = 'org.ethereum' - } -} - -bintrayUpload.onlyIf { - (!pullRequest || pullRequest == 'false') && !project.version.endsWith('-SNAPSHOT') -} - install { repositories.mavenInstaller { customizePom(pom, project) } } -publish { - description = "Releases snapshots to oss.jfrog.org and releases to Bintray/JCenter" - dependsOn artifactoryPublish, bintrayUpload +task publish { + description = "Publishes snapshots to oss.jfrog.org" + dependsOn artifactoryPublish } - def customizePom(pom, gradleProject) { pom.whenConfigured { generatedPom -> // eliminate test-scoped dependencies (no need in maven central poms) From 1c354cb7366673475fa1d0a20c5cbd1dfff477db Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 6 Jan 2015 14:07:09 +0100 Subject: [PATCH 5/7] Re-enable Bintray upload support Thanks to @jbaruch for his comments at https://github.com/ethereum/ethereumj/commit/00aba13#commitcomment-9167542 --- ethereumj-core/README.md | 2 +- ethereumj-core/build.gradle | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ethereumj-core/README.md b/ethereumj-core/README.md index eedfca66..8f552442 100644 --- a/ethereumj-core/README.md +++ b/ethereumj-core/README.md @@ -59,4 +59,4 @@ Run `../gradlew install`. #### Publish ethereumj-core builds -Simply push to master, and [the Travis CI build](https://travis-ci.org/ethereum/ethereumj) will take care of the rest. To publish manually instead, just run `../gradlew publish`. Where the artifacts are published depends on the value of the `version` property in the [root build.gradle file](../build.gradle). Snapshots (version values ending in `-SNAPSHOT`) will be published to oss.jfrog.org. **You must be a member of the [ethereum Bintray organization](https://bintray.com/ethereum) and you must supply `bintrayUser` and `bintrayKey` properties to the Gradle build in order to authenticate against these repositories**. Configure these properties in your `$HOME/.gradle/gradle.properties` for greatest convenience and security. +Simply push to master, and [the Travis CI build](https://travis-ci.org/ethereum/ethereumj) will take care of the rest. To publish manually instead, just run `../gradlew publish`. Where the artifacts are published depends on the value of the `version` property in the [root build.gradle file](../build.gradle). Snapshots (version values ending in `-SNAPSHOT`) will be published to [oss.jfrog.org](https://oss.jfrog.org/libs-snapshot/org/ethereum/), while releases will be published to [Bintray](https://bintray.com/ethereum/maven/org.ethereum/) (and subsequently to [JCenter](http://jcenter.bintray.com/org/ethereum/)). **You must be a member of the [ethereum Bintray organization](https://bintray.com/ethereum) and you must supply `bintrayUser` and `bintrayKey` properties to the Gradle build in order to authenticate against these repositories**. Configure these properties in your `$HOME/.gradle/gradle.properties` for greatest convenience and security. diff --git a/ethereumj-core/build.gradle b/ethereumj-core/build.gradle index 6d979686..1a21fd23 100644 --- a/ethereumj-core/build.gradle +++ b/ethereumj-core/build.gradle @@ -15,6 +15,7 @@ plugins { id 'com.github.johnrengelman.shadow' version '1.2.0' id 'me.champeau.gradle.antlr4' version '0.1' id 'com.github.kt3k.coveralls' version '2.0.1x' + id 'com.jfrog.bintray' version '1.0' } apply plugin: 'propdeps-maven' @@ -139,6 +140,25 @@ artifactoryPublish.onlyIf { (!pullRequest || pullRequest == 'false') && project.version.endsWith('-SNAPSHOT') } +bintray { + user = bintrayUsername + key = bintrayPassword + + configurations = ['archives'] + + dryRun = false //Whether to run this as dry-run, without deploying + publish = true //If version should be auto published after an upload + pkg { + userOrg = 'ethereum' //An optional organization name when the repo belongs to one of the user's orgs + repo = 'maven' + name = 'org.ethereum' + } +} + +bintrayUpload.onlyIf { + (!pullRequest || pullRequest == 'false') && !project.version.endsWith('-SNAPSHOT') +} + install { repositories.mavenInstaller { customizePom(pom, project) @@ -146,10 +166,11 @@ install { } task publish { - description = "Publishes snapshots to oss.jfrog.org" - dependsOn artifactoryPublish + description = "Publishes snapshots to oss.jfrog.org and releases to Bintray/JCenter" + dependsOn artifactoryPublish, bintrayUpload } + def customizePom(pom, gradleProject) { pom.whenConfigured { generatedPom -> // eliminate test-scoped dependencies (no need in maven central poms) From ab880805f7c769d004eab4d2ef04de58641f0d53 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 6 Jan 2015 14:20:21 +0100 Subject: [PATCH 6/7] Update Travis notifications --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4da5b982..8f8f95ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,8 @@ notifications: on_failure: always use_notice: true skip_join: true + slack: + - secure: "Fhaoka5w5XzIZS7ObKfVrnHaVLz7x2Owo1ygb+hXWAHiXpc3Oi1Q6yDOfye/z+Y0Gw8an8v23PIxhLoVZ6JpdurwCXo66dK2TkiNzmEWd6RtYPSZDm6f+0NjPBSOnP5rHmej7RvHeyTY/PQrGPtrHZZQTYD3AuRP1S+tGvtqikA=" # Encrypted values are ORG_GRADLE_PROJECT_bintrayUser and ORG_GRADLE_PROJECT_bintrayKey props for use by Travis when # authenticating against oss.jfrog.org and/or Bintray repositories. See http://docs.travis-ci.com/user/encryption-keys From cde55dd100577a0697a505d8d26af22c28b204fb Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 6 Jan 2015 14:27:24 +0100 Subject: [PATCH 7/7] Update Travis notifications Notify on failure and first success. --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8f8f95ad..ca5afb2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,10 @@ notifications: use_notice: true skip_join: true slack: - - secure: "Fhaoka5w5XzIZS7ObKfVrnHaVLz7x2Owo1ygb+hXWAHiXpc3Oi1Q6yDOfye/z+Y0Gw8an8v23PIxhLoVZ6JpdurwCXo66dK2TkiNzmEWd6RtYPSZDm6f+0NjPBSOnP5rHmej7RvHeyTY/PQrGPtrHZZQTYD3AuRP1S+tGvtqikA=" + on_success: change + on_failure: always + rooms: + - secure: "Fhaoka5w5XzIZS7ObKfVrnHaVLz7x2Owo1ygb+hXWAHiXpc3Oi1Q6yDOfye/z+Y0Gw8an8v23PIxhLoVZ6JpdurwCXo66dK2TkiNzmEWd6RtYPSZDm6f+0NjPBSOnP5rHmej7RvHeyTY/PQrGPtrHZZQTYD3AuRP1S+tGvtqikA=" # Encrypted values are ORG_GRADLE_PROJECT_bintrayUser and ORG_GRADLE_PROJECT_bintrayKey props for use by Travis when # authenticating against oss.jfrog.org and/or Bintray repositories. See http://docs.travis-ci.com/user/encryption-keys