-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
118 lines (109 loc) · 4.3 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
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/" // fix missing jcenter dependencies for e.g. cyclonedx plugin
}
}
}
plugins {
id 'java-library'
id 'maven-publish'
id 'jacoco'
id 'com.adarshr.test-logger' version "4.0.0"
id 'com.github.ben-manes.versions' version "0.51.0"
id "io.freefair.lombok" version "8.11"
id "com.github.johnrengelman.shadow" version "8.1.1"
id 'com.github.jk1.dependency-license-report' version "2.9"
id 'org.cyclonedx.bom' version "1.10.0"
}
group = 'io.github.msg-systems'
version = rootProject.file('version.txt').text.trim()
description = 'JUnit Extension and Java Agent for energy consumption measurement. See also https://github.com/msg-systems/jpowermonitor'
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
// options.compilerArgs << '-Xlint:deprecation'
options.compilerArgs << '-parameters'
}
repositories {
mavenCentral()
}
configurations {
demo
}
dependencies {
implementation(
[group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.4.1'],
[group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.18.2'],
[group: 'org.yaml', name: 'snakeyaml', version: '2.3'],
[group: 'io.prometheus', name: 'simpleclient', version: '0.16.0'],
[group: 'io.prometheus', name: 'simpleclient_common', version: '0.16.0'],
[group: 'io.prometheus', name: 'simpleclient_hotspot', version: '0.16.0'],
[group: 'io.prometheus', name: 'simpleclient_httpserver', version: '0.16.0'],
[group: 'org.slf4j', name: 'slf4j-api', version: '2.0.16'],
)
demo (
[group: 'org.slf4j', name: 'slf4j-api', version: '2.0.16'],
[group: 'org.slf4j', name: 'slf4j-simple', version: "2.0.16"],
)
compileOnly(
[group: 'org.jetbrains', name: 'annotations', version: "26.0.1"],
[group: 'org.junit.jupiter', name: 'junit-jupiter', version: "5.11.4"],
)
testImplementation(
// use logger only in test implementation in order to have a minimal set of dependencies in main source
[group: 'org.slf4j', name: 'slf4j-simple', version: "2.0.16"],
[group: 'org.junit.jupiter', name: 'junit-jupiter', version: "5.11.4"],
[group: 'org.assertj', name: 'assertj-core', version: "3.27.0"]
)
}
apply from: "gradle/test-config.gradle"
apply from: "gradle/jar.gradle"
apply from: "gradle/dependencyUpdates.gradle"
apply from: "gradle/publish.gradle"
apply from: "gradle/signing.gradle"
apply from: "gradle/dist.gradle"
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
// --------------------- shadowJar
shadowJar {
exclude("*.yaml") // exclude template.yaml
exclude("*.json") // exclude grafana dashboards
exclude("simplelogger.properties")
exclude("group/msg/jpowermonitor/demo")
exclude("group/msg/jpowermonitor/demo/*")
dependencies {
exclude(dependency('org.slf4j:slf4j-simple'))
}
}
tasks.register('shadowJarDemo', ShadowJar) {
mergeServiceFiles()
group = "shadow"
archiveBaseName = 'jpowermonitor-demo'
configurations = [project.configurations.demo]
manifest {
attributes('Main-Class': 'group.msg.jpowermonitor.demo.StressCpuExample')
}
from(sourceSets.main.output) {
include 'group/msg/jpowermonitor/demo/StressCpuExample.class' // Pfad zur gewünschten Klasse
include 'simplelogger.properties'
}
}
shadowJar.dependsOn(shadowJarDemo)
// --------------------- license-report:
import com.github.jk1.license.filter.LicenseBundleNormalizer
import com.github.jk1.license.render.InventoryHtmlReportRenderer
licenseReport {
renderers = [new InventoryHtmlReportRenderer()]
filters = [new LicenseBundleNormalizer(bundlePath: "$projectDir/gradle/license-normalizer-bundle.json")]
}
// --------------------- SBOM:
cyclonedxBom {
// includeConfigs is the list of configuration names to include when generating the BOM
// (leave empty to include every configuration)
includeConfigs = []
// skipConfigs is a list of configuration names to exclude when generating the BOM
skipConfigs = ["testCompileClasspath", "testRuntimeClasspath"]
}