title: Intellij IDEA artifact 'XXXX:war exploded' has invalid extension
body: <p>Every time I make even the tiniest change to my POM Intellij removes the .war extension for my <em>exploded</em> artifact in the Project Structure output directory setting. This causes an error in Intellij's Run/Debug configuration: </p>
  
  <p><strong>Artifact 'XXXX:war exploded' has invalid extension.</strong> </p>
  
  <p>In order to resolve the issue I must manually override the Project Structure output directory setting. Every time I make even the tiniest change to the POM I must go back to the Output directory setting and manually append ".war" to the end of the Output directory setting.  This is getting very old and frustrating.</p>
  
  <p>e.g. I must change this:</p>
  
  <p>E:\workarea\enterp\application\target\application</p>
  
  <p>to this:</p>
  
  <p>E:\workarea\enterp\application\target\application.war</p>
  
  <p>If I manually set the Maven WAR plugin outputDirectory configuration as follows, this does not help at all: </p>
  
  <pre><code>&lt;plugin&gt;
      &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
      &lt;version&gt;${maven.war.plugin.version}&lt;/version&gt;
      &lt;configuration&gt;
  
          &lt;!-- Output directory of artifact:war exploded keeps losing the .war extension --&gt;
          &lt;outputDirectory&gt;${project.build.directory}.war&lt;/outputDirectory&gt;
  
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>How can I resolve this problem?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here's the complete build config:</p>
  
  <pre><code>    &lt;build&gt;
      &lt;!-- Maven will append the version to the finalName (which is the name
          given to the generated war, and hence the context root) --&gt;
      &lt;finalName&gt;${project.artifactId}&lt;/finalName&gt;
  
      &lt;plugins&gt;
          &lt;!-- Compiler plugin enforces Java 1.6 compatibility and activates annotation
              processors --&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;${maven.compiler.plugin.version}&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;${maven.compiler.source}&lt;/source&gt;
                  &lt;target&gt;${maven.compiler.target}&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;version&gt;${maven.war.plugin.version}&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;!-- Output directory of artifact:war exploded keeps losing the .war extension --&gt;
                  &lt;outputDirectory&gt;${project.build.directory}/${project.artifactId}.war&lt;/outputDirectory&gt;
  
                  &lt;!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! --&gt;
                  &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;!-- The WildFly plugin deploys your war to a local WildFly container --&gt;
          &lt;!-- To use, run: mvn package wildfly:deploy --&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.wildfly.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;wildfly-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;${version.wildfly.maven.plugin}&lt;/version&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  
  &lt;/build&gt;
  </code></pre>
  
  <p><strong>SECOND EDIT:</strong></p>
  
  <p>I discovered that one solution is to append ".war" to ${project.artifactId} in the build configuration, e.g.:</p>
  
  <pre><code>&lt;finalName&gt;${project.artifactId}.war&lt;/finalName&gt;
  </code></pre>
  
  <p>and remove outputDirectory from the plugin configuration.  So the build config should look like this:</p>
  
  <pre><code>&lt;build&gt;
      &lt;!--
          Maven will make finalName the name of the generated war.
  
          NOTE:   Output directory of artifact:war exploded keeps losing the .war extension
                  http://youtrack.jetbrains.com/issue/IDEA-86484
                  http://youtrack.jetbrains.com/issue/IDEA-95162
  
                  The solution is to append ".war" to ${project.artifactId}, below:
      --&gt;
      &lt;finalName&gt;${project.artifactId}.war&lt;/finalName&gt;
  
      &lt;plugins&gt;
          &lt;!-- Compiler plugin enforces Java 1.6 compatibility and activates annotation
              processors --&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;${maven.compiler.plugin.version}&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;${maven.compiler.source}&lt;/source&gt;
                  &lt;target&gt;${maven.compiler.target}&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;version&gt;${maven.war.plugin.version}&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! --&gt;
                  &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;!-- The WildFly plugin deploys your war to a local WildFly container --&gt;
          &lt;!-- To use, run: mvn package wildfly:deploy --&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.wildfly.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;wildfly-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;${version.wildfly.maven.plugin}&lt;/version&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  
  &lt;/build&gt;
  </code></pre>
  
  <p>DISCLAIMER:  If you use this workaround just be aware that when you deploy an unexploded WAR artifact the file name will be named XXXX.war.war.  It works -- I deployed the artifact as a WAR file in Intellij -- but it's ugly.</p>
  
  <blockquote>
    <p>INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "XXXX.war.war" (runtime-name: "XXXX.war.war)"</p>
  </blockquote>
  
  <p>If someone can tell me how to configure the Intellij project to work with Maven to select one or the other finalName values depending on whether I'm deploying a WAR file vs. exploded artifact then this question will be sufficiently answered.</p>
  
  <pre><code>&lt;!-- Exploded artifact --&gt; 
  &lt;finalName&gt;${project.artifactId}.war&lt;/finalName&gt;
  
  &lt;!-- WAR file (unexploded) artifact --&gt; 
  &lt;finalName&gt;${project.artifactId}&lt;/finalName&gt;
  </code></pre>