understanding build vs rebuild vs make vs compile

so, the way I understand it, when it comes to compilation,there's conditional, and there's clean:  confitional compilation only rewrites files that have changed, clean compilation blows them all away and starts fresh

build and rebuild and are clean, and make and compile are conditional... true?

are build and rebuild exactly the same things? are make and compile exactly the same things?

I have a multi-module project in which one module is constantly changing, and one changes almost never. so I disable compilation on that one, to save time during each test run. but sometimes I do want to rebuild, not just make, that module. is there a "rebuild module" command? dont see one

another question: from the docs and looking at the autogenerated ant scripts, intellij by default creates two subdirectories for each module: testing and production... I understand this distinction in a general way, but what exactly is the story here? am I able to define two different build profiles, one for testing, one for production? I dont see any config panel for all that

and, must have set up my output configs incorrectly because when I use rebuild project, I get one folder per module, no production/testing dirs

somehow my autogenerated ant scripts are getting scrambled... or?

thanks!

3 comments

Hello.

"Build" action exists only for artifacts. For sources there is Compile, Make and Rebuild. For a quick guide see: http://www.jetbrains.com/idea/webhelp/compilation-types.html

Rebuild and Compile are clean in your terms, Make is conditional. Compile unconditionally compiles just pointed files, no more, no less (i.e. it may report errors, if dependencies are not compiled).

If a module does not change, Make should do nothing for it, so not spending resources. However, Rebuild will process everything from scratch. Typically users call Make regularly and Rebuild rarely, in case of some corruptions.

Production directory is for sources root output, test is for test output. On configuring them see:
http://www.jetbrains.com/idea/webhelp/content-root.html
http://www.jetbrains.com/idea/webhelp/configuring-module-compiler-output.html
And around.

Regards,
Alexander.

0

ceteris wrote:

build and rebuild and are clean, and make and compile are conditional... true?

are build and rebuild exactly the same things?


I'm not sure where you are seeing "Build", unless you are referring to"Build Artifact". IDEA has three compilation types:

  1. Compile
  2. Make
  3. Rebuild

  1. Compile - this just complies the files in the specified scope. So you can, for example, compile just a single class or a package (or, of course, a module). It does not transitively compile dependencies. So if Foo has a dependency on Bar, and Bar was not previously compiled, and you go to compile Foo only, the compilation fails. If Bar was previous compiled, but has changed, and you again only compile Foo, it uses the old compiled version and does not recompile the changed Bar class. Compile always compiles everything in the scope (i.e. a clean compile); this includes unmodified classes within the scope. But again, not transitively/recursively. If you compile module "GUI" which has a dependency on module "API", only GUI is complied. If "API" was not previously compiled (or has changes) the compiling of GUI would fail. Finally, compile only compiles code. It does not create any artifacts (JARs, WARs, etc.)
  2. Make - Make is limited to the module or project level. (i.e. you cannot make a single class or package). It only compiles modified classes. Make, however, will transitively/recursively compile dependencies. Thus, using the above example, if we make "GUI", it will also make "API" and compile any classes modified since last compilation. When you make a project, some additional tasks that tiled to the make process are performs, such as EJB validation. Finally, make only compiles classes and does not create any artifacts (JARs, WARs, etc.) So the main difference between compile and make is that compile can be performed on a finer level (class or package) and make compiles transitive/recursive dependencies.
  3. Rebuild - This performs a full clean make on the project. So unlike make, it deletes all previous compiled objects. Rebuild can only be performed at the project level (so, "No" to answer your question about a module rebuild). Rebuild only compiles classes and does not create any artifacts (JARs, WARs, etc.)


There is also the "Build Artifact" action which allows you to "Build", "Rebuild" or just clean the artifact. Build only builds it if there is modified code, whereas Rebuild always rebuilds it.

Also of note, in the compiler configuration, you can select to "Make the project automatically" if you have the "Use external build" option selected. The latter simply runs the build in a separate OS process. Therefore you can select the former, and IDEA will automatically make the project in the background. As such, when you go to run code or tests, there is typically little if any code that needs to be compiled.

ceteris wrote:

another question: from the docs and looking at the autogenerated ant scripts, intellij by default creates two subdirectories for each module: testing and production... I understand this distinction in a general way, but what exactly is the story here? am I able to define two different build profiles, one for testing, one for production? I dont see any config panel for all that

You cannot define a different build profile for production vs test code. You can only a different output directory. By default IDEA will split the content into two different directories, 'production' and 'test' of the directory configured in File >  Project Structure > [Project Settings] > Project > Project compiler output. You can customize this on a per module level in File > Project Structure > [Project Settings] > Modules > {Module Name} > 'Paths' tab > Compiler Output. If you are not seeing the compiled classes being split up, it mostly likely means the source paths are not correctly identified. Go to File > Project Structure > [Project Settings] > Modules > {Module Name} > 'sources' tab and make sure your test source directory is marked as Test Source (green) and not Sources.

2

Please sign in to leave a comment.