<?xml version="1.0"?>

<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:util="jelly:util">

  <!--==================================================================-->
  <!-- Generate IntelliJ IDEA project, workspace and model files        -->
  <!--==================================================================-->
  <goal name="idea"
    description="Generate IDEA project files"
    prereqs="idea:generate-project"/>

  <goal name="idea:generate-project"
    description="Generate IDEA .ipr, .iml and .iws project files">

    <j:set var="template.dir" value="${plugin.resources}/templates/v${maven.idea.project.version}" />

    <ant:echo>Creating ${basedir}/${pom.artifactId}.ipr ...</ant:echo>

    <j:file name="${basedir}/${pom.artifactId}.ipr" prettyPrint="true" xmlns="dummy">
      <j:import file="${template.dir}/project.jelly" inherit="true"/>
    </j:file>

    <ant:echo>Creating ${basedir}/${pom.artifactId}.iws ...</ant:echo>

    <j:file name="${basedir}/${pom.artifactId}.iws" prettyPrint="true" xmlns="dummy">
      <j:import file="${template.dir}/workspace.jelly" inherit="true"/>
    </j:file>

    <util:available file="${template.dir}/module.jelly">
      <ant:echo>Creating ${basedir}/${pom.artifactId}.iml ...</ant:echo>

      <j:file name="${basedir}/${pom.artifactId}.iml" prettyPrint="true" xmlns="dummy">
        <j:import file="${template.dir}/module.jelly" inherit="true"/>
      </j:file>
    </util:available>

  </goal>

</project>
