0

gradle: перенесены методы в gradle-plugin

This commit is contained in:
2021-01-07 00:57:53 +03:00
parent c98c5d2c34
commit 05f0245323
2 changed files with 40 additions and 20 deletions

View File

@@ -1,7 +1,44 @@
class FilteringDependenciesExtention {
/**
* example for 'library':
* <pre>
* [lib: 'org.bukkit:bukkit:1.12.2-R0.1-SNAPSHOT',
* exclude: [
* 'com.google.code.gson:gson',
* 'com.googlecode.json-simple:json-simple'
* ]]
* </pre>
*
* @param library see example
*/
def filter(library) {
Object[] result = new Object[2]
result[0] = library.lib
result[1] = {
library.exclude.each { String excludeLibStr ->
String[] excludeLib = excludeLibStr.split(':')
exclude group: excludeLib[0], module: excludeLib[1]
}
}
return result
}
}
class FilteringDependenciesPlugin implements Plugin<Project> {
@Override
void apply(Project target) {
target.extensions.create('fildep', FilteringDependenciesExtention)
}
}
plugins {
id 'java'
}
apply plugin: FilteringDependenciesPlugin
apply from: 'libs.gradle'
def publishScript = file(rootProject.getProjectDir().getPath() + '/publish.gradle')
@@ -19,35 +56,17 @@ repositories {
maven { url 'https://dmx-mc-project.gitlab.io/maven-repository/' }
}
def compileOnly2(library) {
dependencies.compileOnly library.lib, {
library.exclude.each { String excludeLibStr ->
String[] excludeLib = excludeLibStr.split(':')
exclude group: excludeLib[0], module: excludeLib[1]
}
}
}
def testImplementation2(library) {
dependencies.testImplementation library.lib, {
library.exclude.each { String excludeLibStr ->
String[] excludeLib = excludeLibStr.split(':')
exclude group: excludeLib[0], module: excludeLib[1]
}
}
}
dependencies {
compileOnly libs.lombok
annotationProcessor libs.lombok
compileOnly2 libs.bukkit
compileOnly fildep.filter(libs.bukkit)
implementation libs.commons_text
implementation libs.refobj
testImplementation libs.test.junit5
testImplementation libs.test.mock
testImplementation2 libs.bukkit
testImplementation fildep.filter(libs.bukkit)
testImplementation libs.test.h2db
}