-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
162 lines (149 loc) · 5.88 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
}
apply from: "${rootProject.rootDir}/gradle/tests.gradle"
apply from: "${rootProject.rootDir}/gradle/publishing.gradle"
group = 'com.inomera.telco'
version = rootProject.file('VERSION').text.trim()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
}
dependencies {
compileOnly 'org.apache.httpcomponents:httpcore:4.4.13'
implementation 'org.apache.logging.log4j:log4j-core:2.20.0'
implementation 'org.apache.logging.log4j:log4j-api:2.20.0'
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.20.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.3'
}
test {
useJUnitPlatform()
}
tasks.register('javadocJar', Jar) {
dependsOn javadoc
classifier "javadoc"
from javadoc.destinationDir
}
tasks.register('sourceJar', Jar) {
classifier 'sources'
from sourceSets.main.allJava
}
compileJava.dependsOn(processResources)
artifacts {
archives sourceJar
archives javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
groupId = "${project.group}".toString()
println("groupId -> ${groupId}")
artifactId = "${project.name}".toString()
println("artifactId -> ${artifactId}")
version = "${project.version}".toString()
println("version -> ${version}")
pom {
name = 'ssl-forge'
description = 'SSL Forge'
url = 'https://github.com/inomera/ssl-forge'
organization {
name = 'Inomera Research'
url = 'https://inomera.com/'
}
licenses {
license {
name = 'MIT License'
url = 'http://www.opensource.org/licenses/mit-license.php'
}
}
developers {
developer {
id = 'FatihBozik'
name = 'Fatih Bozik'
organization = 'Inomera'
organizationUrl = 'https://inomera.com/'
}
}
scm {
url = 'https://github.com/inomera/ssl-forge'
connection = 'scm:git:https://github.com/inomera/ssl-forge.git'
developerConnection = 'scm:git:https://github.com/inomera/ssl-forge.git'
}
issueManagement {
system = 'GitHub'
url = 'https://github.com/inomera/ssl-forge/issues'
}
}
// create the sign pom artifact
pom.withXml {
def root = asNode()
// Print all dependencies before filtering
println("Dependencies before filtering:")
root.dependencies.dependency.each { dep ->
def groupId = dep.groupId.text()?.toString()
def artifactId = dep.artifactId.text()?.toString()
def version = dep.version.text()?.toString()
def scope = dep.scope.text()?.toString()
println("GroupId: ${groupId}, ArtifactId: ${artifactId}, Version: ${version}, Scope: ${scope}")
}
// Eliminate test-scoped dependencies
root.dependencies.dependency.findAll { dep ->
dep.scope.text()?.toString() == "test"
}.each { dep ->
def groupId = dep.groupId.text()?.toString()
def artifactId = dep.artifactId.text()?.toString()
println("Removing dependency: GroupId=${groupId}, ArtifactId=${artifactId}")
dep.parent().remove(dep)
}
// Print remaining dependencies after filtering
println("Dependencies after filtering:")
root.dependencies.dependency.each { dep ->
def groupId = dep.groupId.text()?.toString()
def artifactId = dep.artifactId.text()?.toString()
def version = dep.version.text()?.toString()
def scope = dep.scope.text()?.toString()
println("GroupId: ${groupId}, ArtifactId: ${artifactId}, Version: ${version}, Scope: ${scope}")
}
println("root -> $root")
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)
println("pomFile -> $pomFile")
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
println("pomAscFile -> $pomAscFile")
artifact(pomAscFile) {
classifier = null
extension = 'pom.asc'
}
}
artifact(sourceJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}
// create the signed artifacts
def archives = project.tasks.signArchives
println("archives -> $archives")
def files = archives.signatureFiles
println("signatureFiles -> $files")
files.each {
artifact(it) {
def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/
println("it.file -> $it.file")
if (matcher.find()) {
classifier = matcher.group(1)
println("classifier -> $classifier")
} else {
classifier = null
}
extension = 'jar.asc'
}
}
}
}
}