You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Andreas Sewe <se...@st.informatik.tu-darmstadt.de> on 2011/02/03 12:19:34 UTC

Legitimate use of ToolchainManagerPrivate?

Hi all,

I am using Maven to build benchmarks for JVM research. I have already 
written a plugin that bundles up the benchmarks harness, dependencies, 
and input data. This works like a charm. :-)

To integration-test the benchmarks, I would like my plugin to run 
benchmark just build on a whole range of JVMs. To this end, Maven's 
toolchain support seems like a perfect fit. Alas, the 
maven-toolchain-plugin can configure only one toolchain of a given type 
and the ToolchainManager only gives me access to a single "jdk" type 
toolchain. What I want, instead, is to retrieve a list of all "jdk" type 
toolchains matching some requirements from my plugin's configuration.

This can be done by using ToolchainManagerPrivate (and duplicating some 
functionality of the maven-toolchain-plugin), but 
ToolchainManagerPrivate doesn't look like its intended to be used that 
way. Is there are better one?

Best wishes,

Andreas


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


Re: Legitimate use of ToolchainManagerPrivate?

Posted by Andreas Sewe <se...@st.informatik.tu-darmstadt.de>.
Hi all,

sorry it took so long to reply, but here are my findings:

> I remember when I was writing that plugin I found a couple of use cases
for
> tool chains that the initial spec had missed... there could be some hack
I'm
> doing... also are you using maven 2 or 3.

I am using Maven 3; while animal-sniffer:check works just fine,
animal-sniffer:build has problems. :-(

> I have not tested animal-sniffer-maven-plugin for generating signatures
with
> maven 3 so it might be that it only works in 2.0.10-2.2.1

Yes, it looks like that is the case: when asking explicitly for a toolchain
in the plugin's configuration, I get the following error:

[ERROR] Failed to execute goal
org.codehaus.mojo:animal-sniffer-maven-plugin:1.6:build (build) on project
test: Incompatible toolchain API:
org.apache.maven.toolchain.DefaultToolchainManager.getToolchainsForType(java.lang.String)
-> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute
goal org.codehaus.mojo:animal-sniffer-maven-plugin:1.6:build (build) on
project test: Incompatible toolchain API
	at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
	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:84)
	at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
	at
org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
	at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
	at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
	at
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
	at
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Incompatible
toolchain API
	at
org.codehaus.mojo.animal_sniffer.maven.BuildSignaturesMojo.getToolchains(BuildSignaturesMojo.java:686)
	at
org.codehaus.mojo.animal_sniffer.maven.BuildSignaturesMojo.getToolchainFromConfiguration(BuildSignaturesMojo.java:637)
	at
org.codehaus.mojo.animal_sniffer.maven.BuildSignaturesMojo.getToolchain(BuildSignaturesMojo.java:600)
	at
org.codehaus.mojo.animal_sniffer.maven.BuildSignaturesMojo.execute(BuildSignaturesMojo.java:286)
	at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
	at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
	... 19 more
Caused by: java.lang.NoSuchMethodException:
org.apache.maven.toolchain.DefaultToolchainManager.getToolchainsForType(java.lang.String)
	at java.lang.Class.getMethod(Class.java:1605)
	at
org.codehaus.mojo.animal_sniffer.maven.BuildSignaturesMojo.getToolchains(BuildSignaturesMojo.java:679)
	... 24 more

This is due to the fact that an instance of class
org.apache.maven.toolchain.DefaultToolchainManager is injected into the
ToolchainManager @component, which is not a ToolchainManagerPrivate. So it
looks like one has to explicitly request a ToolchainManagerPrivate
@component; just asking for a ToolchainManager does not get one a
ToolchainManagerPrivate.

