You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jan-Kees van Andel <ja...@apache.org> on 2010/01/20 15:00:58 UTC

Add dependency to maven-compiler-plugin classpath

Hey,

In my project I have a dependency that I only want to have on my
compiler-plugin classpath, but not on my normal project classpath.

This is my code:
<build>
 ...
 <plugins>
   ...
   <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-compiler-plugin</artifactId>
     <configuration>
       <verbose>true</verbose>
       <compilerArguments>
         <s>${basedir}/target/generated-sources</s>
       </compilerArguments>
     </configuration>
     <dependencies>
       <dependency>
         <groupId>my.dependency.groupId</groupId>
         <artifactId>artifactId</artifactId>
         <version>${parent.version}</version>
         <scope>compile</scope>
       </dependency>
     </dependencies>
   </plugin>
   ...
 </plugins>
 ...
</build>

When I run Maven with -X, I see the following output by the compiler plugin:
[INFO] [compiler:compile]
[DEBUG] Using compiler 'javac'.
[DEBUG] Source directories:
[C:\java\work\idea-9\...\buildergenerator\test\src\main\java]
[DEBUG] Classpath: [C:\java\work\idea-9\...\buildergenerator\test\target\classes
 C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-annotations\0.1-SNAPSHOT\buildergenerator-annotations-0.1-SNAPSHOT.jar
 C:\java\maven-repo\joda-time\joda-time\1.6\joda-time-1.6.jar]

When I add the same dependency as a project dependency, I see the
following output:
[INFO] [compiler:compile]
[DEBUG] Using compiler 'javac'.
[DEBUG] Source directories:
[C:\java\work\idea-9\...\buildergenerator\test\src\main\java]
[DEBUG] Classpath: [C:\java\work\idea-9\...\buildergenerator\test\target\classes
 C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-annotations\0.1-SNAPSHOT\buildergenerator-annotations-0.1-SNAPSHOT.jar
 C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-core\0.1-SNAPSHOT\buildergenerator-core-0.1-SNAPSHOT.jar
 C:\java\maven-repo\org\freemarker\freemarker\2.3.15\freemarker-2.3.15.jar
 C:\java\maven-repo\joda-time\joda-time\1.6\joda-time-1.6.jar]

As you can see, I have one more dependency on my compiler classpath
(buildergenerator-core-0.1-SNAPSHOT.jar).

For some reason, the plugin dependency is not added to the compiler classpath.

Is there a way to fix this? I've also tried to add a <classpath>
element to <compilerArguments>, but this had the effect of removing
all other dependencies from the classpath, which is of course also not
desirable.

Thanks ans regards,
Jan-Kees

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Add dependency to maven-compiler-plugin classpath

Posted by Jan-Kees van Andel <ja...@apache.org>.
Allright, I should have provided a bit more context. Here it is:

I've written an APT annotation processor which generates builder
classes for immutable objects. Objects annotated with @Immutable are
processed by this annotation processor and code is generated
appropriately.

It used to contain only one module, containing both the annotations,
the processor class and a META-INF file to configure the processor...

The annoying thing of this was that the compiler auto-detects any
processors on the classpath and invokes them automatically. This is
something I don't want, so I decided to split it up into two parts:
- First a project with the annotations (the project that uses the
builder, needs to have the annotations on its classpath, since they
are in the source code).
- The other project contains the processor and its configuration. This
is not a compile dependency and I don't want it in my distribution.
It's a tool and I only want it on the classpath when compiling.

The reason not to use a project dependency with scope=provided is
because of my IDE's. On my project, we use both IntelliJ and RSA and I
don't want the processor project on the classpath, since it modifies
the build/make process in the IDE. This causes issues with build/make,
because the processor gets invoked by it, leading to "duplicate class"
kind of compiler errors, because it's trying to generate a class
that's already generated by the maven-compiler-plugin.

So, long story short (and also after cleaning up my own mind), it
looks like I need a provided dependency, but I don't want it to be
included in my eclipse/idea classpath. I hoped to achieve this by
using a plugin dependency, but maybe I can just as easy exclude it
from those plugins (eclipse:idea)...

Regards,
Jan-Kees


