I tried adding the jar{} section to my build.gradle file to set some extra manifest entries. But none of the entries appear in the jar files produced (either the sourcesJar or the library). I suspect they are being clobbered by something in the plugins. How do I get this to work?
import java.text.SimpleDateFormat
plugins {
id 'java'
id 'maven-publish'
id 'checkstyle'
id 'org.springframework.boot' version '2.6.6'
id 'com.github.spotbugs' version '5.0.4'
id 'com.google.protobuf' version '0.8.18'
}
... repos, dependencies, protobuf config, then...
task sourcesJar(type: Jar) {
from "src/main/java"
from "src/main/proto"
from "src/main/resources"
from "${buildDir}/generated/source/proto/main/grpc"
from "${buildDir}/generated/source/proto/main/java"
archiveClassifier = 'sources'
dependsOn("generateProto")
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.warnings = false
dependsOn("sourcesJar")
}
java {
withSourcesJar()
}
jar {
manifest {
attributes(
'Implementation-Title': "ProjectName",
'Implementation-Version': archiveVersion,
'Build-Time': new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date())
)
}
}
...