I would advise against creating the ipr file as it is very long and nasty. I
would suggest only generating the iml file which is the important part and
points to the source code locations and dependent jars. I have written a
macrodef to generate an IML that has been tested against IJ 8.1.3. This
macrodef has references to other specific items in my build system so you will
not be able to use it directly without modification. But, perhaps you can use
it as a template to write your own. Once a user generates their IML from this,
they can create a new project in IJ and then import this IML file and they are
ready to go.
<macrodef name="generateIntelliJModule" description="Converts a
dependency directory into an IntelliJ module iml file">
<!--Assumes source code is in src directory at root-->
<!--Assumes thirparty jars are in jar directory at
root-->
<!--Doesn't take into account env.BUILD_DIR-->
<!--Doesn't take into account user ivy.xml file-->
<attribute name="moduleName"/>
<attribute name="moduleDir"/>
<attribute name="moduleSandbox"/>
<attribute name="moduleDependency"/>
<sequential>
<!--Check for ivy module location-->
<ac:var name="ivyModuleDir" unset="true"/>
<ac:var name="ivyDependencySourceDir"
unset="true"/>
<condition property="ivyModuleDir"
value="$...@{modulename}.sandbox.dir}" else="@{moduleDir}">
<and>
<istrue
value="@{moduleSandbox}"/>
<istrue
value="@{moduleDependency}"/>
</and>
</condition>
<!--IntelliJ likes forward slashes-->
<at:stringutil property="ivyModuleDir"
string="${ivyModuleDir}">
<at:replace regex="\\" replacement="/"/>
</at:stringutil>
<at:stringutil
property="ivyDependencySourceDir" string="${env.DEPENDENCIES_SOURCE_DIR}">
<at:replace regex="\\" replacement="/"/>
</at:stringutil>
<!--Write generic file-->
<echoxml file="@{moduleDir}/@{moduleName}.iml">
<module relativePaths="false"
type="JAVA_MODULE" version="4">
<component
name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output/>
<content
url="file://${ivyModuleDir}"/>
<orderEntry
type="inheritedJdk"/>
<orderEntry
type="sourceFolder" forTests="false"/>
<orderEntry
type="module-library" exported="">
<library
name="@{moduleName}-jars">
<CLASSES/>
<JAVADOC/>
<SOURCES/>
</library>
</orderEntry>
</component>
</module>
</echoxml>
<!--Add excludes-->
<ac:if>
<isset
property="@{moduleName}.intellij.exclude"/>
<ac:then>
<!--IntelliJ likes forward
slashes-->
<at:stringutil
property="@{moduleName}.intellij.exclude"
string="$...@{modulename}.intellij.exclude}">
<at:replace regex="\\"
replacement="/"/>
</at:stringutil>
<ac:for
param="intellij.excludeDir" list="$...@{modulename}.intellij.exclude}">
<sequential>
<xt:xmltask
source="@{moduleDir}/@{moduleName}.iml" dest="@{moduleDir}/@{moduleName}.iml">
<xt:insert path="/module/component/content" xml="<excludeFolder
url="file://${ivyModuleDir}/@{intellij.excludeDir}"/>"/>
</xt:xmltask>
</sequential>
</ac:for>
</ac:then>
</ac:if>
<!--Add jars-->
<ac:if>
<available file="${ivyModuleDir}/jar"/>
<ac:then>
<!--Only recurse jars if a real
sandbox-->
<ac:var
name="ivyModuleRecurseJars" unset="true"/>
<condition
property="ivyModuleRecurseJars" value="true">
<istrue
value="@{moduleSandbox}"/>
</condition>
<ac:for param="ivyModuleDirJar">
<fileset
dir="${ivyModuleDir}/jar">
<include
name="*.jar" unless="ivyModuleRecurseJars"/>
<include
name="*.zip" unless="ivyModuleRecurseJars"/>
<include
name="**/*.jar" if="ivyModuleRecurseJars"/>
<include
name="**/*.zip" if="ivyModuleRecurseJars"/>
</fileset>
<sequential>
<!--IntelliJ
likes forward slashes-->
<at:stringutil
property="ivyModuleDirJar" string="@{ivyModuleDirJar}">
<at:replace regex="\\" replacement="/"/>
</at:stringutil>
<xt:xmltask
source="@{moduleDir}/@{moduleName}.iml" dest="@{moduleDir}/@{moduleName}.iml">
<xt:insert path="/module/component/orderEntry/library/CLASSES" xml="<root
url="jar://${ivyModuleDirJar}!/"/>"/>
</xt:xmltask>
</sequential>
</ac:for>
</ac:then>
</ac:if>
<!--Add JavaDoc URL if not sandbox dependency-->
<ac:if>
<isfalse value="@{moduleSandbox}"/>
<ac:then>
<ac:var
name="ivy-module.info(revision)" unset="true"/>
<xmlproperty
file="${ivyModuleDir}/ivy/ivy.xml"/>
<!--Strip off release spec name
from revision of dependency-->
<at:stringutil
property="ivyModuleReleaseSpec" string="${ivy-module.info(revision)}">
<at:replace
regex="\..*" replacement=""/>
</at:stringutil>
<xt:xmltask
source="@{moduleDir}/@{moduleName}.iml" dest="@{moduleDir}/@{moduleName}.iml">
<xt:insert
path="/module/component/orderEntry/library/JAVADOC" xml="<root
url="http://cmnas01.lgc.com/www/docs/@{moduleName}/${ivyModuleReleaseSpec}/java"/>"/>
</xt:xmltask>
</ac:then>
</ac:if>
<!--Add compiled source path-->
<ac:if>
<available file="${ivyModuleDir}/src"/>
<ac:then>
<xt:xmltask
source="@{moduleDir}/@{moduleName}.iml" dest="@{moduleDir}/@{moduleName}.iml">
<xt:attr
path="/module/component" attr="inherit-compiler-output" value="false"/>
<xt:insert
path="/module/component/exclude-output" position="before" xml="<output
url="file://$MODULE_DIR$/build/classes"/>"/>
<xt:insert
path="/module/component/exclude-output" position="before" xml="<output-test
url="file://$MODULE_DIR$/build/testClasses"/>"/>
<xt:insert
path="/module/component/content" xml="<sourceFolder
url="file://${ivyModuleDir}/src"
isTestSource="false"/>"/>
<xt:insert
path="/module/component/content" xml="<sourceFolder
url="file://${ivyModuleDir}/test"
isTestSource="true"/>"/>
<xt:insert
path="/module/component/content" xml="<content
url="file://$MODULE_DIR$/build"><sourceFolder
url="file://$MODULE_DIR$/build/generated"
isTestSource="false"/></content>" position="after"/>
</xt:xmltask>
</ac:then>
</ac:if>
<!--Add library source path-->
<ac:if>
<available
file="${ivyDependencySourceDir}/@{moduleName}/src"/>
<ac:then>
<xt:xmltask
source="@{moduleDir}/@{moduleName}.iml" dest="@{moduleDir}/@{moduleName}.iml">
<xt:insert
path="/module/component/orderEntry/library/SOURCES" xml="<root
url="file://${ivyDependencySourceDir}/@{moduleName}/src"/>"/>
</xt:xmltask>
</ac:then>
</ac:if>
<!--Insert in dependencies-->
<ac:var name="ivyModuleFile" unset="true"/>
<condition property="ivyModuleFile"
value="${ivyModuleDir}/ivy.xml" else="${ivyModuleDir}/ivy/ivy.xml">
<istrue value="@{moduleSandbox}"/>
</condition>
<ac:var name="hasIvyDependencies"
value="false"/>
<xt:xmltask source="${ivyModuleFile}">
<xt:call
path="ivy-module/dependencies/dependency">
<param
name="ivyModuleDependencyName" path="@name"/>
<xt:actions>
<ac:var
name="hasIvyDependencies" value="true"/>
<xt:xmltask
source="@{moduleDir}/@{moduleName}.iml" dest="@{moduleDir}/@{moduleName}.iml">
<xt:insert
path="/module/component" xml="<orderEntry type="module"
module-name="@{ivyModuleDependencyName}" exported=""/>"/>
</xt:xmltask>
</xt:actions>
</xt:call>
</xt:xmltask>
<ac:if>
<isfalse value="${hasIvyDependencies}"/>
<ac:then>
<xt:xmltask
source="@{moduleDir}/@{moduleName}.iml" dest="@{moduleDir}/@{moduleName}.iml">
<xt:insert
path="/module/component" xml="<orderEntry type="module"
module-name="lgcbuild" exported=""/>"/>
</xt:xmltask>
</ac:then>
</ac:if>
<echo message="Created IntelliJ IML file:
@{moduleDir}/@{moduleName}.iml"/>
</sequential>
</macrodef>
---
Shawn Castrianni
-----Original Message-----
From: Raja Nagendra Kumar [mailto:[email protected]]
Sent: Tuesday, November 03, 2009 4:01 AM
To: [email protected]
Subject: IDEA Project generation from ant
Hi,
Are there any ant tasks available to generate intellij and/or eclipse
projects from ant target. I wish to provide the needed class and source
paths.
Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
--
View this message in context:
http://old.nabble.com/IDEA-Project-generation-from-ant-tp26160045p26160045.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and
privileged information for the sole use of the intended recipient. Any review,
use, distribution, or disclosure by others is strictly prohibited. If you are
not the intended recipient (or authorized to receive information for the
intended recipient), please contact the sender by reply e-mail and delete all
copies of this message.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]