Skip to content

Commit

Permalink
🔨 build: setup CI.CD dependencies injection #2
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Jun 27, 2024
1 parent 7518ed0 commit d4d8b1e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
33 changes: 23 additions & 10 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,29 @@ repositories {

import org.yaml.snakeyaml.Yaml

class JarConfig {
boolean enabled
String source

JarConfig(Map<String, Object> config) {
enabled = config['enabled'] ?: false
source = config['source'] ?: ''
}
}

class NgConfig {
String name
String version
boolean enabledLink
List<String> jars
List<JarConfig> jars

@SuppressWarnings('GroovyAssignabilityCheck')
NgConfig(Map<String, Object> configs) {
name = configs.containsKey('name') ? configs['name'] : 'bot4j'
version = configs.containsKey('version') ? configs['version'] : 'v1.0.0'
version = configs.containsKey('version') ? configs['version'] : 'v0.0.0'
enabledLink = configs.containsKey('enabled_link') ? configs['enabled_link'] : false
jars = configs.containsKey('jars') ? configs['jars'] : []
// jars = configs.containsKey('jars') ? configs['jars'] : [] // List<String> jars
jars = configs.containsKey('jars') ? configs['jars'].collect { new JarConfig(it) } : []
}
}

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

// Handle duplicates
// <code>
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// </code>
// Compressing the external JAR files listed in gradle.yml using zipTree if enabled_link is true
if (ngConfig.isEnabledLink() && !ngConfig.getJars().isEmpty()) {
ngConfig.getJars().each { jar ->
println("📦 Jar compressing... [${jar}]")
from {
zipTree(file(jar))
if (jar.isEnabled() && !jar.getSource().isEmpty()) {
println("📦 Jar compressing... [${jar.getSource()}]")
from {
zipTree(file(jar.getSource()))
}
}
}
} else {
Expand All @@ -108,8 +119,10 @@ dependencies {
// Add the dependencies listed in the gradle.yml file
if (!ngConfig.getJars().isEmpty()) {
ngConfig.getJars().each { jar ->
println("🔄 Jar mounting... [${jar}]")
implementation files(jar)
if (!jar.getSource().isEmpty()) {
println("🔄 Jar mounting... [${jar.getSource()}]")
implementation files(jar.getSource())
}
}
} else {
println '⚠️ No JAR files specified in gradle.yml for dependencies.'
Expand Down
6 changes: 4 additions & 2 deletions plugin/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ ng:
jars:
# unify4J: Java 1.8 skeleton library offering a rich toolkit of utility functions
# for collections, strings, date/time, JSON, maps, and more.
- "./../libs/unify4j-v1.0.0.jar"
- enabled: false # enable compression and attachment of the external libraries
source: "./../libs/unify4j-v1.0.0.jar"
# alpha4J: is a Java 8 library featuring common data structures and algorithms.
# Enhance your projects with efficient and easy-to-use implementations designed for performance and clarity.
- "./../libs/alpha4j-v1.0.0.jar"
- enabled: true
source: "./../libs/alpha4j-v1.0.0.jar"

0 comments on commit d4d8b1e

Please sign in to comment.