Can I compile java files transitively without doing full module compile?

Answered

When called from command line, `javac` will compile any dependencies of a file automatically.

But with

ProjectTaskManager.getInstance(project).compile(file) 

this is not the case. For any declared import, you get 

Error:(4, 37) java: package com.xxx does not exist

I can't compile the full project straight away because I have missing classes that need to be generated first (with a generator that I'm trying to compile above).

Thanks in advance for any suggestion.

0
1 comment
Avatar
Permanently deleted user

Hi Amyn,

You cannot choose one files and let the build system (we name it "JPS") compile this file and all its dependencies. This is done deliberately, as the "main" action is always supposed to be incremental "Build" and it is assumed that "Recompile" is used rather rarely, to precisely recompile partticular file or a set of files.

Looks like a your problem is a matter of project configuration. I would break the sources on modules: Module "Gen" will contain the source generator, 

module "Main" depending on "Gen" would contain sources that depend on the generator or the fililes it generated. Dependencies between modules will naturally define the compilation sequence and you won't have to remember to compile or recompile a susbset of files "manually".

1

Please sign in to leave a comment.