I am trying to pass an object through my pom to my maven mojo.
I have a class...
public class Shortcut {
/**
* @parameter expression="${project}"
*/
private String name;
private String description;
private String commandLine;
public Shortcut(String Name)
{
setName(Name);
//setDescription(Description);
//setCommandLine(CommandLine);
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
public void setCommandLine(String commandLine) {
this.commandLine = commandLine;
}
public String getCommandLine() {
return commandLine;
}
}
and i declare the variable
/**
* Shortcuts to add to XML
* @parameter
*/
private Shortcut shortcut;
and in my pom i declare this in the <configuration> tag
<shortcut>
<name>TESTING</name>
<description>TESTING</description>
<commandLine>TESTING</commandLine>
</shortcut>
I keep getting this error
[ERROR] Failed to execute goal SOME.PACKAGE (default-cli) on project test:
Unable to parse configuration of mojo SOME.PACKAGE for parameter shortcut:
Class 'SOME.PACKAGE.Shortcut' cannot be instantiated -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute
goal SOME.PACKAGE (default-cli) on project test: Unable to parse
configuration of mojo SOME.PACKAGE for parameter shortcut: Class
'SOME.PACKAGE.Shortcut' cannot be instantiated
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:589)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
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.PluginConfigurationException: Unable to
parse configuration of mojo SOME.PACKAGE for parameter shortcut: Class
'SOME.PACKAGE.Shortcut' cannot be instantiated
at
org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:643)
at
org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:595)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:94)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
... 14 more
Caused by:
org.codehaus.plexus.component.configurator.ComponentConfigurationException:
Class 'SOME.PACKAGE.Shortcut' cannot be instantiated
at
org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter.instantiateObject(AbstractConfigurationConverter.java:133)
at
org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.fromConfiguration(ObjectWithFieldsConverter.java:90)
at
org.codehaus.plexus.component.configurator.converters.ComponentValueSetter.configure(ComponentValueSetter.java:260)
at
org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:145)
at
org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:58)
at
org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:630)
... 17 more
Caused by: java.lang.InstantiationException: SOME.PACKAGE.Shortcut
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at
org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter.instantiateObject(AbstractConfigurationConverter.java:123)
... 22 more
Could someone give me an example or explain to me why this isnt working.
For an example
a sample simple custom class and the corresponding pom and variable
declarations would be great.
Thanks in advance
-TJ
--
View this message in context:
http://maven.40175.n5.nabble.com/Mojo-Complex-Object-From-Pom-tp2639350p2639350.html
Sent from the Maven Developers mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]