Re: How to add a dependency programmatically for the compile phase?
Well, it doesn't talk about the solution you're talking about, which I pointed out in my initial mail. The solution I had in mind, but don't really know if it is doable, would be to have a custom packaging type (which is packaged as a plugin as explained in the article) which would map to the .aar file type. It would then have an ArtifactHandler which would then do the magic you're asking about. BUT, I don't know if this works. How would this work if Maven was not used? How would the compiler be able to read/use the jar in the aar file? Is it a special classloader? I was about to point you at Manfred, but I found a thread where I see that you're already working with him. :-) /Anders On Fri, Dec 20, 2013 at 2:43 PM, Benoit Billington < benoit.billing...@gmail.com> wrote: > Thanks Anders but unfortunately the content of that article didn't talk > about > the thing we need. which is adding content of a dependency to the > classpath. > This article is talking about supporting new extensions which we already do > by supporting aar. > > But an ".aar" contains a ".jar" that needs to be added to the classpath > too. > > > > -- > View this message in context: > http://maven.40175.n5.nabble.com/How-to-add-a-dependency-programmatically-for-the-compile-phase-tp5778954p5779153.html > Sent from the Maven - Users mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > >
Re: How to add a dependency programmatically for the compile phase?
Thanks Anders but unfortunately the content of that article didn't talk about the thing we need. which is adding content of a dependency to the classpath. This article is talking about supporting new extensions which we already do by supporting aar. But an ".aar" contains a ".jar" that needs to be added to the classpath too. -- View this message in context: http://maven.40175.n5.nabble.com/How-to-add-a-dependency-programmatically-for-the-compile-phase-tp5778954p5779153.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: How to add a dependency programmatically for the compile phase?
This is the page is quickly glanced through before replying: http://blog.sonatype.com/2009/08/create-a-customized-build-process-in-maven/ As I've never written an ArtifactHandler I don't really know what the limitations are. Maybe there is someone else here who knows more on this? /Anders On Thu, Dec 19, 2013 at 9:10 AM, William Ferguson < william.fergu...@xandar.com.au> wrote: > There are only a few consumers of aar (which is a newish packaging type) > artifacts from a Maven repository. > >1. People that build using Maven and our plugin. >2. People that build using Gradle. >3. Building from an IDE like IntelliJ/Eclipse > > This solution would appears to solve 1 and probably 3 (since typically the > IDE just delegates to Maven - at least IntelliJ does). 2 is not our > concern. > > But if we can somehow update the Project Model inside the IDE so that when > it sees an aar dependency that it looks inside it and adds the embedded jar > to the compile classpath that is ideal. If that is what you are suggesting > with a custom ArtifactHandler then I am all ears. Can you point me to some > high value doco? > > William > > > > > > On Thu, Dec 19, 2013 at 5:12 PM, Anders Hammar wrote: > > > I don't have the code at hands on how to do what you're asking, but I > > wanted to stress that changing the dependency list in a plugin will only > > affect that list during the build where your plugin is executed. Any > > consumers of your artifact (from the repo) will not get this dependency, > as > > the plugin is then not executed! Maybe you can solve this with a custom > > packaging type and a special ArtifactHandler, but I'm not sure. > > > > /Anders > > > > > > > > On Thu, Dec 19, 2013 at 5:25 AM, William Ferguson < > > william.fergu...@xandar.com.au> wrote: > > > > > Hi, > > > > > > I would like to know how to add a dependency (such as a jar) into the > > > project's list of compile time dependencies programmatically within a > > Mojo. > > > Benoit should probably have posted this in Maven Users rather than > > > Maven Dev, so I'm reposting here. > > > > > > We are developing a Mojo that needs to add some dependencies into the > > > project list of compile time dependencies programmatically. I was sure > > > that I've seen code that did this, but I can't find it now. Can anyone > > > point us in the right direction? > > > > > > William > > > > > > -- Benoit's original post -- > > > > > > I require to do this programmatically because the user set a dependency > > of > > > type "aar"(1) which itself contains a jar. > > > This jar needs to be known by the compile phase (in order to succeed) > > > Note: the compile phase knows about the aar dependency. > > > > > > (1) Aar format: > > > http://tools.android.com/tech-docs/new-build-system/aar-format > > > > > > Other conversations: > > > About AAR & the included > > > JAR: > > > > > > https://groups.google.com/forum/#!topic/maven-android-developers/bPK3EnbKH2M > > > > > > Programmatically adding dependencies to a MavenProject: (this > > conversation > > > led to a hacky solution) > > > > > > http://maven.40175.n5.nabble.com/Programmatically-adding-dependencies-to-a-MavenProject-td215077i20.html#a5773302 > > > > > >
Re: How to add a dependency programmatically for the compile phase?
There are only a few consumers of aar (which is a newish packaging type) artifacts from a Maven repository. 1. People that build using Maven and our plugin. 2. People that build using Gradle. 3. Building from an IDE like IntelliJ/Eclipse This solution would appears to solve 1 and probably 3 (since typically the IDE just delegates to Maven - at least IntelliJ does). 2 is not our concern. But if we can somehow update the Project Model inside the IDE so that when it sees an aar dependency that it looks inside it and adds the embedded jar to the compile classpath that is ideal. If that is what you are suggesting with a custom ArtifactHandler then I am all ears. Can you point me to some high value doco? William On Thu, Dec 19, 2013 at 5:12 PM, Anders Hammar wrote: > I don't have the code at hands on how to do what you're asking, but I > wanted to stress that changing the dependency list in a plugin will only > affect that list during the build where your plugin is executed. Any > consumers of your artifact (from the repo) will not get this dependency, as > the plugin is then not executed! Maybe you can solve this with a custom > packaging type and a special ArtifactHandler, but I'm not sure. > > /Anders > > > > On Thu, Dec 19, 2013 at 5:25 AM, William Ferguson < > william.fergu...@xandar.com.au> wrote: > > > Hi, > > > > I would like to know how to add a dependency (such as a jar) into the > > project's list of compile time dependencies programmatically within a > Mojo. > > Benoit should probably have posted this in Maven Users rather than > > Maven Dev, so I'm reposting here. > > > > We are developing a Mojo that needs to add some dependencies into the > > project list of compile time dependencies programmatically. I was sure > > that I've seen code that did this, but I can't find it now. Can anyone > > point us in the right direction? > > > > William > > > > -- Benoit's original post -- > > > > I require to do this programmatically because the user set a dependency > of > > type "aar"(1) which itself contains a jar. > > This jar needs to be known by the compile phase (in order to succeed) > > Note: the compile phase knows about the aar dependency. > > > > (1) Aar format: > > http://tools.android.com/tech-docs/new-build-system/aar-format > > > > Other conversations: > > About AAR & the included > > JAR: > > > https://groups.google.com/forum/#!topic/maven-android-developers/bPK3EnbKH2M > > > > Programmatically adding dependencies to a MavenProject: (this > conversation > > led to a hacky solution) > > > http://maven.40175.n5.nabble.com/Programmatically-adding-dependencies-to-a-MavenProject-td215077i20.html#a5773302 > > >
Re: How to add a dependency programmatically for the compile phase?
I don't have the code at hands on how to do what you're asking, but I wanted to stress that changing the dependency list in a plugin will only affect that list during the build where your plugin is executed. Any consumers of your artifact (from the repo) will not get this dependency, as the plugin is then not executed! Maybe you can solve this with a custom packaging type and a special ArtifactHandler, but I'm not sure. /Anders On Thu, Dec 19, 2013 at 5:25 AM, William Ferguson < william.fergu...@xandar.com.au> wrote: > Hi, > > I would like to know how to add a dependency (such as a jar) into the > project's list of compile time dependencies programmatically within a Mojo. > Benoit should probably have posted this in Maven Users rather than > Maven Dev, so I'm reposting here. > > We are developing a Mojo that needs to add some dependencies into the > project list of compile time dependencies programmatically. I was sure > that I've seen code that did this, but I can't find it now. Can anyone > point us in the right direction? > > William > > -- Benoit's original post -- > > I require to do this programmatically because the user set a dependency of > type "aar"(1) which itself contains a jar. > This jar needs to be known by the compile phase (in order to succeed) > Note: the compile phase knows about the aar dependency. > > (1) Aar format: > http://tools.android.com/tech-docs/new-build-system/aar-format > > Other conversations: > About AAR & the included > JAR: > https://groups.google.com/forum/#!topic/maven-android-developers/bPK3EnbKH2M > > Programmatically adding dependencies to a MavenProject: (this conversation > led to a hacky solution) > http://maven.40175.n5.nabble.com/Programmatically-adding-dependencies-to-a-MavenProject-td215077i20.html#a5773302 >