IDEA 9.0 - Artifact 'build on make' does not work until I run make at least twice (RESOLVED)

I just submitted this support request to JetBrains, but I wondered if anyone else here is seeing this problem:

I currently own IDEA 7 and I am evaluating the new IDEA 9 (I am considering buying an upgrade).  So far I like version 9 quite a bit, but I am getting repeatedly bitten by a problem that is driving me crazy: the "Build on Make" feature for artifacts seems to be hit-or-miss.  I have a single artifact that I use to copy any changed files (classes, JSPs, etc.) over to my Tomcat development instance's deploy directory (C:\Tomcat\webapps\myapp), and I then boot Tomcat so I can test my changes.  The problem is that "Build on make" does not always deploy (copy) my changed classes!  I have to execute make at least twice (sometimes more) in order for my changes to be deployed.  Running make again (or sometimes three times) makes IDEA finally copy the changed class files over.  Is there another setting I need to use in order for "Build on make" to *always* copy my changed class files?  Is this a known issue?  This bites me many times a day because I restart Tomcat to test my changed classes each time, so it is important that my changed classes are copied over to Tomcat automatically with each make.  [Deployment works perfectly for me in IDEA 7 because I don't use artifacts to copy my class files over (to my knowledge artifacts don't exist in version 7) -- in version 7 I just build to the tomcat webapps/myapp directory directly, which works fine for me.]

1 comment
Comment actions Permalink

Good news here -- the problem has been resolved!  First, I have to say that JetBrains' customer support is absolutely first-rate!  It turns out the problem only occurred for source files where the file's location under my content root did not match the package declared at the top of the file.  Here are the details snipped from my email to customer support:


Our main project tree looks like this (company and project names replaced with 'mycompany' and 'myproject'):


  C:\source\myproject\main\com\mycompany\...   (normal Java source files under here in package directories)


  C:\source\myproject\main\com\mycompany\test\com\mycompany\...  (TEST Java source files under here in package directories)


In IDEA, I have the 'main' module's content root defined as this:



What makes the test source files different (and quite unusual!) from IDEA's perspective is that the *directory under the content root* does not match the *declared package in the source file*.  For example, we have a test source file located here:





Inside, the package is declared as:


  package com.mycompany.caseset.util;   


Now, in the IDEA editor, IDEA (correctly!) complains by underlining the package in red with the tooltip message, "package name 'com.mycompany.caseset.util' does not correspond to file path 'test\com\mycompany\caseset\util'".  In other words, the content-root-relative path of the file is 'test\com\mycompany\caseset\util', but the *package name* is declared as 'com.mycompany.caseset.util'.

Everything runs OK because IDEA (correctly!) compiles the source file using the declared package name.  I suspect that IDEA thinks that there is a compile error in the because it thinks the package name is incorrect, and so it does not (on the first make) copy the compiled class file as part of the artifact.  

To illustrate, here is what I had defined previously:

C:\source\myproject    (CONTENT ROOT)

  Source Folders


The solution was to simply define a second 'Source' folder under my content root, as follows (change shown in red):

C:\source\myproject    (CONTENT ROOT)

  Source Folders



That worked like a charm!  Now I don't get the "wrong package" warning in the test files anymore, and "Build on make" works perfectly now on the first make command with the test files as well.   


Please sign in to leave a comment.