You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Chris Barlock <ba...@us.ibm.com> on 2015/12/12 01:19:11 UTC

maven-compiler-plugin cannot find class files in WEB-INF/classes

I used the maven-bundle-plugin to create a Web Application Bundle in which 
the class files are in WEB-INF/classes and the MANIFEST.MF confirms this:

Bundle-ClassPath: WEB-INF/classes

If I try to use this WAB (packaged as a JAR) as a dependency for the 
maven-compiler-plugin, it can't find any of the class files in the JAR. If 
I change the JAR such that the class files are in the root of the JAR 
rather than in WEB-INF classes, then maven-compiler-plugin is happy.  Is 
it possible to use WABs with the maven-compiler-plugin?

Chris


Re: maven-compiler-plugin cannot find class files in WEB-INF/classes

Posted by Robert Scholte <rf...@apache.org>.
They must use a different compiler. Verify their pom (or other buildtool  
file) to see how they do it.
e.g. googling for OSGi compiler plugin gave me enough hits.

Robert

Op Mon, 14 Dec 2015 01:07:23 +0100 schreef Chris Barlock  
<ba...@us.ibm.com>:

> Thanks Robert.  I opened some of the Apache jars that have been
> OSGi-enabled and they just put the classes and/or JARs in the root of the
> JAR and specify the appropriate packages on Import-Packages and
> Export-Package in the MANIFEST.  Your best practice is a little more
> "pure" in terms of generating a "proper" OSGi bundle -- at the expense of
> more more project to build the JAR for the bundle.
>
> Chris
>
> IBM Middleware
> Research Triangle Park, NC
> (919) 224-2240
> Internet:  barlock@us.ibm.com
>
>
>
> From:   "Robert Scholte" <rf...@apache.org>
> To:     "Maven Users List" <us...@maven.apache.org>
> Date:   12/12/2015 07:07 AM
> Subject:        Re: maven-compiler-plugin cannot find class files in
> WEB-INF/classes
>
>
>
> Hi Chris,
>
> this isn't really a maven-compiler-plugin issue. This is how the java
> compiler (JAVA_HOME/bin/javac) works, or to be more precise: how the
> classpath works.
> It expects that the packages are in the root of the archive, not in a
> subdirectory like WEB-INF/classes.
>
> Best practice in this case: have a separate Maven module for the classes
> and include it as jar dependency to your war or generate an extra jar  
> with
> your war containing the classes [1]. You'll get an extra
> webapp-1.0-SNAPSHOT-classes.jar. If you want to use this, add
> <classifier>classes</classifier> to your dependency.
>
> thanks,
> Robert
>
> [1]
> http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#archiveClasses
>
>
>
> Op Sat, 12 Dec 2015 01:19:11 +0100 schreef Chris Barlock
> <ba...@us.ibm.com>:
>
>> I used the maven-bundle-plugin to create a Web Application Bundle in
>> which
>> the class files are in WEB-INF/classes and the MANIFEST.MF confirms
> this:
>>
>> Bundle-ClassPath: WEB-INF/classes
>>
>> If I try to use this WAB (packaged as a JAR) as a dependency for the
>> maven-compiler-plugin, it can't find any of the class files in the JAR.
>> If
>> I change the JAR such that the class files are in the root of the JAR
>> rather than in WEB-INF classes, then maven-compiler-plugin is happy.  Is
>> it possible to use WABs with the maven-compiler-plugin?
>>
>> Chris
>
> ---------------------------------------------------------------------
> 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: maven-compiler-plugin cannot find class files in WEB-INF/classes

Posted by Chris Barlock <ba...@us.ibm.com>.
Thanks Robert.  I opened some of the Apache jars that have been 
OSGi-enabled and they just put the classes and/or JARs in the root of the 
JAR and specify the appropriate packages on Import-Packages and 
Export-Package in the MANIFEST.  Your best practice is a little more 
"pure" in terms of generating a "proper" OSGi bundle -- at the expense of 
more more project to build the JAR for the bundle.

Chris

IBM Middleware
Research Triangle Park, NC
(919) 224-2240
Internet:  barlock@us.ibm.com



From:   "Robert Scholte" <rf...@apache.org>
To:     "Maven Users List" <us...@maven.apache.org>
Date:   12/12/2015 07:07 AM
Subject:        Re: maven-compiler-plugin cannot find class files in 
WEB-INF/classes



Hi Chris,

this isn't really a maven-compiler-plugin issue. This is how the java 
compiler (JAVA_HOME/bin/javac) works, or to be more precise: how the 
classpath works.
It expects that the packages are in the root of the archive, not in a 
subdirectory like WEB-INF/classes.

Best practice in this case: have a separate Maven module for the classes 
and include it as jar dependency to your war or generate an extra jar with 
 
your war containing the classes [1]. You'll get an extra 
webapp-1.0-SNAPSHOT-classes.jar. If you want to use this, add 
<classifier>classes</classifier> to your dependency.

thanks,
Robert

[1] 
http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#archiveClasses



Op Sat, 12 Dec 2015 01:19:11 +0100 schreef Chris Barlock 
<ba...@us.ibm.com>:

> I used the maven-bundle-plugin to create a Web Application Bundle in 
> which
> the class files are in WEB-INF/classes and the MANIFEST.MF confirms 
this:
>
> Bundle-ClassPath: WEB-INF/classes
>
> If I try to use this WAB (packaged as a JAR) as a dependency for the
> maven-compiler-plugin, it can't find any of the class files in the JAR. 
> If
> I change the JAR such that the class files are in the root of the JAR
> rather than in WEB-INF classes, then maven-compiler-plugin is happy.  Is
> it possible to use WABs with the maven-compiler-plugin?
>
> Chris

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





Re: maven-compiler-plugin cannot find class files in WEB-INF/classes

Posted by Robert Scholte <rf...@apache.org>.
Hi Chris,

this isn't really a maven-compiler-plugin issue. This is how the java  
compiler (JAVA_HOME/bin/javac) works, or to be more precise: how the  
classpath works.
It expects that the packages are in the root of the archive, not in a  
subdirectory like WEB-INF/classes.

Best practice in this case: have a separate Maven module for the classes  
and include it as jar dependency to your war or generate an extra jar with  
your war containing the classes [1]. You'll get an extra  
webapp-1.0-SNAPSHOT-classes.jar. If you want to use this, add  
<classifier>classes</classifier> to your dependency.

thanks,
Robert

[1]  
http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#archiveClasses


Op Sat, 12 Dec 2015 01:19:11 +0100 schreef Chris Barlock  
<ba...@us.ibm.com>:

> I used the maven-bundle-plugin to create a Web Application Bundle in  
> which
> the class files are in WEB-INF/classes and the MANIFEST.MF confirms this:
>
> Bundle-ClassPath: WEB-INF/classes
>
> If I try to use this WAB (packaged as a JAR) as a dependency for the
> maven-compiler-plugin, it can't find any of the class files in the JAR.  
> If
> I change the JAR such that the class files are in the root of the JAR
> rather than in WEB-INF classes, then maven-compiler-plugin is happy.  Is
> it possible to use WABs with the maven-compiler-plugin?
>
> Chris

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