You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by sizu <sc...@gmail.com> on 2013/10/11 19:19:26 UTC

Re: Is there any maven plugin to add dependency to existing pom.xml ?

This is useful for many reasons.  The less steps required to use external
dependencies the better.  If someone must add and configure xml to add a
dependency, it leads to human in the loop, which leads to errors.

I am all about how quick, I can get installed.

For instance, maybe I am writing an organizations how to, to download the
standard speech jar.

I would rather say, issue these ten commands:

curl http://dl.ghost4j.org/ghost4j-0.5.0.zip > ghost4j-0.5.0.zip

open ghost4j-0.5.0.zip

/usr/bin/mvn install:install-file -Dfile=ghost4j-0.5.0/ghost4j-0.5.0.jar
-Dpackaging=jar -DgroupId=org.ghost4j -DartifactId=ghost4j -Dversion=0.5.0
-DaddToPom=true

/usr/bin/mvn install:install-file
-Dfile=ghost4j-0.5.0/lib/xmlgraphics-commons-1.4.jar -Dpackaging=jar
-DgroupId=org.ghost4j -DartifactId=xmlgraphics-commons -Dversion=1.4
-DaddToPom=true

/usr/bin/mvn install:install-file
-Dfile=ghost4j-0.5.0/lib/commons-io-1.3.1.jar -Dpackaging=jar
-DgroupId=org.ghost4j -DartifactId=commons-io -Dversion=1.3.1
-DaddToPom=true

/usr/bin/mvn install:install-file -Dfile=ghost4j-0.5.0/lib/log4j-1.2.15.jar
-Packaging=jar -DgroupId=org.ghost4j -DartifactId=log4j -Dversion=1.2.15
-DaddToPom=true

/usr/bin/mvn install:install-file
-Dfile=ghost4j-0.5.0/lib/commons-beanutils-1.8.3.jar -Dpackaging=jar
-DgroupId=org.ghost4j -DartifactId=commons-beanutils -Dversion=1.8.3
-DaddToPom=true

/usr/bin/mvn install:install-file
-Dfile=ghost4j-0.5.0/lib/commons-logging-1.1.1.jar -Dpackaging=jar
-DgroupId=org.ghost4j -DartifactId=commons-logging -Dversion=1.1.1
-DaddToPom=true

/usr/bin/mvn install:install-file -Dfile=ghost4j-0.5.0/lib/itext-2.1.7.jar
-Dpackaging=jar -DgroupId=org.ghost4j -DartifactId=itext -Dversion=2.1.7
-DaddToPom=true

/usr/bin/mvn install:install-file -Dfile=ghost4j-0.5.0/lib/jna-3.3.0.jar
-Dpackaging=jar -DgroupId=org.ghost4j -DartifactId=jna -Dversion=3.3.0
-DaddToPom=true

More commands, fine, but command line also leads to automation.  Users can
include ghostscript via a batch file!



--
View this message in context: http://maven.40175.n5.nabble.com/Is-there-any-maven-plugin-to-add-dependency-to-existing-pom-xml-tp2839092p5772853.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: Is there any maven plugin to add dependency to existing pom.xml ?

Posted by Benson Margulies <bi...@gmail.com>.
I use the maven invoker plugin for this, by parameterizing a pom so
that I can substitute various versions. By using the 'pom dependency'
thing, you could perhaps do this for entire dependencies as opposed to
versions. Or you could script pom editing; there are XML-editing Maven
plugin and ant plugins out there.

On Fri, Oct 11, 2013 at 2:45 PM, sizu <sc...@gmail.com> wrote:
> Example using sed:
>
> sed
> 's/<dependencies>/<dependencies>\r\n\r\n<dependency>\r\n<groupId>org.ghost4j<\/groupId>\r\n<artifactId>ghost4j<\/artifactId>\r\n<version>0.5.0<\/version>\r\n<\/dependency>\r\n/g'
> pom.xml > pom2.xml
>
> Replaces the dependencies tag with the dependencies tag followed by the new
> dependency (inserts the new dependency first in the list.
>
> Creates a new file pom2.xml with the new dependency (this can be changed to
> overwrite the original file using: pom.xml > pom.xml
>
>
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/Is-there-any-maven-plugin-to-add-dependency-to-existing-pom-xml-tp2839092p5772863.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

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


Re: Is there any maven plugin to add dependency to existing pom.xml ?

Posted by sizu <sc...@gmail.com>.
Example using sed:

sed
's/<dependencies>/<dependencies>\r\n\r\n<dependency>\r\n<groupId>org.ghost4j<\/groupId>\r\n<artifactId>ghost4j<\/artifactId>\r\n<version>0.5.0<\/version>\r\n<\/dependency>\r\n/g'
pom.xml > pom2.xml

Replaces the dependencies tag with the dependencies tag followed by the new
dependency (inserts the new dependency first in the list.

Creates a new file pom2.xml with the new dependency (this can be changed to
overwrite the original file using: pom.xml > pom.xml



--
View this message in context: http://maven.40175.n5.nabble.com/Is-there-any-maven-plugin-to-add-dependency-to-existing-pom-xml-tp2839092p5772863.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: Is there any maven plugin to add dependency to existing pom.xml ?

Posted by sizu <sc...@gmail.com>.
Here is another use case.  Suppose I programmatically want to make sure that
my database is backwards compatible with all versions of my application.  I
may have a test suite that compiles the project using different jars, which
represent different versions of the persistence module.

I can verify no exceptions or errors and that data can be extracted.  I
could alos programmatically determine that a database created with any
version was readable by any other version.  This is huge!

Imagine the database is expanding, fields being added and deleted.  If the
database was created and writen using my-database-1.0.3-jar, could it be
read with 1.0.2-jar and 1.0.5-jar.  You may not be able to do anything about
1.0.2 reading 1.0.3, because 1.0.3 is already released, but that would
enable you to create a database jar that was forward compatible (or
scalable) and backwards compatible.



--
View this message in context: http://maven.40175.n5.nabble.com/Is-there-any-maven-plugin-to-add-dependency-to-existing-pom-xml-tp2839092p5772861.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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