Re: Evaluate expressions in a plugin
Thanks for the reply, just for reference, I was looking right now at 3 different solutions for the same problem: 1. The enforcer plugin: EnforcerRuleHelper -> http://svn.apache.org/viewvc/maven/enforcer/tags/enforcer-1.0/enforcer-api/src/main/java/org/apache/maven/enforcer/rule/api/EnforcerRuleHelper.java?view=markup DefaultEnforcerRuleHelper -> http://svn.apache.org/viewvc/maven/enforcer/tags/enforcer-1.0/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/DefaultEnforcementRuleHelper.java?view=markup 2. The help plugin: http://maven.apache.org/plugins/maven-help-plugin/xref/org/apache/maven/plugins/help/EvaluateMojo.html 3. The resources plugin - haven't seen it yet, I presume it's the same thing. Anyway, it's usually something big & convoluted, since for evaluation there's an ExpressionEvaluator which needs: - a different type of logger from Plexus (the Maven 2 logger does not depend on the Plexus logger, WTF?) - the Maven session - a path translator (?) - some other stuff Anyway, it's doable, but not nice by any means :) -- View this message in context: http://maven.40175.n5.nabble.com/Evaluate-expressions-in-a-plugin-tp3276728p3276842.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Evaluate expressions in a plugin
Hello, Is there a simple way to evaluate expressions in a custom Maven 2 plugin? The plugin I'm writing now tries to parse some string which may contain Maven 2 expressions, and I'd like to use Maven 2's mechanisms for filtering/interpolating/replacing these properties. I've looked a bit through the source code of the maven-help-plugin, especially help:evaluate, but it doesn't seem too straightforward. So, is there a simple solution to evaluate expressions in a Maven 2 plugin? Dynamic expressions, not static ones like @parameter expression="${something}". Thanks :) -- View this message in context: http://maven.40175.n5.nabble.com/Evaluate-expressions-in-a-plugin-tp3276728p3276728.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Re: [RESULT] [VOTE] Promote maven-jarsigner-plugin out of sandbox
Benjamin Bentmann wrote: > > Hi, > > The vote has passed with the following result: > > +1: Dennis Lundberg, Arnaud Héritier, John Casey > > Thanks for the feedback! I will move the sources over. > > Over the weekend I plan to look at the outstanding issues reported for > jar:sign and see what I can quickly integrate into the new plugin before > I call a vote for 1.0. Once the plugin is out, I will deprecate the > signing goals in the maven-jar-plugin. > > > Benjamin > > > > - > To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org > For additional commands, e-mail: dev-h...@maven.apache.org > Congratulations! BTW, about this: Benjamin Bentmann wrote: > > Does this plugin take care of the problem of not being able to sign a jar > artifact which has a non-jar packaging type? I ran into this issue > recently. > > Thanks, > Shane > If I want to make and sign a jar and then wrap it in a zip, in the same module... Right now I can't. Is there any technical reason to not allow this? Thank you, Costin. -- View this message in context: http://www.nabble.com/-VOTE--Promote-maven-jarsigner-plugin-out-of-sandbox-tp24453955p24534119.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Re: Copy transitive dependencies
BRIAN FOX-5 wrote: > > Take a look at the maven-dependency-plugin copy-dependencies code, > this is pretty much exactly what you're trying to do. There are > filters that are in a common jar you can reuse to filter out > transitivity etc. > Thanks for the replies guys. I need to download the transitive dependencies of the project's depencies, each into their own folder, like this: A's dependencies - I - II - III I's dependencies - 1 - 2 II's dependencies - 3 - 4 Copy from the repo the dependencies in the following folder structure: I - 1 - 2 II - 3 - 4 For further reference - use ArtifactResolver.resolveTransitively(). Besides resolving transitively, it returns an ArtifactResolutionResult which has a getArtifacts() method which has all the artifacts you need. So, steps: - get the projects artifacts - resolve each one transitively - use the ArtifactResolutionResult to get the transitive dependencies for each dependency (so we don't mix them up) - use the resulting artifacts' .getFile() method to get & later to copy the file where you need it Something like this: Artifact dependency = (Artifact)(mainProject().getArtifacts().iterator().next()); MavenProject dependencyProject = projectBuilder.buildFromRepository(dependency, remoteArtifactRepositories, localRepository); Set artifacts = dependencyProject.createArtifacts(artifactFactory, null, null); ArtifactResolutionResult artifactResolved = artifactResolver.resolveTransitively(artifacts, dependency, remoteArtifactRepositories, localRepository, artifactMetadataSource); artifactResolved.getArtifacts(); ... iterate over the resulting artifacts & do your stuff :) -- View this message in context: http://www.nabble.com/Copy-transitive-dependencies-tp24376786p24406881.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Copy transitive dependencies
Hello, I have a plugin which needs to download & copy somewhere the transitive dependencies of the project's dependencies (at least level 1, I'll see about the rest). So I have this: project -> dependencies -> transitive dependencies. I extracted artifacts from the direct dependencies, so this part is ok. For the rest of the mail, "artifact" is a direct dependency. How can I access the transitive dependencies? I tried artifact.getDependencyTrail() on the artifact - but this doesn't give me what I need (I don't even understand exactly what getDependencyTrail() is supposed to return :) ). Next I tried creating MavenProjects from the artifact: DefaultMavenProjectBuilder defaultMavenProjectBuilder = new DefaultMavenProjectBuilder(); defaultMavenProjectBuilder.initialize(); mavenProject = defaultMavenProjectBuilder.buildFromRepository(artifact, remoteRepositories, localRepository) I was thinking of using getDependencies() on the project, but this gives me a nice NPE. How can I use DefaultMavenProjectBuilder? I also looked around at maven-dependency-plugin & others but I'm having problems understanding exactly the parts I need (plus the documentation isn't that great...). Any ideas? Kind regard, Costin. -- View this message in context: http://www.nabble.com/Copy-transitive-dependencies-tp24376786p24376786.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Deprecated warning on help:describe
Hello, For a plugin I wrote, help:describe says this, both for the goals and for the parameters: "Deprecated. No reason given" What must I do to get rid of this message, since it's confusing to users? Thank you. -- View this message in context: http://www.nabble.com/Deprecated-warning-on-help%3Adescribe-tp22872404p22872404.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
How do I get the Maven classpaths in a test?
Hello. Suppose I'm running a Junit test with Maven, and I need to get all the files in the classpath, for various reasons. Is there any way to access the Maven project and get it's classpath? (I presume I can't just use @parameter & co). Thank you, Costin. -- View this message in context: http://www.nabble.com/How-do-I-get-the-Maven-classpaths-in-a-test--tp22621200p22621200.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Re: Map @parameter loading problem
Benjamin Bentmann wrote: > > Costin Caraivan wrote: > >> The invocation is from the pom.xml, inside a profile. So execution bound >> to >> a build lifecycle. > > Then consider to drop an example project in JIRA so we can have closer > look and something to reproduce the issue. From the few bits given so > far, I have no idea what might be going wrong. > > > Benjamin > To finish this topic, I can't reproduce it now, I might have made a typo (I really don't think so, I checked the names several times). If it pops up again I'll try to file a bug, but it's not that easy (need to edit my project, I can't upload it all to the bug tracker). Thanks for the help, Costin. -- View this message in context: http://www.nabble.com/Map-%40parameter-loading-problem-tp21854211p21971574.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Re: Map @parameter loading problem
Benjamin Bentmann wrote: > > Costin Caraivan wrote: > >> By the way, this works when I move the section in the >> root >> of the plugin. > > We have a (passing) IT [0] to test configuration which > includes a Map parameter so I wonder how do you invoke your mojo in the > first place? From the command line? Per configurations have > by design no effect to CLI invocations of a plugin, they are only meant > for executions bound to the build lifecycle. > > Benjamin > > [0] > http://svn.eu.apache.org/repos/asf/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3864/pom.xml > The invocation is from the pom.xml, inside a profile. So execution bound to a build lifecycle. Here is the execution (out of which I took out the section for now. unpack-plugins process-resources unpackPlugins -- View this message in context: http://www.nabble.com/Map-%40parameter-loading-problem-tp21854211p21872258.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Re: Map @parameter loading problem
Costin Caraivan wrote: > > Hello, > > I have a plugin with the following configuration: > > > com.axway.md > com.axway.md > ${project.version} > zip > > aoleu > aoleu > > This is inside an execution of my plugin. > > In my Mojo I have this: > /** > * @parameter > * @required > */ > private Map featureId; > > However, the featureId comes out as null, and when I added @required, > Maven tells me: > [0] Inside the definition for plugin 'axway-eclipse-plugin' specify the > following: > > ... > VALUE > . > > According to: > http://maven.apache.org/guides/plugin/guide-java-plugin-development.html > I'm doing everything right (or at least I hope so :) ). > > Why isn't the map loaded? > Thank you. > > Regards, > Costin. > By the way, this works when I move the section in the root of the plugin. But I'd want it to be per execution. Any ideas how I could configure this per execution? Thanks :) -- View this message in context: http://www.nabble.com/Map-%40parameter-loading-problem-tp21854211p21854670.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Map @parameter loading problem
Hello, I have a plugin with the following configuration: com.axway.md com.axway.md ${project.version} zip aoleu aoleu This is inside an execution of my plugin. In my Mojo I have this: /** * @parameter * @required */ private Map featureId; However, the featureId comes out as null, and when I added @required, Maven tells me: [0] Inside the definition for plugin 'axway-eclipse-plugin' specify the following: ... VALUE . According to: http://maven.apache.org/guides/plugin/guide-java-plugin-development.html I'm doing everything right (or at least I hope so :) ). Why isn't the map loaded? Thank you. Regards, Costin. -- View this message in context: http://www.nabble.com/Map-%40parameter-loading-problem-tp21854211p21854211.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Re: Programmatically adding dependencies to a MavenProject
Richard van Nieuwenhoven-2 wrote: > > Hi, > > i also had this problem, and yes Jason is right don't do it! You will > have all sorts of follow up problems (like some other plugins not > working). It will work for the normal stuff, but be sure to start your > plugin in the validate phase. > > Now i use a custom repository layout / repository to enable me to add > maven dependencies to those jars (that works also with maven 3 and all > other plugins keep working ;-). But you could also try Tycho. > > http://docs.codehaus.org/display/M2ECLIPSE/Tycho+project+overview > > I am thinking of creating a sourceforge project for the repository > layout, if there people willing to help (like adding your needed feature > of embedded jars). > > regards, > Richard van Nieuwenhoven > Tycho being alpha certainly does not inspire confidence. My main problem right now is that OSGi > Maven (in terms of complexity). I know that Maven developers know this and are trying to solve it, but I have a problem to solve too, and waiting for the indefinite future isn't really an option. The solution will probably be the other way around: run something before the build to add the dependencies to the pom.xml. A more visible workaround, if you may. Regards, Costin. -- View this message in context: http://www.nabble.com/Programmatically-adding-dependencies-to-a-MavenProject-tp21173440p21681478.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Re: Programmatically adding dependencies to a MavenProject
Jason van Zyl-5 wrote: > > This is a bad idea and don't count on Maven 3.x supporting this > because it makes determining what the dependencies are black magic. > The dependency tree and visualization tools won't work. In Maven 3.x > we are likely to make the dependency set immutable post resolution > phase. > > I don't feel there is any valid use case for programatically adding > dependencies and if someone finds one then something is wrong with > Maven itself. > Use case: Eclipse bundles. They can be simple jars or jars containing jars. Any other ideas for getting the classes inside those inner jars visible for the compiler? eclipse.jar contains whatever.jar. whatever.jar contains classes. I want to compile myjar.jar using the classes in whatever.jar. I do not want (for ease of use, this is a request) to manually add the inside dependencies, I just want to add eclipse.jar (like Eclipse itself does during plugin development). I think this is a legitimate use case, *so*, for my use case, could anyone please point out what I'm doing wrong? -- View this message in context: http://www.nabble.com/Programmatically-adding-dependencies-to-a-MavenProject-tp21173440p21680711.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
Re: Programmatically adding dependencies to a MavenProject
Maarten Storm-2 wrote: > > Hello all, > I would like to add programmatically dependencies to the MavenProject. > I have looked in the mail archives but I could not find info on this > topic.Is there a possible solution for this? > Kind regards, > Maarten Storm > Hello, I'm also interested by this and I found this example: http://www.eclipse.org/articles/article.php?file=Article-Eclipse-and-Maven2/index.html However, when I do it, I get a NullPointerException later on with this code: currentArtifact = artifactFactory.createBuildArtifact( currentDependency.getGroupId(), currentDependency.getArtifactId(), currentDependency.getVersion(), currentDependency.getType() ); // Add the jar to the dependency list. getProject().getDependencies().add(currentDependency); // Get the artifact from the remote repository if it is not available locally. artifactResolver.resolve(currentArtifact, getProject().getRemoteArtifactRepositories(), localRepository); => [ERROR] FATAL ERROR [INFO] [INFO] null [INFO] [INFO] Trace java.lang.NullPointerException at org.apache.maven.project.artifact.MavenMetadataSource.createArtifacts(MavenMetadataSource.java:327) at org.apache.maven.project.MavenProject.createArtifacts(MavenProject.java:1577) at org.apache.maven.plugin.DefaultPluginManager.resolveTransitiveDependencies(DefaultPluginManager.java:1409) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:405) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129) at org.apache.maven.cli.MavenCli.main(MavenCli.java:287) 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:585) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375) BTW, some things are undocumented, like how to get access to artifactFactory or artifactResolver - I had to Google this page up to be able to write that code: http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook Thanks for any tips. Regards, Costin. -- View this message in context: http://www.nabble.com/Programmatically-adding-dependencies-to-a-MavenProject-tp21173440p21664740.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org
How to get path to the local repository?
I tried: Settings set = new Settings(); set.getLocalRepository(); gives me null (probably because I don't have an explicit path in the settings.xml file). I also tried: ArtifactRepository localRepo; localRepo.getBasedir(); but this doesn't work. How do I get the path to the local repository? I'm sure that Maven computes it, because a ${settings.LocalRepository} property in a pom file gets the right path. Any clues? Regards, Costin. -- View this message in context: http://www.nabble.com/How-to-get-path-to-the-local-repository--tp21417315p21417315.html Sent from the Maven Developers mailing list archive at Nabble.com. - To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org