2010/1/20 Stephen Connolly <st...@gmail.com>:
> scope=provided
>
> 2010/1/20 Jan-Kees van Andel <ja...@apache.org>:
>> Hey,
>>
>> In my project I have a dependency that I only want to have on my
>> compiler-plugin classpath, but not on my normal project classpath.
>>
>> This is my code:
>> <build>
>>  ...
>>  <plugins>
>>   ...
>>   <plugin>
>>     <groupId>org.apache.maven.plugins</groupId>
>>     <artifactId>maven-compiler-plugin</artifactId>
>>     <configuration>
>>       <verbose>true</verbose>
>>       <compilerArguments>
>>         <s>${basedir}/target/generated-sources</s>
>>       </compilerArguments>
>>     </configuration>
>>     <dependencies>
>>       <dependency>
>>         <groupId>my.dependency.groupId</groupId>
>>         <artifactId>artifactId</artifactId>
>>         <version>${parent.version}</version>
>>         <scope>compile</scope>
>>       </dependency>
>>     </dependencies>
>>   </plugin>
>>   ...
>>  </plugins>
>>  ...
>> </build>
>>
>> When I run Maven with -X, I see the following output by the compiler plugin:
>> [INFO] [compiler:compile]
>> [DEBUG] Using compiler 'javac'.
>> [DEBUG] Source directories:
>> [C:\java\work\idea-9\...\buildergenerator\test\src\main\java]
>> [DEBUG] Classpath: [C:\java\work\idea-9\...\buildergenerator\test\target\classes
>>  C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-annotations\0.1-SNAPSHOT\buildergenerator-annotations-0.1-SNAPSHOT.jar
>>  C:\java\maven-repo\joda-time\joda-time\1.6\joda-time-1.6.jar]
>>
>> When I add the same dependency as a project dependency, I see the
>> following output:
>> [INFO] [compiler:compile]
>> [DEBUG] Using compiler 'javac'.
>> [DEBUG] Source directories:
>> [C:\java\work\idea-9\...\buildergenerator\test\src\main\java]
>> [DEBUG] Classpath: [C:\java\work\idea-9\...\buildergenerator\test\target\classes
>>  C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-annotations\0.1-SNAPSHOT\buildergenerator-annotations-0.1-SNAPSHOT.jar
>>  C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-core\0.1-SNAPSHOT\buildergenerator-core-0.1-SNAPSHOT.jar
>>  C:\java\maven-repo\org\freemarker\freemarker\2.3.15\freemarker-2.3.15.jar
>>  C:\java\maven-repo\joda-time\joda-time\1.6\joda-time-1.6.jar]
>>
>> As you can see, I have one more dependency on my compiler classpath
>> (buildergenerator-core-0.1-SNAPSHOT.jar).
>>
>> For some reason, the plugin dependency is not added to the compiler classpath.
>>
>> Is there a way to fix this? I've also tried to add a <classpath>
>> element to <compilerArguments>, but this had the effect of removing
>> all other dependencies from the classpath, which is of course also not
>> desirable.
>>
>> Thanks ans regards,
>> Jan-Kees
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Add dependency to maven-compiler-plugin classpath

Posted by Stephen Connolly <st...@gmail.com>.
scope=provided

2010/1/20 Jan-Kees van Andel <ja...@apache.org>:
> Hey,
>
> In my project I have a dependency that I only want to have on my
> compiler-plugin classpath, but not on my normal project classpath.
>
> This is my code:
> <build>
>  ...
>  <plugins>
>   ...
>   <plugin>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-compiler-plugin</artifactId>
>     <configuration>
>       <verbose>true</verbose>
>       <compilerArguments>
>         <s>${basedir}/target/generated-sources</s>
>       </compilerArguments>
>     </configuration>
>     <dependencies>
>       <dependency>
>         <groupId>my.dependency.groupId</groupId>
>         <artifactId>artifactId</artifactId>
>         <version>${parent.version}</version>
>         <scope>compile</scope>
>       </dependency>
>     </dependencies>
>   </plugin>
>   ...
>  </plugins>
>  ...
> </build>
>
> When I run Maven with -X, I see the following output by the compiler plugin:
> [INFO] [compiler:compile]
> [DEBUG] Using compiler 'javac'.
> [DEBUG] Source directories:
> [C:\java\work\idea-9\...\buildergenerator\test\src\main\java]
> [DEBUG] Classpath: [C:\java\work\idea-9\...\buildergenerator\test\target\classes
>  C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-annotations\0.1-SNAPSHOT\buildergenerator-annotations-0.1-SNAPSHOT.jar
>  C:\java\maven-repo\joda-time\joda-time\1.6\joda-time-1.6.jar]
>
> When I add the same dependency as a project dependency, I see the
> following output:
> [INFO] [compiler:compile]
> [DEBUG] Using compiler 'javac'.
> [DEBUG] Source directories:
> [C:\java\work\idea-9\...\buildergenerator\test\src\main\java]
> [DEBUG] Classpath: [C:\java\work\idea-9\...\buildergenerator\test\target\classes
>  C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-annotations\0.1-SNAPSHOT\buildergenerator-annotations-0.1-SNAPSHOT.jar
>  C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-core\0.1-SNAPSHOT\buildergenerator-core-0.1-SNAPSHOT.jar
>  C:\java\maven-repo\org\freemarker\freemarker\2.3.15\freemarker-2.3.15.jar
>  C:\java\maven-repo\joda-time\joda-time\1.6\joda-time-1.6.jar]
>
> As you can see, I have one more dependency on my compiler classpath
> (buildergenerator-core-0.1-SNAPSHOT.jar).
>
> For some reason, the plugin dependency is not added to the compiler classpath.
>
> Is there a way to fix this? I've also tried to add a <classpath>
> element to <compilerArguments>, but this had the effect of removing
> all other dependencies from the classpath, which is of course also not
> desirable.
>
> Thanks ans regards,
> Jan-Kees
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Add dependency to maven-compiler-plugin classpath

