Last active
March 21, 2018 09:10
-
-
Save naosim/042352e1274110a7030bdb97713779ec to your computer and use it in GitHub Desktop.
デフォルトのjarを自作のjarに差し替える
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// デフォルトのjarをアーティファクトから削除 | |
configurations.archives.artifacts.with { archives -> | |
def jarArtifact | |
archives.each { | |
if (it.file =~ 'jar') { | |
jarArtifact = it | |
} | |
} | |
println "JAR to delete: ${jarArtifact}" | |
remove(jarArtifact) | |
} | |
/** | |
上位で | |
project.ext { | |
docsMavenConfig = [ includeJars: ['common'] ] | |
} | |
こんな感じの設定を想定 | |
*/ | |
boolean isIncludeJar(obj) { | |
def result = project.docsMavenConfig.includeJars.findAll { obj.toString().contains(it)}.size() > 0 | |
println("isIncludeJar: ${obj.toString()} -> ${result}") | |
return result | |
} | |
// 例: fatJarを作成するタスク | |
task fatJar(type: Jar) { | |
baseName = project.name + '-all' | |
from { | |
configurations.compile.findAll { isIncludeJar(it) }.collect { it.isDirectory() ? it : zipTree(it) } | |
} | |
with jar | |
} | |
// fatJarをアーティファクトに登録 | |
artifacts { | |
archives fatJar | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment