You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by buzzterrier <te...@gmail.com> on 2008/03/24 19:32:17 UTC

Deploy pom with dependencies to internal repository

Hello, 

We have several projects that share common dependencies. I wanted to create
a parent pom that allowed them to inherit these dependencies, but from what
I can tell all the projects would need to be sub-projects of the parent to
inherit the parent pom (not what we want). Digging around in the archives I
found a thread that (loosely) described installing a pom that contains all
the common dependencies, and then adding a reference to that artifact in
your pom, making sure to reference it as <type>pom</type>. This works when I
install it to my local repository. However, when I try to deploy it to our
Internal repository, only the project description gets uploaded, without the
dependencies. 

for example, here is a snippet of what gets installed locally:

...	
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
<groupId>com.foo</groupId>
	<artifactId>common-dependencies</artifactId>
	<packaging>pom</packaging>
	<version>1.0</version>
	<dependencies>
		 <dependency>
		    <groupId>log4j</groupId>
		    <artifactId>log4j</artifactId>
		    <version>1.2.12</version>
		</dependency>
		<dependency>
			<groupId>axis</groupId>
			<artifactId>axis</artifactId>
			<version>1.3</version>
			<scope>compile</scope>
		</dependency>
...

and here is what gets deployed to the Internal repository:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.foo</groupId>
  <artifactId>common-dependencies</artifactId>
  <packaging>pom</packaging>
  <version>1.0</version>
</project>

I use the following command to deploy it to the Internal repos:
mvn deploy:deploy-file -DgroupId=com.foo -DartifactId=common-dependencies
-Dversion=1.0 -Dpackaging=pom -Dfile=c:/poms/common-dependencies.xml
-Durl=http://ourinternalrepos:8080/archiva/repository/internal
-DrepositoryId=internal  -Dgenerate-pom=true

How do I get the dependencies included with the pom on the Internal
repository? I read the docs and it seems like the deploy:deploy-file target
should be used to install to an Internal repos, while install:install-file
is for local repos. 
-- 
View this message in context: http://www.nabble.com/Deploy-pom-with-dependencies-to-internal-repository-tp16258021s177p16258021.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: Deploy pom with dependencies to internal repository

Posted by simon <si...@chello.at>.
Hi Wendy,

On Mon, 2008-03-24 at 13:19 -0700, Wendy Smoak wrote:
> On Mon, Mar 24, 2008 at 1:16 PM, buzzterrier <te...@gmail.com> wrote:
> 
> >  Thx for the reply. I did define a custom pom, that declared the
> >  dependencies, e.g.
> ...
> >  but when I deploy this pom to the internal repository the dependencies are
> >  stripped out and I am left with:
> 
> What command did you use?
> 
> My guess is that you left out -DpomFile=... and you're getting the
> automatically generated pom.
> 
> http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html
> 

I've tried it, and that works too. However it seems a very odd UI for
the deploy plugin.

The "file" property is mandatory, so when deploying just a POM, doesn't
it make sense to set -Dfile to point to the pom.xml, and
-Dpackaging=pom?

And when doing that, it then seems very odd to have to set the optional
-DpomFile parameter. In fact, I would bet that maven then scps the pom
file twice; once as the "deployed file" and once as the "deployed pom".
Not fatal, but definitely odd.

Wouldn't it make more sense to disable generatePom when -Dpackaging=pom
is set?

Regards,
Simon


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


Re: Deploy pom with dependencies to internal repository

Posted by buzzterrier <te...@gmail.com>.
Sweet, that worked! I would have never thought to add the -DpomFile, since I
declared the packaging as pom. 

Thank you both for your help.

 

Wendy Smoak-3 wrote:
> 
> On Mon, Mar 24, 2008 at 1:40 PM, buzzterrier <te...@gmail.com>
> wrote:
> 
> 
> Yep, I posted the wrong link.  Simon got it right, but I think you can
> shorten it by using -DpomFile=... (and you definitely don't want it to
> generate a pom.)  It's a bit non-intuitive to specify both file and
> pomFile, but it works.
> 
> JIRA issues for enhancements (preferably with patches) welcome! :)
> 
> -- 
> Wendy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Deploy-pom-with-dependencies-to-internal-repository-tp16258021s177p16260888.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: Deploy pom with dependencies to internal repository

Posted by Wendy Smoak <ws...@gmail.com>.
On Mon, Mar 24, 2008 at 1:40 PM, buzzterrier <te...@gmail.com> wrote:

>  mvn deploy:deploy-file -DgroupId=com.foo -DartifactId=common-dependencies
>  -Dversion=1.0 -Dpackaging=pom -Dfile=c:/poms/common-dependencies.xml
>  -Durl=http://ourinternalrepos:8080/archiva/repository/internal
>  -DrepositoryId=internal  -Dgenerate-pom=true
>
>  The install plugin states that it:
>  "Installs a file in local repository."

Yep, I posted the wrong link.  Simon got it right, but I think you can
shorten it by using -DpomFile=... (and you definitely don't want it to
generate a pom.)  It's a bit non-intuitive to specify both file and
pomFile, but it works.

JIRA issues for enhancements (preferably with patches) welcome! :)

-- 
Wendy

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


Re: Deploy pom with dependencies to internal repository

Posted by buzzterrier <te...@gmail.com>.
Hi Wendy,

I used deploy:deploy-file:

mvn deploy:deploy-file -DgroupId=com.foo -DartifactId=common-dependencies
-Dversion=1.0 -Dpackaging=pom -Dfile=c:/poms/common-dependencies.xml
-Durl=http://ourinternalrepos:8080/archiva/repository/internal
-DrepositoryId=internal  -Dgenerate-pom=true

The install plugin states that it:
"Installs a file in local repository."

I want to install to an Internal repository which is why the deploy plugin
seemed appropriate.



Wendy Smoak-3 wrote:
> 
> On Mon, Mar 24, 2008 at 1:16 PM, buzzterrier <te...@gmail.com>
> wrote:
> 
>>  Thx for the reply. I did define a custom pom, that declared the
>>  dependencies, e.g.
> ...
>>  but when I deploy this pom to the internal repository the dependencies
>> are
>>  stripped out and I am left with:
> 
> What command did you use?
> 
> My guess is that you left out -DpomFile=... and you're getting the
> automatically generated pom.
> 
> http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html
> 
> -- 
> Wendy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Deploy-pom-with-dependencies-to-internal-repository-tp16258021s177p16260462.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: Deploy pom with dependencies to internal repository

Posted by Wendy Smoak <ws...@gmail.com>.
On Mon, Mar 24, 2008 at 1:16 PM, buzzterrier <te...@gmail.com> wrote:

>  Thx for the reply. I did define a custom pom, that declared the
>  dependencies, e.g.
...
>  but when I deploy this pom to the internal repository the dependencies are
>  stripped out and I am left with:

What command did you use?

My guess is that you left out -DpomFile=... and you're getting the
automatically generated pom.

http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html

-- 
Wendy

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


Re: Deploy pom with dependencies to internal repository

Posted by simon <si...@chello.at>.
On Mon, 2008-03-24 at 13:16 -0700, buzzterrier wrote:
> Hi Simon,
> 
> Thx for the reply. I did define a custom pom, that declared the
> dependencies, e.g.
> 
> common_dependencies.xml
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>  http://maven.apache.org/maven-v4_0_0.xsd">
> 	<modelVersion>4.0.0</modelVersion>
> 	<groupId>com.foo</groupId>
> 	<artifactId>common-dependencies</artifactId>
> 	<packaging>pom</packaging>
> 	<version>1.0</version>
> 	<dependencies>
> 		 <dependency>
> 		    <groupId>log4j</groupId>
> 		    <artifactId>log4j</artifactId>
> 		    <version>1.2.12</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>axis</groupId>
> 			<artifactId>axis</artifactId>
> 			<version>1.3</version>
> 			<scope>compile</scope>
> 		</dependency>
> ...
> 
> </project>
> 
> but when I deploy this pom to the internal repository the dependencies are
> stripped out and I am left with:
> 
> <project>
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com.foo</groupId>
>   <artifactId>common-dependencies</artifactId>
>   <packaging>pom</packaging>
>   <version>1.0</version>
> </project> 
> 
> If I install the pom to my local repository all the dependency declarations
> are still there. I cannot figure out how to install the pom to the internal
> repository with the dependency declarations.

I just tried it, and got the same problem:

mvn deploy:deploy-file -DgroupId=foo -DartifactId=foo -Dversion=1
-Dpackaging=pom -Dfile=pom.xml -Durl=file:///home/simon/mockm2

Then I added
  -DgeneratePom=false
on the end, and it worked as expected.

The generatePom option is true by default, so I think maven is
generating a pom for the pom, and overwriting the one just deployed:-). 

Looks like a JIRA issue is needed for maven-deploy-plugin to ensure
generatePom defaults to false when -Dpackaging=pom is specified!

> 
> Also, thx for your insight on why this approach may be problematic. Can you
> suggest a more appropriate approach for sharing common libraries across
> several projects. For example, all the projects are going to use log4J so it
> seems like it should be automatically made available to all of them.

I would personally just add log4j as an explicit dependency. If a
project uses log4j, then why not add a dependency for it? This then
means that poms declare their *real* dependencies, and don't pull in
stuff that they don't need.

Some people then start worrying about "keeping the version up to date",
but I think that's not an issue at all. If a project functions fine with
a specific version, then there is no need to keep updating the version -
in fact, it's dangerous. And if something else depends on that lib but
itself uses log4j, then it will automatically override the version
anyway.

Regards,
Simon


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


Re: Deploy pom with dependencies to internal repository

Posted by buzzterrier <te...@gmail.com>.
Hi Simon,

Thx for the reply. I did define a custom pom, that declared the
dependencies, e.g.