Posted by Anders Hammar <an...@hammar.net>.
I don't understand what you're trying to do. You're saying you have a
compile time dependency you don't want to add as a normal dependency? It
doesn't make sense to me. Is it a dependency of your code or something
different?

/Anders

On Wed, Jan 20, 2010 at 15:00, Jan-Kees van Andel <
jankeesvanandel@apache.org> wrote:

> Hey,
>
> In my project I have a dependency that I only want to have on my
> compiler-plugin classpath, but not on my normal project classpath.
>
> This is my code:
> <build>
>  ...
>  <plugins>
>   ...
>   <plugin>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-compiler-plugin</artifactId>
>     <configuration>
>       <verbose>true</verbose>
>       <compilerArguments>
>         <s>${basedir}/target/generated-sources</s>
>       </compilerArguments>
>     </configuration>
>     <dependencies>
>       <dependency>
>         <groupId>my.dependency.groupId</groupId>
>         <artifactId>artifactId</artifactId>
>         <version>${parent.version}</version>
>         <scope>compile</scope>
>       </dependency>
>     </dependencies>
>   </plugin>
>   ...
>  </plugins>
>  ...
> </build>
>
> When I run Maven with -X, I see the following output by the compiler
> plugin:
> [INFO] [compiler:compile]
> [DEBUG] Using compiler 'javac'.
> [DEBUG] Source directories:
> [C:\java\work\idea-9\...\buildergenerator\test\src\main\java]
> [DEBUG] Classpath:
> [C:\java\work\idea-9\...\buildergenerator\test\target\classes
>
>  C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-annotations\0.1-SNAPSHOT\buildergenerator-annotations-0.1-SNAPSHOT.jar
>  C:\java\maven-repo\joda-time\joda-time\1.6\joda-time-1.6.jar]
>
> When I add the same dependency as a project dependency, I see the
> following output:
> [INFO] [compiler:compile]
> [DEBUG] Using compiler 'javac'.
> [DEBUG] Source directories:
> [C:\java\work\idea-9\...\buildergenerator\test\src\main\java]
> [DEBUG] Classpath:
> [C:\java\work\idea-9\...\buildergenerator\test\target\classes
>
>  C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-annotations\0.1-SNAPSHOT\buildergenerator-annotations-0.1-SNAPSHOT.jar
>
>  C:\java\maven-repo\nl\...\buildergenerator\buildergenerator-core\0.1-SNAPSHOT\buildergenerator-core-0.1-SNAPSHOT.jar
>  C:\java\maven-repo\org\freemarker\freemarker\2.3.15\freemarker-2.3.15.jar
>  C:\java\maven-repo\joda-time\joda-time\1.6\joda-time-1.6.jar]
>
> As you can see, I have one more dependency on my compiler classpath
> (buildergenerator-core-0.1-SNAPSHOT.jar).
>
> For some reason, the plugin dependency is not added to the compiler
> classpath.
>
> Is there a way to fix this? I've also tried to add a <classpath>
> element to <compilerArguments>, but this had the effect of removing
> all other dependencies from the classpath, which is of course also not
> desirable.
>
> Thanks ans regards,
> Jan-Kees
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>