You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Christofer Dutz <ch...@c-ware.de> on 2016/04/12 15:16:01 UTC

Classloading issues in maven plugin with custom lifecycle mapping

Hi,


I am currently working on converting Apache Flex from Ant to Maven. I have managed to convert all of the Ant stuff in our newest SDK. I even built a new maven plugin for doing the Flex compilation. All parts seem to be working great.


The build consists of:

- A compiler

- Some Framework libs that are build using the compiler


The maven plugin is not part of the build. The maven plugin has a plugin-dependency to the compiler artifact. It is used in the framework modules to build the flex artifacts.


Now if I just build the compiler or I just build the framework, all works fine. But if I build compiler and framework in the same build, the flex maven plugin complains about not being able to find the classes of the compiler. The dump of the classpath lists the compiler.jar, but it doesn't seem to be able to load any classes from it. If I take the context classloader inside the plugin and create a new instance with the exact same URLs, I am able to manually load the class.


I assume that this is due to the fact that the compiler jar is replaced during the build after getting a handle to the jar file and before using it. But that is just a well educated guess. Is there anything I could do to make this build work?


I am also having builds randomly fail because artifacts that are used b plugins are replaced during the build, but I couldn't quite pin the problem down to a cause.


Probably when I asked this question on the user list, this was too specific for that list, as I didn't get a single response. Hopefully on this list it will be different :-)


I would really appreciate a little Help here ... It's definitely worth at least a beer in Vancouver ;-)


Chris

AW: Classloading issues in maven plugin with custom lifecycle mapping

Posted by Christofer Dutz <ch...@c-ware.de>.
Sure I do ... It's an Apache Project ... you could reproduce by doing the following:

1. Checkout apache flex falcon from https://git-wip-us.apache.org/repos/asf/flex-falcon.git
2. switch to the "feature/maven-migration" branch
3. run the "migrate-to-maven.sh" script which moves stuff around

Now it should be a valid Maven project.

As I use a maven extension in the ".mvn" directory, you have to have at least Maven 3.3.1.

I identified some modules that need to be built prior to running the build, after the first release I will separate them from the project as they should not change very often. They are built via the "minimal" profile:

mvn install -P minimal

The problem occurs if you build both of the main parts in one build:

mvn clean install -P compiler,externs -DskipTests

(You should skip the tests, as the build does have dependencies on the Flashplayer and skiping the tests, doesn't have an effect on the success/failure of the build)

You should get a CNFE when building the externs, but if you just build the externs (by only activating the externs profile), all is good.

Chris

________________________________________
Von: Robert Scholte <rf...@apache.org>
Gesendet: Dienstag, 12. April 2016 20:09
An: Maven Developers List
Betreff: Re: Classloading issues in maven plugin with custom lifecycle mapping

Hi,

do you have an example project (e.g. at github) to reproduce it?
Not sure if this is the issue, but maven-plugins cannot be part and used
by a multimodule project. Before a project can be built, all plugins must
be resolved. This shouldn't be an issue, since a maven-plugin should have
a different lifecycle compared to a multimodule-project using it.

thanks,
Robert

On Tue, 12 Apr 2016 15:16:01 +0200, Christofer Dutz
<ch...@c-ware.de> wrote:

> Hi,
>
>
> I am currently working on converting Apache Flex from Ant to Maven. I
> have managed to convert all of the Ant stuff in our newest SDK. I even
> built a new maven plugin for doing the Flex compilation. All parts seem
> to be working great.
>
>
> The build consists of:
>
> - A compiler
>
> - Some Framework libs that are build using the compiler
>
>
> The maven plugin is not part of the build. The maven plugin has a
> plugin-dependency to the compiler artifact. It is used in the framework
> modules to build the flex artifacts.
>
>
> Now if I just build the compiler or I just build the framework, all
> works fine. But if I build compiler and framework in the same build, the
> flex maven plugin complains about not being able to find the classes of
> the compiler. The dump of the classpath lists the compiler.jar, but it
> doesn't seem to be able to load any classes from it. If I take the
> context classloader inside the plugin and create a new instance with the
> exact same URLs, I am able to manually load the class.
>
>
> I assume that this is due to the fact that the compiler jar is replaced
> during the build after getting a handle to the jar file and before using
> it. But that is just a well educated guess. Is there anything I could do
> to make this build work?
>
>
> I am also having builds randomly fail because artifacts that are used b
> plugins are replaced during the build, but I couldn't quite pin the
> problem down to a cause.
>
>
> Probably when I asked this question on the user list, this was too
> specific for that list, as I didn't get a single response. Hopefully on
> this list it will be different :-)
>
>
> I would really appreciate a little Help here ... It's definitely worth
> at least a beer in Vancouver ;-)
>
>
> Chris

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

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


Re: Classloading issues in maven plugin with custom lifecycle mapping

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

do you have an example project (e.g. at github) to reproduce it?
Not sure if this is the issue, but maven-plugins cannot be part and used  
by a multimodule project. Before a project can be built, all plugins must  
be resolved. This shouldn't be an issue, since a maven-plugin should have  
a different lifecycle compared to a multimodule-project using it.

thanks,
Robert

On Tue, 12 Apr 2016 15:16:01 +0200, Christofer Dutz  
<ch...@c-ware.de> wrote:

> Hi,
>
>
> I am currently working on converting Apache Flex from Ant to Maven. I  
> have managed to convert all of the Ant stuff in our newest SDK. I even  
> built a new maven plugin for doing the Flex compilation. All parts seem  
> to be working great.
>
>
> The build consists of:
>
> - A compiler
>
> - Some Framework libs that are build using the compiler
>
>
> The maven plugin is not part of the build. The maven plugin has a  
> plugin-dependency to the compiler artifact. It is used in the framework  
> modules to build the flex artifacts.
>
>
> Now if I just build the compiler or I just build the framework, all  
> works fine. But if I build compiler and framework in the same build, the  
> flex maven plugin complains about not being able to find the classes of  
> the compiler. The dump of the classpath lists the compiler.jar, but it  
> doesn't seem to be able to load any classes from it. If I take the  
> context classloader inside the plugin and create a new instance with the  
> exact same URLs, I am able to manually load the class.
>
>
> I assume that this is due to the fact that the compiler jar is replaced  
> during the build after getting a handle to the jar file and before using  
> it. But that is just a well educated guess. Is there anything I could do  
> to make this build work?
>
>
> I am also having builds randomly fail because artifacts that are used b  
> plugins are replaced during the build, but I couldn't quite pin the  
> problem down to a cause.
>
>
> Probably when I asked this question on the user list, this was too  
> specific for that list, as I didn't get a single response. Hopefully on  
> this list it will be different :-)
>
>
> I would really appreciate a little Help here ... It's definitely worth  
> at least a beer in Vancouver ;-)
>
>
> Chris

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