Discussion:
maven-compiler-plugin question
Mykel Alvis
2006-06-28 18:30:52 UTC
Permalink
Sorry if this is a repeat, but I haven't located an answer on the web
anywhere.
I found http://jira.codehaus.org/browse/MCOMPILER-26 but it appears closed.

In the pom of a module, I have included the following:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>
<include>src/generated/java/**/*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>

This particular module has no code to compile in src/main/java.
During a compile, I get :

[DEBUG] (f) compileSourceRoots =
[/home/malvis/code/test-checkout/orm/src/main/java]
[DEBUG] (f) compilerId = javac
[DEBUG] (f) debug = true
[DEBUG] (f) fork = false
[DEBUG] (f) includes = [src/generated/java/**/*.java]
[DEBUG] (f) optimize = false
[DEBUG] (f) outputDirectory =
/home/malvis/code/test-checkout/orm/target/classes
.
.
.
[DEBUG] Output directory: /home/malvis/code/test-checkout/orm/target/classes
[INFO] Nothing to compile - all classes are up to date
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2 seconds

Why would the compiler not recognize the need to compile the included
sources?
Is this a continuing compiler problem or am I configuring it wrong?

Thanks,
Mykel
--
Never wear anything that panics the cat. -- P. J. O'Rourke
Edwin Punzalan
2006-06-29 01:46:59 UTC
Permalink
I think you misconfigured it.

You've set the includes to search only in src/generate/java but it seems
like the generated sources are in src/main/java (from
/home/malvis/code/test-checkout/orm/src/main/java).

Hope that helps.


^_^
Post by Mykel Alvis
Sorry if this is a repeat, but I haven't located an answer on the web
anywhere.
I found http://jira.codehaus.org/browse/MCOMPILER-26 but it appears closed.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>
<include>src/generated/java/**/*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
This particular module has no code to compile in src/main/java.
[DEBUG] (f) compileSourceRoots =
[/home/malvis/code/test-checkout/orm/src/main/java]
[DEBUG] (f) compilerId = javac
[DEBUG] (f) debug = true
[DEBUG] (f) fork = false
[DEBUG] (f) includes = [src/generated/java/**/*.java]
[DEBUG] (f) optimize = false
[DEBUG] (f) outputDirectory =
/home/malvis/code/test-checkout/orm/target/classes
.
.
.
/home/malvis/code/test-checkout/orm/target/classes
[INFO] Nothing to compile - all classes are up to date
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2 seconds
Why would the compiler not recognize the need to compile the included
sources?
Is this a continuing compiler problem or am I configuring it wrong?
Thanks,
Mykel
Mykel Alvis
2006-06-29 03:29:16 UTC
Permalink
I may have misconfigured it, but the
/home/malvis/code/test-checkout/orm/src/main/java reference comes for free,
since /home/.../orm is the project's base directory.

The sources are ONLY in src/generated/java. There are no sources in
src/main/java. The generated sources are generated prior to starting the
lifecycle, and not produced as a part of the build process at all.

When I move the sources to src/main/java and remove the "<includes>", they
compile as expected.

If the sources are in src/main/java and I have the <includes> configured, it
finds no sources to compile.

I just can't seem to get it to look in src/generated/java for java files.

Now that I'm away from the office, I thought to try to base my <include> on
the module's project ${basedir} or whatever it is in m2, but that'll have to
wait until tomorrow.

If someone else has done such a thing with success, would you mind posting
the relevant pom sections?
Post by Edwin Punzalan
I think you misconfigured it.
You've set the includes to search only in src/generate/java but it seems
like the generated sources are in src/main/java (from
/home/malvis/code/test-checkout/orm/src/main/java).
Hope that helps.
^_^
Post by Mykel Alvis
Sorry if this is a repeat, but I haven't located an answer on the web
anywhere.
I found http://jira.codehaus.org/browse/MCOMPILER-26 but it appears closed.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>
<include>src/generated/java/**/*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
This particular module has no code to compile in src/main/java.
[DEBUG] (f) compileSourceRoots =
[/home/malvis/code/test-checkout/orm/src/main/java]
[DEBUG] (f) compilerId = javac
[DEBUG] (f) debug = true
[DEBUG] (f) fork = false
[DEBUG] (f) includes = [src/generated/java/**/*.java]
[DEBUG] (f) optimize = false
[DEBUG] (f) outputDirectory =
/home/malvis/code/test-checkout/orm/target/classes
.
.
.
/home/malvis/code/test-checkout/orm/target/classes
[INFO] Nothing to compile - all classes are up to date
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2 seconds
Why would the compiler not recognize the need to compile the included
sources?
Is this a continuing compiler problem or am I configuring it wrong?
Thanks,
Mykel
---------------------------------------------------------------------
--
Never wear anything that panics the cat. -- P. J. O'Rourke
Valeri Felberg
2006-06-29 07:41:22 UTC
Permalink
If there are no sources in src/main/java but only in src/generated/java why
don't you set the project source root to src/generated/java like this:
...
<build>
<sourceDirectory>${basedir}/src/generated/java</sourceDirectory>
...
</build>

Kind regards,
Valeri Felberg
Post by Mykel Alvis
I may have misconfigured it, but the
/home/malvis/code/test-checkout/orm/src/main/java reference comes for free,
since /home/.../orm is the project's base directory.
The sources are ONLY in src/generated/java. There are no sources in
src/main/java. The generated sources are generated prior to starting the
lifecycle, and not produced as a part of the build process at all.
When I move the sources to src/main/java and remove the "<includes>", they
compile as expected.
If the sources are in src/main/java and I have the <includes> configured, it
finds no sources to compile.
I just can't seem to get it to look in src/generated/java for java files.
Now that I'm away from the office, I thought to try to base my <include> on
the module's project ${basedir} or whatever it is in m2, but that'll have to
wait until tomorrow.
If someone else has done such a thing with success, would you mind posting
the relevant pom sections?
Post by Edwin Punzalan
I think you misconfigured it.
You've set the includes to search only in src/generate/java but it seems
like the generated sources are in src/main/java (from
/home/malvis/code/test-checkout/orm/src/main/java).
Hope that helps.
^_^
Post by Mykel Alvis
Sorry if this is a repeat, but I haven't located an answer on the web
anywhere.
I found http://jira.codehaus.org/browse/MCOMPILER-26 but it appears closed.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>
<include>src/generated/java/**/*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
This particular module has no code to compile in src/main/java.
[DEBUG] (f) compileSourceRoots =
[/home/malvis/code/test-checkout/orm/src/main/java]
[DEBUG] (f) compilerId = javac
[DEBUG] (f) debug = true
[DEBUG] (f) fork = false
[DEBUG] (f) includes = [src/generated/java/**/*.java]
[DEBUG] (f) optimize = false
[DEBUG] (f) outputDirectory =
/home/malvis/code/test-checkout/orm/target/classes
.
.
.
/home/malvis/code/test-checkout/orm/target/classes
[INFO] Nothing to compile - all classes are up to date
[INFO]
------------------------------------------------------------------------
Post by Edwin Punzalan
Post by Mykel Alvis
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
Post by Edwin Punzalan
Post by Mykel Alvis
[INFO] Total time: 2 seconds
Why would the compiler not recognize the need to compile the included
sources?
Is this a continuing compiler problem or am I configuring it wrong?
Thanks,
Mykel
---------------------------------------------------------------------
--
Never wear anything that panics the cat. -- P. J. O'Rourke
Mykel Alvis
2006-06-29 18:20:46 UTC
Permalink
Thanks! Like moving the "generated" sources to "src/main", that does
solve my immediate need, but there might be source in the "real"
source directory in the future and that those (pre)generated sources
will eventually get generated in the correct way, I hope.

The question still remains about how to get the <includes> to operate
in the manner that I want. Maybe there's some other way?