common_dependencies.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.foo</groupId>
	<artifactId>common-dependencies</artifactId>
	<packaging>pom</packaging>
	<version>1.0</version>
	<dependencies>
		 <dependency>
		    <groupId>log4j</groupId>
		    <artifactId>log4j</artifactId>
		    <version>1.2.12</version>
		</dependency>
		<dependency>
			<groupId>axis</groupId>
			<artifactId>axis</artifactId>
			<version>1.3</version>
			<scope>compile</scope>
		</dependency>
...

</project>

but when I deploy this pom to the internal repository the dependencies are
stripped out and I am left with:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.foo</groupId>
  <artifactId>common-dependencies</artifactId>
  <packaging>pom</packaging>
  <version>1.0</version>
</project> 

If I install the pom to my local repository all the dependency declarations
are still there. I cannot figure out how to install the pom to the internal
repository with the dependency declarations.

Also, thx for your insight on why this approach may be problematic. Can you
suggest a more appropriate approach for sharing common libraries across
several projects. For example, all the projects are going to use log4J so it
seems like it should be automatically made available to all of them.


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




-- 
View this message in context: http://www.nabble.com/Deploy-pom-with-dependencies-to-internal-repository-tp16258021s177p16259983.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: Deploy pom with dependencies to internal repository

Posted by simon <si...@chello.at>.
On Mon, 2008-03-24 at 11:32 -0700, buzzterrier wrote:
> Hello, 
> 
> We have several projects that share common dependencies. I wanted to create
> a parent pom that allowed them to inherit these dependencies, but from what
> I can tell all the projects would need to be sub-projects of the parent to
> inherit the parent pom (not what we want). Digging around in the archives I
> found a thread that (loosely) described installing a pom that contains all
> the common dependencies, and then adding a reference to that artifact in
> your pom, making sure to reference it as <type>pom</type>. This works when I
> install it to my local repository. However, when I try to deploy it to our
> Internal repository, only the project description gets uploaded, without the
> dependencies. 
> 
> for example, here is a snippet of what gets installed locally:
> 
> ...	
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>  http://maven.apache.org/maven-v4_0_0.xsd">
> 	<modelVersion>4.0.0</modelVersion>
> <groupId>com.foo</groupId>
> 	<artifactId>common-dependencies</artifactId>
> 	<packaging>pom</packaging>
> 	<version>1.0</version>
> 	<dependencies>
> 		 <dependency>
> 		    <groupId>log4j</groupId>
> 		    <artifactId>log4j</artifactId>
> 		    <version>1.2.12</version>
> 		</dependency>
> 		<dependency>
> 			<groupId>axis</groupId>
> 			<artifactId>axis</artifactId>
> 			<version>1.3</version>
> 			<scope>compile</scope>
> 		</dependency>
> ...
> 
> and here is what gets deployed to the Internal repository:
> 
> <project>
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com.foo</groupId>
>   <artifactId>common-dependencies</artifactId>
>   <packaging>pom</packaging>
>   <version>1.0</version>
> </project>
> 
> I use the following command to deploy it to the Internal repos:
> mvn deploy:deploy-file -DgroupId=com.foo -DartifactId=common-dependencies
> -Dversion=1.0 -Dpackaging=pom -Dfile=c:/poms/common-dependencies.xml
> -Durl=http://ourinternalrepos:8080/archiva/repository/internal
> -DrepositoryId=internal  -Dgenerate-pom=true
> 
> How do I get the dependencies included with the pom on the Internal
> repository? I read the docs and it seems like the deploy:deploy-file target
> should be used to install to an Internal repos, while install:install-file
> is for local repos. 

There are two completely separate tasks here:

(1)
Define a custom pom (with your group id) that declares dependencies on a
bunch of other libs, and deploy this to your company's repo. After that,
any project can declare a *dependency* on this pom, and that will cause
it to depend transiently on the libs that pom depends on.

Note that this is not necessarily a good idea. I personally think this
is bad; it hides the real dependencies which will just cause problems in
other ways. For example, if a security bug is discovered in one of those
libs and you need to find out which of your products are actually
vulnerable, then fine-grained dependencies will tell you this; but if
each of your products has a dependency on a whole block of libs even
when it doesn't use them all, then this analysis is impossible.

However if you are determined to do this, then Maven does support it.

(2)
Copy a bunch of libs into your company's repo.

AFAIK, there is no single command that combines the two.

When the libs referenced by the pom are all available via the master
repositories, then (2) is usually not needed. You just allow maven to
fetch the dependencies from the master repositories (possibly via a
caching proxy, to reduce load on the master repository servers, and
improve performance for you). Only if your company has strict security
policies that ban maven from downloading from the master repositories
"on demand" is (2) needed.

Of course, if the libs that your "dependencies" pom are depending on are
not in the master repos (eg if they are developed by your company) then
you do need to upload them. There is nothing in Maven itself that helps
to automate this process. I *think* that some of the "repository
manager" programs around can help, but haven't used any myself.

Regards,
Simon


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