|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
IDEA Project generation from antHi,
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. There is a plugin in maven to do this.. but unable to find the similar thing for ant.. any leads pl. Regards, Raja Nagendra Kumar, C.T.O www.tejasoft.com |
|
|
RE: IDEA Project generation from antI 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:Nagendra.Raja@...] Sent: Tuesday, November 03, 2009 4:01 AM To: user@... 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: user-unsubscribe@... For additional commands, e-mail: user-help@... ---------------------------------------------------------------------- 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: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: IDEA Project generation from antI generally only generate .classpath files and then use them in both
Eclipse and IntelliJ. Savant also has a plugin for generating files and since it is an Ant script , you can use that. The best approach is to use a stock XML file that contains most everything and then a simple script to add in the necessary JAR files. Try to keep it simple because most of the time you are just updating the dependencies of the project. -bp On Nov 3, 2009, at 3:01 AM, Raja Nagendra Kumar wrote: > > 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: user-unsubscribe@... > For additional commands, e-mail: user-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: IDEA Project generation from ant> I generally only generate .classpath files
Could you tell me how you archive this with ant >Try to keep it simple because most of the time you are just updating the dependencies of the project. This is perfect way.. could be archived by syncup with the existing ipr files. Yes, mostly classpath, sourcepaths etc would get changed in our case. Lack of ant task for generation of project files, would it be possible to use the code used by maven to do the same job.. if yes, any pointers pl. Regards, Nagendra |
|
|
RE: IDEA Project generation from antHi Shawn,
Thank you Shawn for sharing your macro. We shall start from here.. and see if we could write a good ant task based on this. Regards, Nagendra |
|
|
Re: IDEA Project generation from antOn Nov 3, 2009, at 9:44 PM, Raja Nagendra Kumar wrote: > >> I generally only generate .classpath files > > Could you tell me how you archive this with ant The .classpath format is an extremely simple XML format that tells the IDE where the source paths are and the JAR files for the project. This is the Eclipse storage format. IntelliJ can be told to use the Eclipse .classpath for its dependencies as well. This requires changes to the .iml file and it also creates an additional file ending in .eml. Then, I just use a simple Groovy script to manipulate the XML in the .classpath file with the new dependencies. I really need to update my script, but it is pretty simple to manipulate XML in Groovy and Groovy inside Ant is really simple as well. I believe the best method is to load the .classpath into the Groovy XML objects, remove all the elements whose type attribute is "var" and then generate new elements for each of the project's dependencies. The generation of the new elements will depend on the dependency management tool you are using. -bp --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: IDEA Project generation from antThank you Brian we shall try this.
Regads, Nagendra
|
| Free embeddable forum powered by Nabble | Forum Help |