JavaSourceTransformingCompiler causes all files to be always rebuilt

Hi,

I use a JavaSourceTransformingCompiler to add some source instrumentation of Java files.

When my compiler is active (ie isTransformable() returns true for all potentially transformable files), all files are always instrumented and rebuilt during Make, including the clean ones.

Is there any way to inject ValidityState (dependency) objects to prevent instrumentation and recompilation of files that have not changed?
Or find out whether given file is considered dirty and should be recompiled, so I could return true from isTransformable only in this case? (I don't want to have the uninstrumented file to be compiled behind my back, though)

I tried to use SourceInstrumentingCompiler, but it causes the original files to be changed - is it by design? Should any compiler permanently change the source files?
I also tried a TransformingCompiler registered for JAVA->JAVA transformation that I expected to be injected before the actual Java Compiler, but it just created instrumented files in a folder I chose - they were not compiled afterward.
Next, I tried to wrap JavaCompiler with my own wrapper that would provide my own array of VirtualFiles to the JavaCompiler.compile() method, but it seems to ignore what I provide - as if it internally retrieved the list of files from other source.

Is there anything I could do to have a working Make with source instrumentation? working = rebuilding only the files that have changed.
Is anything going to improve with Idea 8.0?

Regards
Slawomir Ginter

6 comments
Comment actions Permalink

Hi Slawomir,
Please check that original file passed to your transforming compiler is not modified.
Since JavaSourceTransformingCompiler is applied only to files that were selected for recompilation, unchanged files won't be
transformed. In fact, original source files must not be transformed; all the transformations are done just before the file is passed
to javac and applied to the copy of that file. The modified copy is then passed to javac instead of the original source file.
You don't need to register input-output types for this compiler (JAVA->JAVA) because the compiler is applied only to java files.

The SourceInstrumentingCompiler causes original sources to be changed and this is by design. Depending on what you need you may
choose to use it or not.

--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"Slawomir Ginter" <sginter@atlassian.com> wrote in message news:12822336.3851224083996432.JavaMail.jive@app4.labs.intellij.net...

Hi,

>

I use a JavaSourceTransformingCompiler to add some source instrumentation of Java files.

>

When my compiler is active (ie isTransformable() returns true for all potentially transformable files), all files are always
instrumented and rebuilt during Make, including the clean ones.

>

Is there any way to inject ValidityState (dependency) objects to prevent instrumentation and recompilation of files that have not
changed?
Or find out whether given file is considered dirty and should be recompiled, so I could return true from isTransformable only in
this case? (I don't want to have the uninstrumented file to be compiled behind my back, though)

>

I tried to use SourceInstrumentingCompiler, but it causes the original files to be changed - is it by design? Should any compiler
permanently change the source files?
I also tried a TransformingCompiler registered for JAVA->JAVA transformation that I expected to be injected before the actual Java
Compiler, but it just created instrumented files in a folder I chose - they were not compiled afterward.
Next, I tried to wrap JavaCompiler with my own wrapper that would provide my own array of VirtualFiles to the
JavaCompiler.compile() method, but it seems to ignore what I provide - as if it internally retrieved the list of files from other
source.

>

Is there anything I could do to have a working Make with source instrumentation? working = rebuilding only the files that have
changed.
Is anything going to improve with Idea 8.0?

>

Regards
Slawomir Ginter



0
Comment actions Permalink

Hi,

I just noticed that this happens for test folders only (green ones).

I mean, I have 2 source folders in my project: src and test.
When I mark both as "blue" folders (Sources in Project settings -> Modules) all works fine.
If I mark the test folder as Test Sources ("green"), the problem occurs - contents of this folder only are always recompiled.

Could you please verify this for me?
Maybe there is some check that is done for one type of source folder only?

Regards,
Slawomir Ginter

Edited by: Slawomir Ginter on Oct 16, 2008 11:07 PM

0
Comment actions Permalink

Hi Slawomir,

You have not mentioned whether you checked all the things I mentioned in my previous post.

Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

I checked the timestamps etc - nothing seems changed.
Here is a simplified version of the plugin that causes the problem (~15 lines of meaningful code)

A very simple plugin + a very simple project demonstrating the problem.

1. Install the SimpleTranslator.jar as a plugin
2. Open the SimpleTranslatorTest project
3. Make sure the test folder is green - marked as tests source in module settings
4. Make the project a few times (Command-F9) - you should see the TestClass (only) recompiled each time (my compiler issues a warning with compiled file name)
5. Mark test folder blue - "normal" source folder
6. Make the project a few times - after the first one nothing should be compiled
7. goto 3

See SimpleTranslator project for plugin source (really simple)



Attachment(s):
SimpleTranslator.zip
0
Comment actions Permalink

Thanks Slawomir, indeed there was a problem with determining whether the transformed file belonged to test root. This was fixed and the fix will be available in the coming Diana build

0
Comment actions Permalink

Thanks a lot.

If you could also do something about file names, or suggest some workaround, you would have solved 2 of my most frequently reported problems :)

Regards,
Slawomir Ginter

0

Please sign in to leave a comment.