To Kra
To Kra

Reputation: 3578

How to compile only java classes with gradle without producing JAR

I have my gradle projects, using java plugin.

In my case I would only need to call classes task to compile only java files, and not create JAR- would need this to speed up some process.

If i call gradle classes its also producing jar's (i suppose that task has dependencies therefore runs also building of jar's).

How would you recommend to do only compiling classes ? I dont want to override that task, because in some cases, i need also to run normal gradle build which produces JAR's.

I tried to skip jar with gradle classes -x jar but it seems omitting external dependencies and causing compilation errors.

Its a multiproject, and running gradle classes from root project is generating JAR in some projects as you can see here https://drive.google.com/file/d/0B0DLkIfwhVMEb25uWHcwX1V1QUk/view?usp=sharing

Upvotes: 1

Views: 4276

Answers (1)

lance-java
lance-java

Reputation: 28016

See the diagram below from the java plugin documentation. The classes task should not call jar enter image description here

EDIT

Here's the result of running a simple gradle file

apply plugin: 'java'

Output:

> gradle classes
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE

BUILD SUCCESSFUL 

As you can see the jar task is not in the task graph

You could try adding the task tree plugin to your build and then run gradle classes taskTree to see what's causing the jar task to be added to the task graph

Upvotes: 1

Related Questions