I am trying to get the Gradle Maven Publish Plugin to publish a snapshot version of my Java library to my local Maven repo such that:
- The version of the jar is
1.0.0.SNAPSHOT-<timestamp>
, where<timestamp>
is the current system time in millis (similar to something likeSystem.currentTimeInMillis()
); and - I log to STDOUT/console the full name of the jar being published, including the version above; and
- A properly-formatted pom.xml is published to Maven local alongside the jar, so that any other Gradle/Maven projects can "pull it down" locally and fetch its transitive dependencies properly
My best attempt so far:
plugins {
id 'java-library'
id 'maven-publish'
}
dependencies {
compile(
'org.hibernate:hibernate-core:5.0.12.Final'
,'com.fasterxml.jackson.core:jackson-core:2.8.10'
,'com.fasterxml.jackson.core:jackson-databind:2.8.10'
,'com.fasterxml.jackson.core:jackson-annotations:2.8.0'
)
testCompile(
'junit:junit:4.12'
)
}
repositories {
jcenter()
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
group 'com.me'
jar {
baseName = 'my-lib'
version = '1.0.0-SNAPSHOT'
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
However, with this setup, when I run ./gradlew publishToMavenLocal
:
- I do see the jar being deployed to
~/.m2/repository/com/me/my-lib/
but without a pom.xml and no1.0.0.SNAPSHOT
version appended to it - I don't even know how/where I would append the timestamp onto the version
- I don't even know how/where I would do a
println(...)
to report the full name of the jar being published
Any ideas?