That being said, I found the "jdk"-type toolchains lacking some information
for my purpose. You only get the jdkHome, but not, e.g., JVM arguments
(like -client or -server). This way is it quite hard to run you tests on
different JVM configurations, as all you get is just the paths to the
"java" executables. :-(

So I am switching back to a single toolchain (obtained via
ToolchainManager) for now.

Best wishes,

Andreas


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


Re: Legitimate use of ToolchainManagerPrivate?

Posted by Stephen Connolly <st...@gmail.com>.
I remember when I was writing that plugin I found a couple of use cases for
tool chains that the initial spec had missed... there could be some hack I'm
doing... also are you using maven 2 or 3.

I have not tested animal-sniffer-maven-plugin for generating signatures with
maven 3 so it might be that it only works in 2.0.10-2.2.1

- Stephen

---
Sent from my Android phone, so random spelling mistakes, random nonsense
words and other nonsense are a direct result of using swype to type on the
screen
On 4 Feb 2011 17:41, "Andreas Sewe" <se...@st.informatik.tu-darmstadt.de>
wrote:

Re: Legitimate use of ToolchainManagerPrivate?

Posted by Andreas Sewe <se...@st.informatik.tu-darmstadt.de>.
Hi all,

> OK, now I get it. Thanks. I'll have a look at the code and come back if 
> I still have some questions.

I did have a look a the animal-sniffer-maven-plugin. Very interesting.

One thing that I do not understand, however, is how to obtain access to an
implementation of ToolchainManagerPrivate (besides @component
ToolchainManagerPrivate). As far as I can see, the plugin only declares a
dependency on the ToolchainManager (w/o Private) component.

  /**
   * @component
   */
  private ToolchainManager toolchainManager;

Still, the plugin later on continues to call
toolchainManager.getClass().getMethod("getToolchainsForType", String.class,
MavenSession.class), a call which can only succeed (instead of throwing a
NoSuchMethodException) if the toolchainManager component actually
implements ToolchainManagerPrivate instead of only ToolchainManager.

If I do the above in my own code, however, toolchainManager is of class
DefaultToolchainManager instead of DefaultToolchainManagerPrivate. So why
does it work in the BuildSignaturesMojo? What am I missing?

Best wishes,

Andreas


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


Re: Legitimate use of ToolchainManagerPrivate?

Posted by Andreas Sewe <se...@st.informatik.tu-darmstadt.de>.
Hi Stephen, hi Jörg,

> yep the code. there's some advanced use of tool chains in animal sniffer...
> no other plugin that I know of is as advanced in using tool chains

OK, now I get it. Thanks. I'll have a look at the code and come back if 
I still have some questions.

Best wishes,

Andreas

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


Re: Legitimate use of ToolchainManagerPrivate?

Posted by Stephen Connolly <st...@gmail.com>.
yep the code. there's some advanced use of tool chains in animal sniffer...
no other plugin that I know of is as advanced in using tool chains

- Stephen

---
Sent from my Android phone, so random spelling mistakes, random nonsense
words and other nonsense are a direct result of using swype to type on the
screen
On 3 Feb 2011 18:44, "Jörg Schaible" <jo...@gmx.de> wrote:
> Andreas Sewe wrote:
>
>> Hi Stephen,
>>
>>> have a look at animal sniffer @mojo
>>
>> the animal-sniffer-maven-plugin is definitely a very useful plugin, but
>> just not for my use case; what I want is to verify that the benchmark
>> being build *behaves* the same on different JVMs (produces identical
>> outputs, doesn't crash the JVM). Simply conforming to an API standard
>> unfortunately does not guarantee this. (This is exemplified very well by
>> the sanity run results of a popular research benchmark suite:
>> <http://dacapo.anu.edu.au/regression/sanity/2011-02-03-
> Thu-13-17/index.html>.)
>>
>> I hope this clarifies things a bit.
>
> I think Stephen meant the code, not the documentation ;-)
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

Re: Legitimate use of ToolchainManagerPrivate?

Posted by Jörg Schaible <jo...@gmx.de>.
Andreas Sewe wrote:

> Hi Stephen,
> 
>> have a look at animal sniffer @mojo
> 
> the animal-sniffer-maven-plugin is definitely a very useful plugin, but
> just not for my use case; what I want is to verify that the benchmark
> being build *behaves* the same on different JVMs (produces identical
> outputs, doesn't crash the JVM). Simply conforming to an API standard
> unfortunately does not guarantee this. (This is exemplified very well by
> the sanity run results of a popular research benchmark suite:
> <http://dacapo.anu.edu.au/regression/sanity/2011-02-03-
Thu-13-17/index.html>.)
> 
> I hope this clarifies things a bit.

I think Stephen meant the code, not the documentation ;-)

- Jörg


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


Re: Legitimate use of ToolchainManagerPrivate?

Posted by Andreas Sewe <se...@st.informatik.tu-darmstadt.de>.
Hi Stephen,

> have a look at animal sniffer @mojo

the animal-sniffer-maven-plugin is definitely a very useful plugin, but 
just not for my use case; what I want is to verify that the benchmark 
being build *behaves* the same on different JVMs (produces identical 
outputs, doesn't crash the JVM). Simply conforming to an API standard 
unfortunately does not guarantee this. (This is exemplified very well by 
the sanity run results of a popular research benchmark suite: 
<http://dacapo.anu.edu.au/regression/sanity/2011-02-03-Thu-13-17/index.html>.)

I hope this clarifies things a bit.

Andreas

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


Re: Legitimate use of ToolchainManagerPrivate?

Posted by Stephen Connolly <st...@gmail.com>.
have a look at animal sniffer @mojo

- Stephen

---
Sent from my Android phone, so random spelling mistakes, random nonsense
words and other nonsense are a direct result of using swype to type on the
screen
On 3 Feb 2011 11:20, "Andreas Sewe" <se...@st.informatik.tu-darmstadt.de>
wrote:
> Hi all,
>
> I am using Maven to build benchmarks for JVM research. I have already
> written a plugin that bundles up the benchmarks harness, dependencies,
> and input data. This works like a charm. :-)
>
> To integration-test the benchmarks, I would like my plugin to run
> benchmark just build on a whole range of JVMs. To this end, Maven's
> toolchain support seems like a perfect fit. Alas, the
> maven-toolchain-plugin can configure only one toolchain of a given type
> and the ToolchainManager only gives me access to a single "jdk" type
> toolchain. What I want, instead, is to retrieve a list of all "jdk" type
> toolchains matching some requirements from my plugin's configuration.
>
> This can be done by using ToolchainManagerPrivate (and duplicating some
> functionality of the maven-toolchain-plugin), but
> ToolchainManagerPrivate doesn't look like its intended to be used that
> way. Is there are better one?
>
> Best wishes,
>
> Andreas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>