Reputation: 22646
I have the following build.gradle
file. One of my dependences is json-simple
. However,
when I create my jar HttpSnapClient
that is not included in the jar file.
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'groovy'
mainClassName = 'com.sunsystem.HttpSnapClient.SnapClient'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile "com.googlecode.json-simple:json-simple:1.1.1"
testCompile "org.codehaus.groovy:groovy:2.3.3"
testCompile "org.spockframework:spock-core:0.7-groovy-2.0"
}
jar {
baseName = 'HttpSnapclient'
version ='1.0.0'
}
task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}
I would like to bundle the json-simple.jar
into my HttpSnapClient.jar
so my application that will use this HttpSnapClient.jar
will already have json-simple.jar
included.
when I run the following command jar tvf HttpSnapclient-1.0.0.jar
0 Mon Jun 30 14:37:56 ICT 2014 META-INF/
25 Mon Jun 30 14:37:56 ICT 2014 META-INF/MANIFEST.MF
294 Mon Jun 30 14:37:56 ICT 2014 WebServiceResponseCodes.class
0 Mon Jun 30 14:37:56 ICT 2014 com/
0 Mon Jun 30 14:37:56 ICT 2014 com/sunsystem/
0 Mon Jun 30 14:37:56 ICT 2014 com/sunsystem/HttpSnapClient/
5965 Mon Jun 30 14:37:56 ICT 2014 com/sunsystem/HttpSnapClient/SnapClient.class
There is no json-simple included, so any application that uses this HttpSnapClient will fail as its looking for the json-simple that has not been included.
When I run I get the following: gradle dependencies
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
archives - Configuration for archive artifacts.
No dependencies
compile - Compile classpath for source set 'main'.
\--- com.googlecode.json-simple:json-simple:1.1.1
\--- junit:junit:4.10
\--- org.hamcrest:hamcrest-core:1.1
default - Configuration for default artifacts.
\--- com.googlecode.json-simple:json-simple:1.1.1
\--- junit:junit:4.10
\--- org.hamcrest:hamcrest-core:1.1
Thanks in advance for any suggestions.
Upvotes: 1
Views: 925
Reputation: 1422
Seems like you are running gradle build instead of gradle distZip or gradle distTar which bundles everything into either a zip og tar. Might be you are more interested in the solution @Opal is suggesting though. Application plugin will create a distribution with a bin folder for startupscripts and a lib for all your jars.
Upvotes: 1