You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Damon Rand <da...@gmail.com> on 2007/05/30 19:19:34 UTC

Publishing a jar without a compilation step

Hi,

I've spent all afternoon working on this but am stuck.. I am building
several wars that all depend on the same set of 3rd party jar files. I
could write a batch file to install the jars to my local repos and
then copy and paste the list of dependencies into each war. But what I
really want is to be able to depend on a single mydependencies/pom.xml
project instead. I tried getting maven to install my jars using the
systemPath variable like this but it didn't work.

<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">
	<parent>
		<groupId>com.xyz</groupId>
		<artifactId>abc-parent</artifactId>
		<version>3.5.1-SNAPSHOT</version>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<artifactId>mydependencies</artifactId>
	<packaging>jar</packaging>
	<name>mydependencies</name>
	<build></build>
	<dependencies>
		<dependency>
			<groupId>com.xyz</groupId>
			<artifactId>abc</artifactId>
			<version>3.5.1</version>
			<scope>system</scope>
			<systemPath>${basedir}/lib/abc.jar</systemPath>
		</dependency>
	</dependencies>
</project>

I've read all about dependencyManagement and installing 3rd party jars
but its just not clicking..


Regards,
Damon.

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


Re: Publishing a jar without a compilation step

Posted by Jo Vandermeeren <jo...@gmail.com>.
Hi Damon,

First thing. If the 3rd party jars are not available in repositories, there
is no other solution than installing them in your repository manually and
generate/create a POM for them. Nothing to do about that.
You don't install a 3rd party jar by creating a new maven project for them
and trying to build it, but by executing the following command for each of
the jars you want to install:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=jar
-DgeneratePom=true


Next. The term "dependency management" has nothing to do with installing
dependencies in your repository.
It is used by a parent project to define default dependency details at a
top-level. This makes defining dependencies for its child projects (modules)
easier and helps to keep their dependency versions in line.

Finally. If you don't like to define a lot of recurring dependencies, there
is a nifty trick you could do:
 - Create a project with packaging set to "pom". Add all recurring
dependencies as dependencies of this project.
 - Install this project by executing "mvn install". Because the type of the
project is "pom", the pom file will be installed in your local repository.
 - In other projects, depend on the previously installed project, and don't
forget to specify its type (pom).

Because of Maven2's transitive dependency resolution, the dependencies of
this project will be injected into the  projects that depend on it.

Cheers
Jo

On 5/30/07, Damon Rand <da...@gmail.com> wrote:
>
> Hi,
>
> I've spent all afternoon working on this but am stuck.. I am building
> several wars that all depend on the same set of 3rd party jar files. I
> could write a batch file to install the jars to my local repos and
> then copy and paste the list of dependencies into each war. But what I
> really want is to be able to depend on a single mydependencies/pom.xml
> project instead. I tried getting maven to install my jars using the
> systemPath variable like this but it didn't work.
>
> <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">
>         <parent>
>                 <groupId>com.xyz</groupId>
>                 <artifactId>abc-parent</artifactId>
>                 <version> 3.5.1-SNAPSHOT</version>
>         </parent>
>         <modelVersion>4.0.0</modelVersion>
>         <artifactId>mydependencies</artifactId>
>         <packaging>jar</packaging>
>         <name>mydependencies</name>
>         <build></build>
>         <dependencies>
>                 <dependency>
>                         <groupId>com.xyz</groupId>
>                         <artifactId>abc</artifactId>
>                         <version>3.5.1</version>
>                         <scope>system</scope>
>                         <systemPath>${basedir}/lib/abc.jar</systemPath>
>                 </dependency>
>         </dependencies>
> </project>
>
> I've read all about dependencyManagement and installing 3rd party jars
> but its just not clicking..
>
>
> Regards,
> Damon.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Publishing a jar without a compilation step

Posted by Jo Vandermeeren <jo...@gmail.com>.
On 5/30/07, Robert Dale <ro...@gmail.com> wrote:
>
> Put the jars in your local repository - system scope should be avoided.
>

Indeed, avoid system scope. It makes your builds irreproducible.

Cheers
Jo

Re: Publishing a jar without a compilation step

Posted by Robert Dale <ro...@gmail.com>.
Put the jars in your local repository - system scope should be avoided.

In your parent pom.xml:

<project>
  <groupId>com.xyz</groupId>
  <artifactId>abc-parent</artifactId>
  ...
  <!-- modules will inherit dependency settings like version and scope -->
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.xyz</groupId>
        <artifactId>abc</artifactId>
        <version>3.5.1</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
  ...
</project>


in your modules' pom.xml:

<project>
  <parent>
    <groupId>com.xyz</groupId>
    <artifactId>abc-parent</artifactId>
  </parent>
  ...
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>
  </dependencies>
  ...
</project>

On 5/30/07, Damon Rand <da...@gmail.com> wrote:
> Hi,
>
> I've spent all afternoon working on this but am stuck.. I am building
> several wars that all depend on the same set of 3rd party jar files. I
> could write a batch file to install the jars to my local repos and
> then copy and paste the list of dependencies into each war. But what I
> really want is to be able to depend on a single mydependencies/pom.xml
> project instead. I tried getting maven to install my jars using the
> systemPath variable like this but it didn't work.
>
> <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">
>         <parent>
>                 <groupId>com.xyz</groupId>
>                 <artifactId>abc-parent</artifactId>
>                 <version>3.5.1-SNAPSHOT</version>
>         </parent>
>         <modelVersion>4.0.0</modelVersion>
>         <artifactId>mydependencies</artifactId>
>         <packaging>jar</packaging>
>         <name>mydependencies</name>
>         <build></build>
>         <dependencies>
>                 <dependency>
>                         <groupId>com.xyz</groupId>
>                         <artifactId>abc</artifactId>
>                         <version>3.5.1</version>
>                         <scope>system</scope>
>                         <systemPath>${basedir}/lib/abc.jar</systemPath>
>                 </dependency>
>         </dependencies>
> </project>
>
> I've read all about dependencyManagement and installing 3rd party jars
> but its just not clicking..
>
>
> Regards,
> Damon.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Robert Dale

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