The following also does not work (I added ${basedir} on the chance
that the paths weren't relative):

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>

<include>${basedir}/src/generated/java/**/*.java</include>
</includes>
</configuration>
</plugin>
Post by Valeri Felberg
If there are no sources in src/main/java but only in src/generated/java why
...
<build>
<sourceDirectory>${basedir}/src/generated/java</sourceDirectory>
...
</build>
Kind regards,
Valeri Felberg
Post by Mykel Alvis
I may have misconfigured it, but the
/home/malvis/code/test-checkout/orm/src/main/java reference comes for free,
since /home/.../orm is the project's base directory.
The sources are ONLY in src/generated/java. There are no sources in
src/main/java. The generated sources are generated prior to starting the
lifecycle, and not produced as a part of the build process at all.
When I move the sources to src/main/java and remove the "<includes>", they
compile as expected.
If the sources are in src/main/java and I have the <includes> configured, it
finds no sources to compile.
I just can't seem to get it to look in src/generated/java for java files.
Now that I'm away from the office, I thought to try to base my <include> on
the module's project ${basedir} or whatever it is in m2, but that'll have to
wait until tomorrow.
If someone else has done such a thing with success, would you mind posting
the relevant pom sections?
Post by Edwin Punzalan
I think you misconfigured it.
You've set the includes to search only in src/generate/java but it seems
like the generated sources are in src/main/java (from
/home/malvis/code/test-checkout/orm/src/main/java).
Hope that helps.
^_^
Post by Mykel Alvis
Sorry if this is a repeat, but I haven't located an answer on the web
anywhere.
I found http://jira.codehaus.org/browse/MCOMPILER-26 but it appears closed.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>
<include>src/generated/java/**/*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
This particular module has no code to compile in src/main/java.
[DEBUG] (f) compileSourceRoots =
[/home/malvis/code/test-checkout/orm/src/main/java]
[DEBUG] (f) compilerId = javac
[DEBUG] (f) debug = true
[DEBUG] (f) fork = false
[DEBUG] (f) includes = [src/generated/java/**/*.java]
[DEBUG] (f) optimize = false
[DEBUG] (f) outputDirectory =
/home/malvis/code/test-checkout/orm/target/classes
.
.
.
/home/malvis/code/test-checkout/orm/target/classes
[INFO] Nothing to compile - all classes are up to date
[INFO]
------------------------------------------------------------------------
Post by Edwin Punzalan
Post by Mykel Alvis
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
Post by Edwin Punzalan
Post by Mykel Alvis
[INFO] Total time: 2 seconds
Why would the compiler not recognize the need to compile the included
sources?
Is this a continuing compiler problem or am I configuring it wrong?
Thanks,
Mykel
---------------------------------------------------------------------
--
Never wear anything that panics the cat. -- P. J. O'Rourke
--
Never wear anything that panics the cat. -- P. J. O'Rourke
Edwin Punzalan
2006-06-30 01:43:55 UTC
Permalink
The includes parameter works only on files inside the
compileSourceRoots. So if you have compileSourceRoots as
"src/main/java" and have include as "src/generated/java" then the
compiler searches for "src/main/java/src/generated/java".

Even if you put ${basedir} in the includes, it will still be appended to
what's in the compileSourceRoots.

Hope that helps.

^_^
Post by Mykel Alvis
Thanks! Like moving the "generated" sources to "src/main", that does
solve my immediate need, but there might be source in the "real"
source directory in the future and that those (pre)generated sources
will eventually get generated in the correct way, I hope.
The question still remains about how to get the <includes> to operate
in the manner that I want. Maybe there's some other way?
The following also does not work (I added ${basedir} on the chance
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>
<include>${basedir}/src/generated/java/**/*.java</include>
</includes>
</configuration>
</plugin>
Post by Valeri Felberg
If there are no sources in src/main/java but only in
src/generated/java why
...
<build>
<sourceDirectory>${basedir}/src/generated/java</sourceDirectory>
...
</build>
Kind regards,
Valeri Felberg
Post by Mykel Alvis
I may have misconfigured it, but the
/home/malvis/code/test-checkout/orm/src/main/java reference comes for free,
since /home/.../orm is the project's base directory.
The sources are ONLY in src/generated/java. There are no sources in
src/main/java. The generated sources are generated prior to
starting the
Post by Mykel Alvis
lifecycle, and not produced as a part of the build process at all.
When I move the sources to src/main/java and remove the
"<includes>", they
Post by Mykel Alvis
compile as expected.
If the sources are in src/main/java and I have the <includes>
configured,
Post by Mykel Alvis
it
finds no sources to compile.
I just can't seem to get it to look in src/generated/java for java
files.
Post by Mykel Alvis
Now that I'm away from the office, I thought to try to base my
<include>
Post by Mykel Alvis
on
the module's project ${basedir} or whatever it is in m2, but
that'll have
Post by Mykel Alvis
to
wait until tomorrow.
If someone else has done such a thing with success, would you mind
posting
Post by Mykel Alvis
the relevant pom sections?
Post by Edwin Punzalan
I think you misconfigured it.
You've set the includes to search only in src/generate/java but
it seems
Post by Mykel Alvis
Post by Edwin Punzalan
like the generated sources are in src/main/java (from
/home/malvis/code/test-checkout/orm/src/main/java).
Hope that helps.
^_^
Post by Mykel Alvis
Sorry if this is a repeat, but I haven't located an answer on
the web
Post by Mykel Alvis
Post by Edwin Punzalan
Post by Mykel Alvis
anywhere.
I found http://jira.codehaus.org/browse/MCOMPILER-26 but it
appears
Post by Mykel Alvis
Post by Edwin Punzalan
Post by Mykel Alvis
closed.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>
<include>src/generated/java/**/*.java</include>
Post by Mykel Alvis
Post by Edwin Punzalan
Post by Mykel Alvis
</includes>
</configuration>
</plugin>
</plugins>
</build>
This particular module has no code to compile in src/main/java.
[DEBUG] (f) compileSourceRoots =
[/home/malvis/code/test-checkout/orm/src/main/java]
[DEBUG] (f) compilerId = javac
[DEBUG] (f) debug = true
[DEBUG] (f) fork = false
[DEBUG] (f) includes = [src/generated/java/**/*.java]
[DEBUG] (f) optimize = false
[DEBUG] (f) outputDirectory =
/home/malvis/code/test-checkout/orm/target/classes
.
.
.
/home/malvis/code/test-checkout/orm/target/classes
[INFO] Nothing to compile - all classes are up to date
[INFO]
------------------------------------------------------------------------
Post by Mykel Alvis
Post by Edwin Punzalan
Post by Mykel Alvis
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
Post by Mykel Alvis
Post by Edwin Punzalan
Post by Mykel Alvis
[INFO] Total time: 2 seconds
Why would the compiler not recognize the need to compile the
included
Post by Mykel Alvis
Post by Edwin Punzalan
Post by Mykel Alvis
sources?
Is this a continuing compiler problem or am I configuring it
wrong?
Post by Mykel Alvis
Post by Edwin Punzalan
Post by Mykel Alvis
Thanks,
Mykel
---------------------------------------------------------------------
Post by Mykel Alvis
--
Never wear anything that panics the cat. -- P. J. O'Rourke
Loading...