In the groovy script wrapper, you will see this line below:
This is where you can add your dependencies. If the jar file is in the same directory you are building from, add the following line:
zipgroupfileset( dir: '.', includes: 'sqljdbc4.jar' )
Then restart the script and your jar will include the classes from sqljdbc4.jar .
Edit:
If the jar file you depend on is signed and you need to maintain a signature, you will have to keep an external jar. You cannot include jar files inside other jar files without using a custom class loader. However, you can specify the dependency in the manifest to avoid having to set the class path, i.e. Your jar is still executable with java -jar myjar.jar . Update the manifest section in the script wrapper to:
manifest { attribute( name: 'Main-Class', value: mainClass ) attribute( name: 'Class-Path', value: 'sqljdbc4.jar' ) }
source share