maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergei Ivanov (JIRA)" <j...@codehaus.org>
Subject [jira] (MNG-5718) Change 'provides' from Object to Properties in toolchains.xml
Date Tue, 10 Feb 2015 12:26:18 GMT

    [ https://jira.codehaus.org/browse/MNG-5718?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=362968#comment-362968
] 

Sergei Ivanov commented on MNG-5718:
------------------------------------

Hi Robert,

One of our developers updated to Maven 3.2.5 and he is no longer able to build one of our
projects that uses my GitHub fork of protobuf plugin for maven. The toolchains plugin fails
to instantiate the custom protobuf toolchain, because the factory obviously expects a different
return type for the {{getProvides()}} method. Since the toolchain API is part of Maven core,
the plugin has no control over its actual version and has to use whatever is provided by Maven.

Here's the log file fragment:

{noformat}
[INFO] --- maven-toolchains-plugin:1.1:toolchain (default) @ xxx-common-parent-pom ---
[INFO] Required toolchain: jdk [ version='1.7' ]
[INFO] Found matching toolchain for type jdk: JDK[C:\Users\sivanov\Applications\java\jdk1.7.0_60_x64]
[INFO] Required toolchain: protobuf [ version='[2.5,2.6)' ]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.330 s
[INFO] Finished at: 2015-02-10T11:59:58+00:00
[INFO] Final Memory: 19M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain
(default) on project xxx-common-parent-pom: Incompatible toolchain API: InvocationTargetException:
org.apache.maven.toolchain.model.ToolchainModel.getProvides()Ljava/lang/Object; -> [Help
1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain
(default) on project xxx-common-parent-pom: Incompatible toolchain API
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Incompatible toolchain API
	at org.apache.maven.plugin.toolchain.ToolchainMojo.getToolchains(ToolchainMojo.java:225)
	at org.apache.maven.plugin.toolchain.ToolchainMojo.selectToolchain(ToolchainMojo.java:147)
	at org.apache.maven.plugin.toolchain.ToolchainMojo.execute(ToolchainMojo.java:90)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	... 19 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.apache.maven.plugin.toolchain.ToolchainMojo.getToolchains(ToolchainMojo.java:194)
	... 23 more
Caused by: java.lang.NoSuchMethodError: org.apache.maven.toolchain.model.ToolchainModel.getProvides()Ljava/lang/Object;
	at com.google.protobuf.maven.toolchain.DefaultProtobufToolchainFactory.createToolchain(DefaultProtobufToolchainFactory.java:52)
	at org.apache.maven.toolchain.DefaultToolchainManagerPrivate.getToolchainsForType(DefaultToolchainManagerPrivate.java:66)
	... 28 more
{noformat}

This was hardly a backwardly compatible change to introduce in a patch release. In fact, not
backwardly compatible at all from the toolchain implementor's point of view. I understand
that the API needs to change from time to time, and I realise that it's impossible to make
this change in the MDO model without breaking compatibility, but I would expect at least a
prominent compatibility warning in the release notes for Maven release. Sorry for sounding
aggressive, but it has caused me a lot of frustration this morning.

On the bright side, after looking at the related commits and related issues, I've found that
Hervé had updated the reference implementation in toolchain ITs to work around this issue.
Let me post a link here for posterity:
http://svn.apache.org/viewvc/maven/plugins/tags/maven-toolchains-plugin-1.1/src/it/custom-toolchain-plugin/src/main/java/org/apache/maven/plugins/toolchains/its/custom/CustomToolchainFactory.java?view=markup
The important bit is {{getProvidesProperties()}} method that uses reflection underneath to
work around API incompatibilities.

> Change 'provides' from Object to Properties in toolchains.xml
> -------------------------------------------------------------
>
>                 Key: MNG-5718
>                 URL: https://jira.codehaus.org/browse/MNG-5718
>             Project: Maven
>          Issue Type: Improvement
>          Components: Toolchains
>            Reporter: Robert Scholte
>            Assignee: Robert Scholte
>             Fix For: 3.2.5
>
>
> Officially the content of the {{<provides>}} element in a toolchain was free of
structure, although we only know Properties-like structures. To be able to support the merging
of toolchains ( MNG-5714 ) it is better to drop the free structure and change it to Properties.
> The {{jdk}} toolchain will be modified accordingly, being transparent for users.
> But any custom toolchain implementation will need to be updated.



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)

Mime
View raw message