How to use a custom Javac task

View: New views
6 Messages — Rating Filter:   Alert me  

How to use a custom Javac task

by John Murph :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you use the uiDesigner in IntelliJ IDEA, you must use a special compiler.  This compiler is freely distributed by IntelliJ and is a drop in replacement for <javac> called <javac2>.  I had this working with the following code:

configurations
{
   javac2
}

dependencies
{
   javac2 'com.intellij:javac2:6.0.5'
}
def javac2Config = configurations.javac2

subprojects
{
   compile.doFirst { ant.taskdef(name:'javac', classname:'com.intellij.ant.Javac2', classpath:javac2Config.asPath) }
}

However, that recently stopped working.  I thought it was due to the source sets changes, so I tried to change the last line to "compileJava.doFirst..." but that did not help.  How can I make this work now?  Or is there a better way?

--
John Murph
Automated Logic Research Team

Re: How to use a custom Javac task

by Adam Murdoch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



John Murph wrote:

> If you use the uiDesigner in IntelliJ IDEA, you must use a special
> compiler.  This compiler is freely distributed by IntelliJ and is a
> drop in replacement for <javac> called <javac2>.  I had this working
> with the following code:
>
> configurations
> {
>    javac2
> }
>
> dependencies
> {
>    javac2 'com.intellij:javac2:6.0.5'
> }
> def javac2Config = configurations.javac2
>
> subprojects
> {
>    compile.doFirst { ant.taskdef(name:'javac',
> classname:'com.intellij.ant.Javac2', classpath:javac2Config.asPath) }
> }
>
> However, that recently stopped working.  I thought it was due to the
> source sets changes, so I tried to change the last line to
> "compileJava.doFirst..." but that did not help.  How can I make this
> work now?

It should still work (with the rename to compileJava). You could just do

subprojects {
    ant.taskdef(name:'javac', classname:'com.intellij.ant.Javac2',
classpath:javac2Config.asPath)
}

as all tasks in a project share the same AntBuilder instance.

I tried it out and it seems to work ok. How do you know it isn't
working? Do you get an error message?

> Or is there a better way?
>

I don't think so. It's an interesting use case for when (if?) we provide
native javac intergration.


Adam


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: How to use a custom Javac task

by John Murph :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I know it's not working because I get a NPE when a field that should be injected is referenced for the first time.  I previously saw this before I made those changes to get it working.  It worked for a couple of months and stopped working in the last couple of days.  This one has me stumped...

I'll report back if I learn anything more.


--
John Murph
Automated Logic Research Team

Re: How to use a custom Javac task

by Adam Murdoch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



John Murph wrote:
> I know it's not working because I get a NPE when a field that should
> be injected is referenced for the first time.  I previously saw this
> before I made those changes to get it working.  It worked for a couple
> of months and stopped working in the last couple of days.  This one
> has me stumped...
>

Very strange. However, I did just make some ugly changes to AntBuilder
to get rid of a memory leak, so I wonder if they are to blame.

Could you try using a different way of overriding the task:

Classloader cl = new URLClassLoader(buildscript.classLoader,
javac2Config.collect { it.toUri().toUrl() } as URL[])
Class javac2Class = cl.loadClass('com.intellij.ant.Javac2')

subprojects {
    ant.antProject.addTaskDefinition('javac', javac2Class)
}

> I'll report back if I learn anything more.
>
>
> --
> John Murph
> Automated Logic Research Team

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: How to use a custom Javac task

by John Murph :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm having problems remoting into my work PC from home right now, so I'll have to try that later.  Hopefully at some point this weekend I can get in.


On Fri, Sep 25, 2009 at 8:39 PM, Adam Murdoch <a@...> wrote:


John Murph wrote:
I know it's not working because I get a NPE when a field that should be injected is referenced for the first time.  I previously saw this before I made those changes to get it working.  It worked for a couple of months and stopped working in the last couple of days.  This one has me stumped...


Very strange. However, I did just make some ugly changes to AntBuilder to get rid of a memory leak, so I wonder if they are to blame.

Could you try using a different way of overriding the task:

Classloader cl = new URLClassLoader(buildscript.classLoader, javac2Config.collect { it.toUri().toUrl() } as URL[])
Class javac2Class = cl.loadClass('com.intellij.ant.Javac2')

subprojects {
  ant.antProject.addTaskDefinition('javac', javac2Class)

}

I'll report back if I learn anything more.


--
John Murph
Automated Logic Research Team

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email





--
John Murph
Automated Logic Research Team

Re: How to use a custom Javac task

by John Murph :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Sep 25, 2009 at 8:39 PM, Adam Murdoch <a@...> wrote:


John Murph wrote:
I know it's not working because I get a NPE when a field that should be injected is referenced for the first time.  I previously saw this before I made those changes to get it working.  It worked for a couple of months and stopped working in the last couple of days.  This one has me stumped...


Very strange. However, I did just make some ugly changes to AntBuilder to get rid of a memory leak, so I wonder if they are to blame.

Could you try using a different way of overriding the task:

Classloader cl = new URLClassLoader(buildscript.classLoader, javac2Config.collect { it.toUri().toUrl() } as URL[])
Class javac2Class = cl.loadClass('com.intellij.ant.Javac2')

subprojects {
  ant.antProject.addTaskDefinition('javac', javac2Class)

}



No effect, still the same NPE.
 

--
John Murph
Automated Logic Research Team