0

I've decided to use gradle instead of ant in some of my applications. the folder structure for my apps is: <appname> ---java ------build.gradle ------settings.gradle ------sourcefolder1 ------sourcefolder2 ------sourcefolder3 ---------------subsourcefolder1 ---------------subsourcefolder2

I take the compilation files for every application and create a single jar that contains them all.

My issue is as follows: There is no code to compile under the java folder, only under its subdirectories which are sub-projects in gradle. So, I apply the java plugin only for the sub-projects. In this case everything compiles fine but the final jar to contain everything doesn't get created. On the other hand, if I apply the java plugin to the rootProject it starts compiling the source folders although they have a uniqe project of their own.

I tried applying the java plugin to the root project and overriding compileJava task to do nothing - but it created an empty jar, probably this task also generates the products to jar.

Is there an elegant solution for this?

Thanks.

ItamarBe
  • 482
  • 1
  • 5
  • 12
  • So you want to build your projects separately but have one big jar file at the end? Maybe creating a "uber" jar is the way to go for you. Have a look at this STOV thread: http://stackoverflow.com/questions/10986244/building-a-uberjar-with-gradle – Rene Groeschke Dec 21 '15 at 07:45
  • 1
    Actually not quite, I was debating between me and myself wether I should use sourceSets or seperate projects to represent my source folders. I decided to go on projects because it is far more simple and readable to declare dependencies between them, and I don't want to teach my colleagues about configurations\sourceSets and other internal structures of gradle. There are some drawbacks in this approach: I get a jar for each source folder altough I don't need it and gradle does "extra work" when projects are involved. but, I want only my classes to be in the uberjar, not my dependencies. @ReneGr – ItamarBe Dec 21 '15 at 08:50
  • @ReneGroeschke adding rene – ItamarBe Dec 21 '15 at 09:53

0 Answers0