maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff MAURY <jeffma...@jeffmaury.com>
Subject Re: Unmanaged dependency question
Date Sat, 31 May 2014 09:48:16 GMT
The install-file is the way to go and it will be successful as soon as your
work on  your machine.
If you want to distributed setup, then you must upload the JAR to a
repository manager or install it on a shared maven repository and use that
remote maven repository in your POM files

Jeff


On Sat, May 31, 2014 at 4:21 AM, Paul Benedict <pbenedict@apache.org> wrote:

> I understand but you can't achieve this using a project to represent a
> pre-existing jar. Your attempt won't work. The "install-file" command is
> the correct solution; that is how you get it into your local repo without
> downloading it from a remote repo.
> On May 30, 2014 4:36 PM, "Matt Whiteman" <mwhiteman@purelandsupply.com>
> wrote:
>
> > Hi Curtis,
> >
> > I'll take a look at that, thanks! Ideally, I'll eventually be able to
> have
> > an
> > internal Maven repository
> > so that I can do everything right. What I had been trying to do in the
> > meantime
> > is having it set up
> > so that when we set up a new development station, the user can simply
> > clone the
> > Github repo that
> > has these dependency projects and just do 'mvn install' on each one, then
> > build
> > or develop the
> > standalone app(s). Kinda  crude I know, but we're basically just
> starting a
> > software development
> > department, so have to work  with what's available in the short-term. If
> it
> > doesn't work, I can just
> > keep a batch script with the jar  that runs the mvn:install I suppose.
> >
> > Yup Paul, that's exactly what was happening. The jar file deployed into a
> > local
> > repo within the
> > project directory, and put a reference pom file up in the .m2 directory.
> > But as
> > soon as I
> > ran 'mvn install', it built an empty jar file and put that up in the .m2
> > instead. I just wanted to try to
> > have it in a separate project so that from the user's perspective, it
> > would be
> > as close as possible
> > to what the process would be  if we had an actual internal maven repo.
> >
> > Thanks for the suggestions everyone!
> >
> > Matt
> >
> > On May 30, 2014 at 4:49 PM Curtis Rueden <ctrueden@wisc.edu> wrote:
> > > Hi Matt,
> > >
> > > Have you seen this article?
> > >
> >
> http://developer-blog.cloudbees.com/2013/03/playing-trade-offs-with-maven.html
> > >
> > > If you cannot deploy the Microsoft JARs to your own internal Maven
> > > repository, then you could try the non-maven-jar-plugin approach. It is
> > > strongly recommended over the "basedir repository hack" approach that
> you
> > > are using (presumably from
> > > https://devcenter.heroku.com/articles/local-maven-dependencies).
> > >
> > > Regards,
> > > Curtis
> > >
> > >
> > > On Fri, May 30, 2014 at 3:42 PM, Matt Whiteman <
> > mwhiteman@purelandsupply.com
> > > > wrote:
> > >
> > > > Hi,
> > > >
> > > >
> > > >
> > > > This has probably been answered before, but I haven't been able to
> > find the
> > > > answer and I'm hoping someone knows.
> > > >
> > > >
> > > >
> > > > I'm writing several apps that talk to a Microsoft SQL database, so
> I'm
> > > > using
> > > > the Hibernate dependency. Since Microsoft doesn't make the sqljdbc4
> jar
> > > > available on Maven, I've downloaded it, and I'm trying to make it an
> > > > unmanaged dependency in its own standalone project so that I can
> simply
> > > > reference it in other projects' pom files without having to deploy
> the
> > jar
> > > > to each one individually.
> > > >
> > > >
> > > >
> > > > I've followed the instructions for deploying an unmanaged dependency.
> > As I
> > > > am the only developer at my company (at this time), I do not have a
> > > > separate
> > > > Maven server setup. I was hoping to simply deploy the dependency and
> > then
> > > > run 'maven install' so that it copies everything needed into my .m2
> > folder.
> > > > This is my directory setup:
> > > >
> > > >
> > > >
> > > > (This is the project directory for the sqljdbc4 unmanaged dependency)
> > > >
> > > > C:\dev\Github-repos\addons\sqljdbc4
> > > >
> > > > +- pom.xml
> > > >
> > > > +-src
> > > >
> > > > +-repo
> > > >
> > > >
> > > >
> > > > I followed the instructions to use mvn deploy on the local
> sqljdbc4.jar
> > > > file. I am using an artifactId of sqljdbc4, version 4.0, groupId of
> > > > com.microsoft.sqlserver. After deployment, the repo directory does
> > appear
> > > > to
> > > > be correctly populated:
> > > >
> > > >
> > > >
> > > > C:\dev\Github-repos\addons\sqljdbc4
> > > >
> > > > +- pom.xml
> > > >
> > > > +-src
> > > >
> > > > +-repo
> > > >
> > > > +-com
> > > >
> > > > +-microsoft
> > > >
> > > > +-sqlserver
> > > >
> > > > +-sqljdbc4
> > > >
> > > > +-maven-metadata
> > > >
> > > > +-4.0
> > > >
> > > > +-sqljdbc4-4.0.jar
> > > >
> > > > +-sqljdbc4-4.0.pom
> > > >
> > > >
> > > >
> > > > Next, following the instructions, I go back into the pom.xml file and
> > add
> > > > the repository tag, so my pom.xml for this now looks like:
> > > >
> > > >
> > > >
> > > > <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/xsd/maven-4.0.0.xsd
> > > > <
> > > >
> >
> http://maven.apache.org/POM/4.0.0%20http:/maven.apache.org/xsd/maven-4.0.0
> > > > .
> > > > xsd> ">
> > > >
> > > > <modelVersion>4.0.0</modelVersion>
> > > >
> > > > <groupId>com.microsoft.sqlserver</groupId>
> > > >
> > > > <artifactId>sqljdbc4</artifactId>
> > > >
> > > > <version>4.0</version>
> > > >
> > > >
> > > >
> > > > <repositories>
> > > >
> > > > <!--other repositories if any-->
> > > >
> > > > <repository>
> > > >
> > > > <id>project.local</id>
> > > >
> > > > <name>project</name>
> > > >
> > > > <url>file:${project.basedir}/repo</url>
> > > >
> > > > </repository>
> > > >
> > > > </repositories>
> > > >
> > > > </project>
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Now, here is the problem. Since I want to use this as a dependency in
> > other
> > > > projects, I am trying to run 'maven install' so that it will push
> > > > everything
> > > > into my .m2 directory. The maven build is a success. However, the
> > resulting
> > > > sqljdbc4.jar file in the target directory and up in the m2 directory
> is
> > > > only
> > > > 2kb (whereas the original jar file is 571kb, none of the content made
> > it
> > > > in). As a result, projects that use this as a dependency build, but
> > then
> > > > throw a ClassNotFoundException at runtime, because the classes aren't
> > > > there.
> > > >
> > > >
> > > >
> > > > I am building a separate project that uses this as a dependency:
> > > >
> > > >
> > > >
> > > > C:\dev\Github-repos\applications\myapp
> > > >
> > > >
> > > >
> > > > The pom.xml for this project uses the dependency correctly:
> > > >
> > > > <dependency>
> > > >
> > > > <groupId>com.microsoft.sqlserver</groupId>
> > > >
> > > > <artifactId>sqljdbc4</artifactId>
> > > >
> > > > <version>4.0</version>
> > > >
> > > > </dependency>
> > > >
> > > >
> > > >
> > > > I'm even using the maven assembly plugin to ensure a jar is built
> with
> > all
> > > > dependencies packaged in:
> > > >
> > > >
> > > >
> > > > <plugin>
> > > >
> > > >
> > > > <artifactId>maven-assembly-plugin</artifactId>
> > > >
> > > > <configuration>
> > > >
> > > > <descriptorRefs>
> > > >
> > > >
> > > > <descriptorRef>jar-with-dependencies</descriptorRef>
> > > >
> > > > </descriptorRefs>
> > > >
> > > > <archive>
> > > >
> > > > <manifest>
> > > >
> > > > <addClasspath>true</addClasspath>
> > > >
> > > >
> > > > <mainClass>productfeeds.main.ProductFeedDriver</mainClass>
> > > >
> > > > </manifest>
> > > >
> > > > </archive>
> > > >
> > > > </configuration>
> > > >
> > > > <executions>
> > > >
> > > > <execution>
> > > >
> > > > <phase>package</phase>
> > > >
> > > > <goals>
> > > >
> > > > <goal>single</goal>
> > > >
> > > > </goals>
> > > >
> > > > </execution>
> > > >
> > > > </executions>
> > > >
> > > > </plugin>
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Any ideas what I'm doing wrong? I'm sure it's something really simple
> > I've
> > > > overlooked. If I don't make this a standalone dependency, and simply
> > use
> > > > 'mvn install:install-file -Dfile=sqljdbc4.jar
> > > > -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0
> > > > -Dpackaging=jar ', then everything works fine.
> > > >
> > > >
> > > >
> > > > Thanks,
> > > >
> > > >
> > > >
> > > > Matt
> > > >
> > > >
> > > >
> > > >
>



-- 
Jeff MAURY


"Legacy code" often differs from its suggested alternative by actually
working and scaling.
 - Bjarne Stroustrup

http://www.jeffmaury.com
http://riadiscuss.jeffmaury.com
http://www.twitter.com/jeffmaury

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message