How To Programmatically Add A build.xml

I have tried the AntConfiguration.getInstance(project).addBuildFile(virtualFile) and I always get a NullPointerException. I separated all of the steps (i.e. AntConfiguration ac = AntConfiguration.getInstance(project), etc) and nothing is null. Can you please outline the few steps that are needed starting with the VirtualFileManager.

Thank you.

5 comments
Comment actions Permalink

Am I right that you get NullPointer when you try to use returned value?
In IDEA 7.0.x there is a bug: the method call became asynchronous and null is always returned. This is fixed in IDEA 8 (EAP) and
coming release of IDEA 7.0.4.
The workaround for the current version would be re-reading the added value from the configuration.

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

"Darren" <no_reply@jetbrains.com> wrote in message news:1001651.45821212178211228.JavaMail.jive@app4.labs.intellij.net...
>I have tried the AntConfiguration.getInstance(project).addBuildFile(virtualFile) and I always get a NullPointerException. I
>separated all of the steps (i.e. AntConfiguration ac = AntConfiguration.getInstance(project), etc) and nothing is null. Can you
>please outline the few steps that are needed starting with the VirtualFileManager.
>

Thank you.



0
Comment actions Permalink

None of the returned values that I am using are null, The method addBuildFile is giving a null pointer exception internally.

Darren

0
Comment actions Permalink

Could you attach the stacktrace? Please specify exact build number as well.

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

"Darren" <no_reply@jetbrains.com> wrote in message news:16185175.51581212437318864.JavaMail.jive@app4.labs.intellij.net...

None of the returned values that I am using are null, The method addBuildFile is giving a null pointer exception internally.

>

Darren



0
Comment actions Permalink

Hi,
The build number is #7757.

Here is the stack trace:
java.lang.NullPointerException
at com.intellij.openapi.progress.impl.BackgroundableProcessIndicator.(BackgroundableProcessIndicator.java:19) at com.intellij.openapi.progress.impl.BackgroundableProcessIndicator.]]>(BackgroundableProcessIndicator.java:4)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressAsynchronously(ProgressManagerImpl.java:57)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.run(ProgressManagerImpl.java:38)
at com.intellij.lang.ant.config.impl.AntConfigurationImpl.addBuildFile(AntConfigurationImpl.java:144)
at bdjPlugin.BDJModuleBuilder.setupBuildFile(BDJModuleBuilder.java:126)
at bdjPlugin.BDJModuleBuilder.setupDirectories(BDJModuleBuilder.java:63)
at bdjPlugin.BDJModuleBuilder.setupRootModel(BDJModuleBuilder.java:41)
at com.intellij.ide.util.projectWizard.ModuleBuilder.createModule(ModuleBuilder.java:96)
at com.intellij.ide.util.projectWizard.ModuleBuilder.createAndCommit(ModuleBuilder.java:123)
at com.intellij.ide.util.projectWizard.ModuleBuilder$2.compute(ModuleBuilder.java:168)
at com.intellij.ide.util.projectWizard.ModuleBuilder$2.compute(ModuleBuilder.java:164)
at com.intellij.openapi.application.impl.ApplicationImpl$14.run(ApplicationImpl.java:1)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:98)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:272)
at com.intellij.ide.util.projectWizard.ModuleBuilder.commit(ModuleBuilder.java:164)
at com.intellij.ide.impl.ProjectUtil.createNewProject(ProjectUtil.java:175)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreen$4.onPress(WelcomeScreen.java:3)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreen$ActionGroupDescriptor$2.mouseClicked(WelcomeScreen.java:3)
at java.awt.Component.processMouseEvent(Component.java:6044)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5806)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4413)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3995)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at com.intellij.ide.IdeEventQueue.c(IdeEventQueue.java:131)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:18)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:136)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

0
Comment actions Permalink

Nevermind, after the fix this code is not called anymore. Does 7.0.4 EAP work for you?

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


0

Please sign in to leave a comment.