Skip to content

Commit d4d8b1e

Browse files
committed
🔨 build: setup CI.CD dependencies injection #2
1 parent 7518ed0 commit d4d8b1e

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

Diff for: plugin/build.gradle

+23-10
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,29 @@ repositories {
3535

3636
import org.yaml.snakeyaml.Yaml
3737

38+
class JarConfig {
39+
boolean enabled
40+
String source
41+
42+
JarConfig(Map<String, Object> config) {
43+
enabled = config['enabled'] ?: false
44+
source = config['source'] ?: ''
45+
}
46+
}
47+
3848
class NgConfig {
3949
String name
4050
String version
4151
boolean enabledLink
42-
List<String> jars
52+
List<JarConfig> jars
4353

4454
@SuppressWarnings('GroovyAssignabilityCheck')
4555
NgConfig(Map<String, Object> configs) {
4656
name = configs.containsKey('name') ? configs['name'] : 'bot4j'
47-
version = configs.containsKey('version') ? configs['version'] : 'v1.0.0'
57+
version = configs.containsKey('version') ? configs['version'] : 'v0.0.0'
4858
enabledLink = configs.containsKey('enabled_link') ? configs['enabled_link'] : false
49-
jars = configs.containsKey('jars') ? configs['jars'] : []
59+
// jars = configs.containsKey('jars') ? configs['jars'] : [] // List<String> jars
60+
jars = configs.containsKey('jars') ? configs['jars'].collect { new JarConfig(it) } : []
5061
}
5162
}
5263

@@ -87,15 +98,15 @@ tasks.jar {
8798
version = "${ngConfig.getVersion()}"
8899

89100
// Handle duplicates
90-
// <code>
91101
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
92-
// </code>
93102
// Compressing the external JAR files listed in gradle.yml using zipTree if enabled_link is true
94103
if (ngConfig.isEnabledLink() && !ngConfig.getJars().isEmpty()) {
95104
ngConfig.getJars().each { jar ->
96-
println("📦 Jar compressing... [${jar}]")
97-
from {
98-
zipTree(file(jar))
105+
if (jar.isEnabled() && !jar.getSource().isEmpty()) {
106+
println("📦 Jar compressing... [${jar.getSource()}]")
107+
from {
108+
zipTree(file(jar.getSource()))
109+
}
99110
}
100111
}
101112
} else {
@@ -108,8 +119,10 @@ dependencies {
108119
// Add the dependencies listed in the gradle.yml file
109120
if (!ngConfig.getJars().isEmpty()) {
110121
ngConfig.getJars().each { jar ->
111-
println("🔄 Jar mounting... [${jar}]")
112-
implementation files(jar)
122+
if (!jar.getSource().isEmpty()) {
123+
println("🔄 Jar mounting... [${jar.getSource()}]")
124+
implementation files(jar.getSource())
125+
}
113126
}
114127
} else {
115128
println '⚠️ No JAR files specified in gradle.yml for dependencies.'

Diff for: plugin/gradle.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ ng:
55
jars:
66
# unify4J: Java 1.8 skeleton library offering a rich toolkit of utility functions
77
# for collections, strings, date/time, JSON, maps, and more.
8-
- "./../libs/unify4j-v1.0.0.jar"
8+
- enabled: false # enable compression and attachment of the external libraries
9+
source: "./../libs/unify4j-v1.0.0.jar"
910
# alpha4J: is a Java 8 library featuring common data structures and algorithms.
1011
# Enhance your projects with efficient and easy-to-use implementations designed for performance and clarity.
11-
- "./../libs/alpha4j-v1.0.0.jar"
12+
- enabled: true
13+
source: "./../libs/alpha4j-v1.0.0.jar"

0 commit comments

Comments
 (0)