diff --git a/bin/create-maven-repos.sh b/bin/create-maven-repos.sh
deleted file mode 100755
index 3a8bd22..0000000
--- a/bin/create-maven-repos.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd $directory
-
-# API dependencies
-./install-lib.sh api mail.jar javax.mail mail 1.4.7
-./install-lib.sh api slf4j-api-1.7.5.jar org.slf4j slf4j-api 1.7.5
-./install-lib.sh api slf4j-simple-1.7.5.jar org.slf4j slf4j-simple 1.7.5
-
-# EXTRA dependencies
-./install-lib.sh extra base64-2.3.8.jar net.iharder base64 2.3.8
-./install-lib.sh extra bitcoin-json-rpc-client-1.0.jar com.azazar.bitcoin.jsonrpcclient bitcoin-json-rpc-client 1.0
-./install-lib.sh extra commons-io-2.4.jar commons-io commons-io 2.4
-./install-lib.sh extra guava-18.0.jar com.google.guava guava 18.0
-./install-lib.sh extra jackson-annotations-2.4.0.jar com.fasterxml.jackson.core jackson-annotations 2.4.0
-./install-lib.sh extra jackson-core-2.4.0.jar com.fasterxml.jackson.core jackson-core 2.4.0
-./install-lib.sh extra jackson-databind-2.4.0.jar com.fasterxml.jackson.core jackson-databind 2.4.0
-./install-lib.sh extra javax.ws.rs-api-2.0.1.jar javax.ws.rs javax.ws.rs-api 2.0.1
-./install-lib.sh extra rescu-1.7.2-SNAPSHOT.jar com.github.mmazi rescu 1.7.2-SNAPSHOT
-./install-lib.sh extra xchange-core-4.0.1-SNAPSHOT.jar org.knowm.xchange xchange-core 4.0.1-SNAPSHOT
-./install-lib.sh extra xchange-bitfinex-4.0.1-SNAPSHOT.jar org.knowm.xchange xchange-bitfinex 4.0.1-SNAPSHOT
-./install-lib.sh extra xchange-itbit-4.0.1-SNAPSHOT.jar org.knowm.xchange xchange-itbit 4.0.1-SNAPSHOT
-./install-lib.sh extra xchange-bittrex-4.0.1-SNAPSHOT.jar org.knowm.xchange xchange-bittrex 4.0.1-SNAPSHOT
-./install-lib.sh extra xchange-poloniex-4.0.1-SNAPSHOT.jar org.knowm.xchange xchange-poloniex 4.0.1-SNAPSHOT
-
-# TEST dependencies
-./install-lib.sh test jopt-simple-4.9.jar net.sf.jopt-simple jopt-simple 4.9
diff --git a/bin/install-lib.sh b/bin/install-lib.sh
deleted file mode 100755
index 3563830..0000000
--- a/bin/install-lib.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-project="$1"
-file="$2"
-groupId="$3"
-artifactId="$4"
-version="$5"
-directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-echo directory: $directory
-
-if [ -z "$5" ] ; then
- echo 'This script is used to install dependencies to the local maven repository.'
- echo 'usage: install-lib.sh project file groupId artifactId version'
- echo ''
- echo 'project is either api, extra, or test'
- echo ''
- echo 'example: install-lib.sh api mail-1.4.7.jar javax.mail mail 1.4.7'
- echo ''
- exit 1
-fi
-
-if [ "$1" == "api" ] || [ "$1" == "extra" ] || [ "$1" == "test" ] ; then
-
- localRepositoryPath="../server_extensions_$1/.mvn-repo"
- mkdir -p $localRepositoryPath
- fileLocation="../server_extensions_$1/libs/$file"
-
- mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file \
- -Dfile=$fileLocation \
- -DgroupId=$groupId \
- -DartifactId=$artifactId \
- -Dversion=$version-BATM \
- -Dpackaging=jar \
- -DlocalRepositoryPath=$localRepositoryPath
-
- echo ''
- echo '...installed, you can use it by adding following to the pom.xml:'
- echo ''
- echo ''
- echo " $groupId"
- echo " $artifactId"
- echo " $version-BATM"
- echo ''
- echo ''
-
-else
- echo 'project needs to be either api, extra, or test'
-fi
-
-exit 1
-
diff --git a/build.gradle b/build.gradle
index 97e8b8e..134cee2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -8,8 +8,17 @@ buildscript {
}
}
+final File repoDir = project.file('libs')
allprojects {
repositories {
jcenter()
}
+ repositories {
+ //bitcoin-json-rpc-client-1.0.jar isn't part of any well known maven repo
+ //so we search the libs dir; gradle generates (guesses) metadata except dependencies.
+ //Artifacts from repos with real metadata take precedence.
+ flatDir {
+ dirs repoDir
+ }
+ }
}
diff --git a/buildSrc/src/main/groovy/com.generalbytes.batm.gradle/DependencySubstitutionPlugin.groovy b/buildSrc/src/main/groovy/com.generalbytes.batm.gradle/DependencySubstitutionPlugin.groovy
new file mode 100644
index 0000000..c2c5b8d
--- /dev/null
+++ b/buildSrc/src/main/groovy/com.generalbytes.batm.gradle/DependencySubstitutionPlugin.groovy
@@ -0,0 +1,85 @@
+package com.generalbytes.batm.gradle
+
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+import org.gradle.api.artifacts.Configuration
+import org.gradle.api.artifacts.DependencyResolveDetails
+import org.gradle.api.artifacts.UnknownConfigurationException
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+class DependencySubstitutionPlugin implements Plugin {
+ private DependencySubstitutionPluginExtension extension
+ private List initialConfinedConfigurations = new LinkedList<>()
+ private Logger logger = LoggerFactory.getLogger('gb-gradle')
+
+ static void confine(Project project, String configurationName) {
+ confine(project.getConfigurations().getByName(configurationName))
+ }
+
+ static void confine(Configuration configuration) {
+ configuration.transitive = false
+ }
+
+ void apply(Project project) {
+ extension = project.extensions.create('dependencySubstitutions', DependencySubstitutionPluginExtension)
+ initialConfinedConfigurations.addAll([
+ 'compile',
+ 'compileOnly',
+ 'compileClasspath',
+ 'implementation',
+ 'providedCompile',
+
+ 'testCompile',
+ 'testCompileOnly',
+ 'testCompileClasspath',
+ 'testImplementation'
+ ])
+
+ project.afterEvaluate {
+ configure(project)
+ }
+ }
+
+ void configure(Project project) {
+ initialConfinedConfigurations.each {
+ try {
+ confine(project.configurations[it])
+ } catch (UnknownConfigurationException ignored) {
+ logger.info("Plugin-specified confined configuration $it not found, skipping...")
+ }
+ }
+ extension.confinedConfigurations.each {
+ switch (it) {
+ case String:
+ confine(project, (String) it)
+ break
+ case Configuration:
+ confine((Configuration) it)
+ break
+ default:
+ throw new IllegalStateException("Illegal specification for confined configuration: $it (${it.class})")
+ }
+ }
+
+ if (extension.conflictFail) {
+ project.configurations.all {
+ resolutionStrategy {
+ failOnVersionConflict()
+ }
+ }
+ }
+
+ project.configurations.all {
+ resolutionStrategy {
+ eachDependency { DependencyResolveDetails details ->
+ final SimpleModuleVersionIdentifier from = new SimpleModuleVersionIdentifier(details.requested.group, details.requested.name, details.requested.version)
+ final String toVersion = extension.substitutions.get(from)
+ if (toVersion != null && toVersion.length() > 0) {
+ details.useVersion(toVersion)
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/groovy/com.generalbytes.batm.gradle/DependencySubstitutionPluginExtension.groovy b/buildSrc/src/main/groovy/com.generalbytes.batm.gradle/DependencySubstitutionPluginExtension.groovy
new file mode 100644
index 0000000..2e0a80b
--- /dev/null
+++ b/buildSrc/src/main/groovy/com.generalbytes.batm.gradle/DependencySubstitutionPluginExtension.groovy
@@ -0,0 +1,57 @@
+package com.generalbytes.batm.gradle
+
+import org.gradle.api.artifacts.Configuration
+
+import java.util.regex.Matcher
+import java.util.regex.Pattern
+
+class DependencySubstitutionPluginExtension {
+ List