Skip to content

Commit 33e0cb0

Browse files
committed
Added gradle buildfiles for those that don't like maven
1 parent d7e1a07 commit 33e0cb0

3 files changed

Lines changed: 210 additions & 0 deletions

File tree

DataGen/build.gradle

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
group = 'com.johnlpage.datagen'
6+
version = '1.0'
7+
8+
java {
9+
toolchain {
10+
languageVersion = JavaLanguageVersion.of(17)
11+
}
12+
}
13+
14+
repositories {
15+
mavenCentral()
16+
}
17+
18+
dependencies {
19+
implementation 'org.apache.commons:commons-csv:1.9.0'
20+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.0'
21+
implementation 'com.google.guava:guava:32.1.2-jre'
22+
}
23+
24+
// --- Uber JAR task without Shadow ---
25+
task uberJar(type: Jar) {
26+
archiveBaseName.set('DataGen')
27+
archiveVersion.set('1.0')
28+
archiveClassifier.set('') // no classifier
29+
30+
// Write directly into target/ instead of build/libs
31+
destinationDirectory = file("$projectDir/target")
32+
33+
// Include compiled classes/resources
34+
from sourceSets.main.output
35+
36+
// Include runtime dependencies exploded into the jar
37+
dependsOn configurations.runtimeClasspath
38+
from {
39+
configurations.runtimeClasspath.collect {
40+
it.isDirectory() ? it : zipTree(it)
41+
}
42+
}
43+
44+
manifest {
45+
attributes(
46+
'Main-Class': 'com.johnlpage.datagen.DataGen'
47+
)
48+
}
49+
50+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
51+
}
52+
53+
// Build should produce uberJar
54+
tasks.build {
55+
dependsOn uberJar
56+
}

memex/build.gradle

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
plugins {
2+
id 'java'
3+
id 'org.springframework.boot' version '3.4.6'
4+
id 'io.spring.dependency-management' version '1.1.5'
5+
id 'jacoco'
6+
}
7+
8+
group = 'com.johnlpage'
9+
version = '1.0'
10+
description = 'MongoDB Enterprise Microservice Examples'
11+
12+
java {
13+
toolchain {
14+
languageVersion = JavaLanguageVersion.of(17)
15+
}
16+
}
17+
18+
repositories {
19+
mavenCentral()
20+
}
21+
22+
dependencyManagement {
23+
imports {
24+
mavenBom "io.cucumber:cucumber-bom:7.22.2"
25+
mavenBom "io.rest-assured:rest-assured-bom:5.5.5"
26+
}
27+
}
28+
29+
dependencies {
30+
// --- Main ---
31+
implementation 'org.springframework.boot:spring-boot-starter-actuator'
32+
implementation 'org.springframework.kafka:spring-kafka'
33+
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
34+
implementation 'org.springframework.boot:spring-boot-starter-web'
35+
implementation 'org.springframework.boot:spring-boot-starter-validation'
36+
37+
// Lombok (compile only, annotation processor)
38+
compileOnly 'org.projectlombok:lombok'
39+
annotationProcessor 'org.projectlombok:lombok'
40+
41+
// --- Test ---
42+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
43+
testImplementation 'io.cucumber:cucumber-java'
44+
testImplementation 'io.cucumber:cucumber-spring'
45+
testImplementation 'io.cucumber:cucumber-junit-platform-engine'
46+
testImplementation 'org.junit.jupiter:junit-jupiter'
47+
testImplementation 'org.junit.platform:junit-platform-suite'
48+
testImplementation 'io.rest-assured:rest-assured'
49+
testImplementation 'io.rest-assured:json-path'
50+
testImplementation 'org.testcontainers:junit-jupiter'
51+
testImplementation 'org.springframework.kafka:spring-kafka-test'
52+
testImplementation 'org.testcontainers:mongodb'
53+
54+
// Lombok annotation processor for tests
55+
testCompileOnly 'org.projectlombok:lombok'
56+
testAnnotationProcessor 'org.projectlombok:lombok'
57+
}
58+
59+
// Make Spring Boot fat jar go to target/
60+
bootJar {
61+
archiveBaseName.set('memex')
62+
archiveVersion.set(version)
63+
destinationDirectory = file("$projectDir/target")
64+
}
65+
66+
// Jacoco coverage
67+
jacoco {
68+
toolVersion = "0.8.12"
69+
}
70+
71+
tasks.test {
72+
useJUnitPlatform()
73+
}
74+
75+
tasks.jacocoTestReport {
76+
dependsOn tasks.test
77+
reports {
78+
xml.required.set(true)
79+
html.required.set(true)
80+
}
81+
}

mxtest/build.gradle

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
group = 'com.mongodb.solcon.mxtest'
6+
version = '1.0'
7+
8+
java {
9+
toolchain {
10+
languageVersion = JavaLanguageVersion.of(17)
11+
}
12+
}
13+
14+
repositories {
15+
mavenCentral()
16+
}
17+
18+
dependencies {
19+
implementation 'com.google.code.gson:gson:2.10.1'
20+
}
21+
22+
// --- Uber JAR task without Shadow ---
23+
task uberJar(type: Jar) {
24+
archiveBaseName.set('mxtest')
25+
archiveVersion.set('1.0')
26+
archiveClassifier.set('') // no classifier
27+
destinationDirectory = file("$projectDir/target") // Maven-style dir
28+
29+
// Compiled classes/resources
30+
from sourceSets.main.output
31+
32+
// Runtime dependencies as exploded contents
33+
dependsOn configurations.runtimeClasspath
34+
from {
35+
configurations.runtimeClasspath.collect {
36+
it.isDirectory() ? it : zipTree(it)
37+
}
38+
}
39+
40+
// Exclude unwanted META-INF stuff
41+
exclude(
42+
'module-info.class',
43+
'META-INF/versions/**/module-info.class',
44+
'META-INF/LICENSE*',
45+
'META-INF/NOTICE*',
46+
'META-INF/MANIFEST.MF',
47+
'META-INF/*.SF',
48+
'META-INF/*.DSA',
49+
'META-INF/*.RSA'
50+
)
51+
52+
// Merge service loader files
53+
eachFile { fileCopyDetails ->
54+
if (fileCopyDetails.path.startsWith('META-INF/services/')) {
55+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
56+
}
57+
}
58+
59+
// Manifest
60+
manifest {
61+
attributes(
62+
'Main-Class': 'com.mongodb.solcon.mxtest.MXTest'
63+
)
64+
}
65+
66+
// Default duplicate strategy for other files
67+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
68+
}
69+
70+
// Run uberJar when building
71+
tasks.build {
72+
dependsOn uberJar
73+
}

0 commit comments

Comments
 (0)