-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
139 lines (114 loc) · 4.67 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id "com.github.ben-manes.versions" version "0.51.0"
id 'org.javamodularity.moduleplugin' version '1.8.15' apply false
}
repositories {
// Use the plugin portal to apply community plugins in convention plugins.
gradlePluginPortal()
}
subprojects {
apply plugin: 'java'
apply plugin: 'org.javamodularity.moduleplugin'
apply plugin: 'maven-publish'
sourceCompatibility = 17
targetCompatibility = 17
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.32'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
testImplementation 'org.projectlombok:lombok:1.18.32'
testImplementation 'junit:junit:[4,5)'
testImplementation 'org.mockito:mockito-core:3.11.1'
}
publishing {
description 'Upload jars to local artifactory'
//group 'publishing'
publications {
mavenJava(MavenPublication) {
from components.java
artifactId = project.name // Use the project name for the artifactId
}
}
repositories {
mavenLocal()
}
/*repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/gerco/messagemanager")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
}
}
}
publications {
gpr(MavenPublication) {
from(components.java)
}
}*/
}
def appVersion = project.version // from gradle.properties
def buildTimeStamp = new Date().toString()
compileJava {
doFirst {
if (project.file("src/main/java-templates/Version.java").exists()) {
ant.mkdir(dir: "${projectDir}/src/main/java/${project.targetPackage}")
def newBuildInfo = new File("${projectDir}/src/main/java/${targetPackage}/Version.java")
def templateBuildInfo = new File("${projectDir}/src/main/java-templates/Version.java")
newBuildInfo.withWriter { def writer ->
templateBuildInfo.eachLine { def line ->
def newLine = line.replace("__PACKAGE", targetPackageJava)
.replace("__VERSION", appVersion)
.replace("__BUILD_ID", appVersion)
.replace("__BUILD_TIMESTAMP", buildTimeStamp)
writer.write(newLine + "\n");
}
}
}
}
}
/* task copyJarToUserData(type: Copy) {
onlyIf {
// only copy jar for plugins to the user data folder
file("${projectDir}/src/main/resources/MessageManager/plugins").exists()
}
from "build/libs/${project.name}-${project.version}.jar" // Source path (replace with your JAR name)
into getUserDataFolder().toString() + "/MessageManager/plugins/${project.version}"
}*/
tasks.register('copyJarToBootstrap',Copy) {
println 'Running copyJarToBootstrap'
onlyIf {
// only copy jar for plugins to the user data folder
file("${projectDir}/src/main/resources/MessageManager/plugins").exists()
}
ant.mkdir(dir: "${projectDir}/../messagemanager-bootstrap/build/root/target/config/plugins")
// client jars will copied to this folder
ant.mkdir(dir: "${projectDir}/../messagemanager-bootstrap/build/root/target/config/clients")
from "build/libs/${project.name}-${project.version}.jar" // Source path (replace with your JAR name)
rename '([a-z]*-[a-z]*).*.jar', '$1.jar' // remove version from jar
into "${projectDir}/../messagemanager-bootstrap/build/root/target/config/plugins"
}
// Ensure copying happens after JAR is built
// build.dependsOn copyJarToUserData
jar.finalizedBy('copyJarToBootstrap')
}
protected File getUserDataFolder() {
def configPath = System.getenv("XDG_CONFIG_DIR")
if (!configPath) {
configPath = System.getenv("APPDATA")
}
if (!configPath) {
def userHome = new File(System.getProperty("user.home"))
return new File(userHome, ".config")
} else {
return new File(configPath)
}
}