0

In the Maven super-pom.xml definition (4.0.0)
in the build section are defined some configuration parameters,
such as:

<build> 
    <directory>${project.basedir}/target</directory>
    <outputDirectory>${project.build.directory}/classes</outputDirectory> <directory>${project.basedir}/target</directory>
    <outputDirectory>${project.build.directory}/classes</outputDirectory>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
    <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
...
<build>

Now let's take for example :<outputDirectory>${project.build.directory}/classes</outputDirectory>

resources:resources plugin goal uses it, as described in the documentation:

Name Type Since Description outputDirectory File - The output
directory into which to copy the resources. Default value is: ${project.build.outputDirectory}.

compiler:compile plugin goal uses it as well (I guess),
but it is nowhere defined in the documentation of that plugin. Why is that ? is it a lack in the specification or what ?
am I missing something ?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
GionJh
  • 2,742
  • 2
  • 29
  • 68
  • I don't get it, Could you post an answer elaborating your point please, it would be very helpful thanks. – GionJh Apr 13 '16 at 21:03
  • I mean you could answer elaborating your previous comment, for example what does "There can be generated sources at build-time" mean ? surely I'm missing something... – GionJh Apr 13 '16 at 21:06
  • Also "maven-compiler-plugin will compile all Java sources in the buildpath.", what do you mean by the buildpath ? – GionJh Apr 13 '16 at 21:07

1 Answers1

0

The goal of the maven-compiler-plugin is to compile all Java files present under source directories, i.e. on the buildpath. It is true that, by default, src/main/java is a source directory. However, there can be many other sources directories.

  • You can add a source directory on-the-fly during the Maven build itself with the build-helper-maven-plugin:add-source goal.
  • A Maven plugin can generate itself Java source code. The FAQ of the compiler plugin even mentions that case . And there are a lot of plugins that generate Java source code, based on a XSD, a WSDL, a database schema, a custom model... Maven itself uses Modello, which is a tool generating Java code from a model.

All those options revolve around the same idea: adding Java sources into the buildpath. And all those sources will need to be compiled by the compiler plugin.

So really, the only concern of the maven-compiler-plugin is: compile what is under the buildpath. My guess is that this is why the documentation of the plugin is the way it is. The compile goal has for unique documentation:

Compiles application sources

And it kind of makes sense: there isn't much to specify since those sources can have a variety of origins, so the documentation stays generic. It only specifies what it needs to: compile what is under the buildpath.


I'll add that this isn't specific to the compiler plugin. As you said in your question, this also concerns the maven-resources-plugin. Everything that has been said before in this answer also applies in the case of the resources plugin:

  • You can add a resource directory during the build with the build-helper-maven-plugin:add-resource goal.
  • A Maven plugin could also generate resources during the build (for example a WSDL generated by Java annotated classes).

And you'll note that the documentation of the resources goal is:

Copy resources for the main source code to the main output directory.

It doesn't specify that src/main/resources is a default resource directory, surely for the same reason as the compiler plugin didn't.

However, as you said in your question, it does document clearly where those resources are placed. But this is because whatever the origin of those resources (src/main/resources, generated...), all of them will always be placed under this output directory.

Community
  • 1
  • 1
Tunaki
  • 132,869
  • 46
  • 340
  • 423