standalone jar AND library

Help
fsogni
2014-04-03
2014-04-03
  • fsogni
    fsogni
    2014-04-03

    Hi all,
    I would like to create a standalone jar that works as a library.
    Basically I would like to do: java -jar myProject.jar
    and at the same time being able to drop the jar to the /lib directory of a grails project and being able to do from one of the domain classes: import com.foo.bar.MyProject

    The first part works fine, i can run the project as a standalone jar, the second is missing.
    I the build.gradle file i added:

    task awesomeFunJar(type: OneJar) {
    mainClass = 'com.foo.bar.MyProject'
    additionalDir = file('src/main/java')
    }

    and actually in the resulting jar i can see com.foo.bar at the root level.
    Unfortunately if import com.foo.bar.MyProject or one of the classes i have an error.
    The same doesn't occour if for example i import com.simontuffs.onejar.Logger
    I played a bit with the manifest and other options without success.

    What am I doing wrong?

    Thanks,
    Fabio