The JAR isn’t found:
thufir@mordor:~/NetBeansProjects/hello_client$
thufir@mordor:~/NetBeansProjects/hello_client$ gradle clean build;java -jar build/libs/hello_client.jar
Changed strategy of configuration ':compile' after it has been resolved. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0
:clean
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:startScripts
:distTar
:distZip
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
BUILD SUCCESSFUL
Total time: 1.078 secs
Exception in thread "main" java.lang.NoClassDefFoundError: net/bounceme/mordor/hello/HelloLibrary
at net.bounceme.mordor.hello.Client.foo(Client.java:13)
at net.bounceme.mordor.hello.Client.main(Client.java:9)
Caused by: java.lang.ClassNotFoundException: net.bounceme.mordor.hello.HelloLibrary
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
thufir@mordor:~/NetBeansProjects/hello_client$
it’s not in build:
thufir@mordor:~/NetBeansProjects/hello_client$
thufir@mordor:~/NetBeansProjects/hello_client$ tree build
build
├── classes
│ └── main
│ └── net
│ └── bounceme
│ └── mordor
│ └── hello
│ └── Client.class
├── dependency-cache
├── distributions
│ ├── hello_client.tar
│ └── hello_client.zip
├── libs
│ └── hello_client.jar
├── scripts
│ ├── hello_client
│ └── hello_client.bat
└── tmp
├── compileJava
│ └── emptySourcePathRef
└── jar
└── MANIFEST.MF
14 directories, 7 files
thufir@mordor:~/NetBeansProjects/hello_client$
but it is in ~/.gradle:
thufir@mordor:~/NetBeansProjects/hello_client$
thufir@mordor:~/NetBeansProjects/hello_client$ ll /home/thufir/.gradle/caches/modules-2/files-2.1/com.github.THUFIR/hello_api/latest/f78962c5e6db6f58bf4c1dfb088e29f0abaf3e0f/hello_api-latest.jar
-rw-rw-r-- 1 thufir thufir 1227 Mar 10 01:47 /home/thufir/.gradle/caches/modules-2/files-2.1/com.github.THUFIR/hello_api/latest/f78962c5e6db6f58bf4c1dfb088e29f0abaf3e0f/hello_api-latest.jar
thufir@mordor:~/NetBeansProjects/hello_client$
Now, how do I actually use it, because the compile fails.
build file:
apply plugin: 'application'
apply plugin: 'maven'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
if (!hasProperty('mainClass')) {
ext.mainClass = 'Client'
}
mainClassName = 'net.bounceme.mordor.hello.Client'
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.10'
compile 'com.github.THUFIR:hello_api:latest'
}
jar {
manifest {
attributes ('Main-Class': 'net.bounceme.mordor.hello.Client',
"Class-Path": configurations.compile.collect { it.getName() }.join(' '))
}
}
assemble.dependsOn (jar)
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}