I'm trying to get a Java/Gradle project to build a shared/non-executable library JAR and publish it to my local Maven repo (so that I can pull it into other projects I'm working on locally).
My build.gradle:
plugins {
id 'java'
id 'maven'
}
version = '0.0.1-SNAPSHOT'
group = 'mygroup'
rootProject.name = 'myproject'
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile(
'ch.qos.logback:logback-classic:1.2.3'
,'org.apache.commons:commons-lang3:3.7'
)
testCompile(
'junit:junit:4.12'
,'org.mockito:mockito-core:2.23.0'
)
}
test {
// Trick to run tests in parallel with as much concurrency as possible.
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}
jar {
baseName = rootProject.name
}
And how I'm invoking it:
./gradlew clean build install
On my file system I see a /home/.m2/repository/myproject/unspecified/ directory (myrpoject is the name of my project and is correct) that contains:
myproject.jar; andmyproject.pom
I'm so close! I'm just trying to figure out to replace the unspecified version number with my configured value (0.0.1-SNAPSHOT) as well as how to change the installation directory to /home/.m2/repository/mygroup/myproject/unspecified/ (note the mygroup addition!)?