本文介绍了发布一个Maven神器到本地常春藤库,递归与它的依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组相关性反映到我公司本地常春藤库。

I have to mirror a set of dependencies to my company-local Ivy repository.

我目前需要发布休眠空间4.0-M1 。从我的Eclipse项目,我只能解决常春藤依赖关系如果我启用远程仓库< ibiblio上的名字=休眠空间m2compatible =真正的根=htt​​p://www.hibernatespatial.org/库/> (和排除 dependencies.xml 几个依赖关系),这因为他们从LAN只能检索其他开发人员不必

I currently need to publish Hibernate Spatial 4.0-M1. From my Eclipse project, I can only resolve Ivy dependencies if I enable remote repository <ibiblio name="hibernate-spatial" m2compatible="true" root="http://www.hibernatespatial.org/repository"/> (and exclude a few dependencies from dependencies.xml), which other developers don't have as they retrieve only from LAN.

所以,我最终把JAR到发布目录,使用适当的Ant任务HS官方POM转换为Ivy和我结束了以下 dependencies.xml

So I ended up putting the JAR into the publish directory, convert the HS official POM to Ivy using a proper Ant task and I ended up with the following dependencies.xml

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="1.0" xmlns:m="http://ant.apache.org/ivy/maven">
    <info organisation="org.hibernate"
        module="hibernate-spatial"
        revision="4.0-M1"
        status="release"
        publication="20130904175525"
    >
        <description homepage="" />
    </info>
    <configurations>
        <conf name="default" visibility="public" description="runtime dependencies and master artifact can be used with this conf" extends="runtime,master"/>
        <conf name="master" visibility="public" description="contains only the artifact published by this module itself, with no transitive dependencies"/>
        <conf name="compile" visibility="public" description="this is the default scope, used if none is specified. Compile dependencies are available in all classpaths."/>
        <conf name="provided" visibility="public" description="this is much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive."/>
        <conf name="runtime" visibility="public" description="this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath." extends="compile"/>
        <conf name="test" visibility="private" description="this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases." extends="runtime"/>
        <conf name="system" visibility="public" description="this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository."/>
        <conf name="sources" visibility="public" description="this configuration contains the source artifact of this module, if any."/>
        <conf name="javadoc" visibility="public" description="this configuration contains the javadoc artifact of this module, if any."/>
        <conf name="optional" visibility="public" description="contains all optional dependencies"/>
    </configurations>
    <publications>
        <artifact name="hibernate-spatial" type="jar" ext="jar" conf="compile"/>
    </publications>
    <dependencies>
        <dependency org="jaxen" name="jaxen" rev="1.1" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="junit" name="junit" rev="4.8.2" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="commons-logging" name="commons-logging-api" rev="99.0-does-not-exist" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.1" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="postgresql" name="postgresql" rev="8.4-701.jdbc4" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
        <dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.6.1" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="javax.validation" name="validation-api" rev="1.0.0.GA" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="dom4j" name="dom4j" rev="1.6.1" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
        <!--<dependency org="org.postgis" name="postgis-jdbc" rev="1.5.3" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>-->
        <dependency org="org.hibernate" name="hibernate-validator" rev="4.2.0.Final" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="org.slf4j" name="slf4j-api" rev="1.6.1" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="commons-dbcp" name="commons-dbcp" rev="1.4" force="true" conf="test->runtime(*),master(*)"/>
        <!--<dependency org="org.jboss.logging" name="jboss-logging" rev="3.1.0.CR2" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>-->
        <dependency org="com.fasterxml" name="classmate" rev="0.5.4" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="commons-logging" name="commons-logging" rev="99.0-does-not-exist" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="org.jboss" name="jandex" rev="1.0.3.Final" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="org.hibernate" name="hibernate-core" rev="4.0.0.Final" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
        <dependency org="org.hibernate" name="hibernate-testing" rev="4.0.0.Final" force="true" conf="test->runtime(*),master(*)"/>
        <dependency org="com.vividsolutions" name="jts" rev="1.12" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
        <dependency org="com.h2database" name="h2" rev="1.2.145" force="true" conf="test->runtime(*),master(*)"/>
        <!--<dependency org="javassist" name="javassist" rev="3.12.1.GA" force="true" conf="test->runtime(*),master(*)"/>-->
    </dependencies>
</ivy-module>

我运行下面的Ant任务:

I run the following Ant task:

<target name="ivy-local-release" depends="ivy-config" description="Locally publish a file">
    <ivy:resolve />
    <ivy:publish artifactspattern="${ivy.install.dir}/publish/[artifact]-[revision].[ext]"  resolver="local" status="release" overwrite="true" />
</target>

和我得到下面的输出:

ivy-config:
[ivy:configure] :: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/ ::
[ivy:configure] :: loading settings :: file = C:\Program Files (x86)\Ivy\ivy-settings.xml
ivy-local-release:
[ivy:resolve] :: resolving dependencies :: org.hibernate#hibernate-spatial;4.0-M1
[ivy:resolve]   confs: [default, master, compile, provided, runtime, test, system, sources, javadoc, optional]
[ivy:resolve]   found postgresql#postgresql;8.4-701.jdbc4 in maven2
[ivy:resolve]   found dom4j#dom4j;1.6.1 in local
[ivy:resolve]   found xml-apis#xml-apis;1.0.b2 in maven2
[ivy:resolve]   found org.hibernate#hibernate-core;4.0.0.Final in maven2
[ivy:resolve]   found commons-collections#commons-collections;3.2.1 in local
[ivy:resolve]   found antlr#antlr;2.7.7 in local
[ivy:resolve]   found org.jboss.spec.javax.transaction#jboss-transaction-api_1.1_spec;1.0.0.Final in local
[ivy:resolve]   found org.hibernate.javax.persistence#hibernate-jpa-2.0-api;1.0.1.Final in maven2
[ivy:resolve]   found org.jboss.logging#jboss-logging;3.1.0.CR2 in maven2

[...]

[ivy:resolve]   ==== jboss: tried
[ivy:resolve]     https://repository.jboss.org/nexus/content/repositories/releases/gnu-getopt/getopt/1.0.13/getopt-1.0.13.pom
[ivy:resolve]     -- artifact gnu-getopt#getopt;1.0.13!getopt.jar:
[ivy:resolve]     https://repository.jboss.org/nexus/content/repositories/releases/gnu-getopt/getopt/1.0.13/getopt-1.0.13.jar
[ivy:resolve]   ==== shared: tried
[ivy:resolve]     R:/repository/gnu-getopt/getopt/1.0.13/ivys/ivy.xml
[ivy:resolve]     -- artifact gnu-getopt#getopt;1.0.13!getopt.jar:
[ivy:resolve]     R:/repository/gnu-getopt/getopt/1.0.13/jars/getopt.jar
[ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve]       ::          UNRESOLVED DEPENDENCIES         ::
[ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve]       :: commons-logging#commons-logging-api;99.0-does-not-exist: not found
[ivy:resolve]       :: commons-logging#commons-logging;99.0-does-not-exist: not found
[ivy:resolve]       :: commons-httpclient#commons-httpclient;3.1-jbossorg-1: not found
[ivy:resolve]       :: org.hornetq#hornetq-core;working@antonioanzivino: not found
[ivy:resolve]       :: org.jboss.netty#netty;working@antonioanzivino: not found
[ivy:resolve]       :: jacorb#jacorb;2.3.1jboss.patch01-brew: not found
[ivy:resolve]       :: jacorb#idl;2.3.1jboss.patch01-brew: not found
[ivy:resolve]       :: org.jboss.logmanager#jboss-logmanager;working@antonioanzivino: not found
[ivy:resolve]       :: org.jboss.integration#jboss-transaction-spi;working@antonioanzivino: not found
[ivy:resolve]       :: org.jboss.spec.javax.ejb#jboss-ejb-api_3.1_spec;working@antonioanzivino: not found
[ivy:resolve]       :: org.jboss.spec.javax.servlet#jboss-servlet-api_3.0_spec;working@antonioanzivino: not found
[ivy:resolve]       :: ${project.parent.groupId}#jboss-logging-generator;1.0.0.Beta6: not found
[ivy:resolve]       :: org.jboss.ws#jbossws-api;1.0.0-SNAPSHOT: not found
[ivy:resolve]       :: gnu-getopt#getopt;1.0.13: not found
[ivy:resolve]       ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve]
[ivy:resolve]
[ivy:resolve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS

BUILD FAILED

我用下面的解析器配置在我的常春藤的settings.xml

    <resolvers>
    <filesystem name="shared" >
        <ivy pattern="${ivy.shared.default.root}/${ivy.shared.default.ivy.pattern}" />
        <artifact pattern="${ivy.shared.default.root}/${ivy.shared.default.artifact.pattern}" />
    </filesystem>
    <ibiblio name="maven2" m2compatible="true"/>
    <ibiblio name="geotools" m2compatible="true" root="http://download.osgeo.org/webdav/geotools"/>
    <ibiblio name="hibernate-spatial" m2compatible="true" root="http://www.hibernatespatial.org/repository"/>
    <ibiblio name="jboss" m2compatible="true" root="https://repository.jboss.org/nexus/content/repositories/releases/"/>
    <ibiblio name="mavenjava" m2compatible="true" root="http://download.java.net/maven/2" />
</resolvers>
<resolvers>
    <chain name="default" returnFirst="false">
        <resolver ref="local" />
        <resolver ref="maven2" />
        <resolver ref="geotools" />
        <resolver ref="hibernate-spatial" />
        <resolver ref="jboss" />
        <resolver ref="shared" />

    </chain>
</resolvers>

但奇怪的是,我能解决所有的依赖关系,当我运行常春藤:在我的本地项目解析

我想递归地发布当地常春藤库的依赖关系,当我发布一个新的神器。那怎么办?

I would like to recursively publish dependencies on local Ivy repository when I publish a new artifact. How to do that?

推荐答案

是否有常春藤?对内部主机的依赖性更好的选择是设置如 Maven仓库经理。类似Maven中央外部存储库将被自动检索并在本地缓存。

Does it have to ivy? A better option for hosting dependencies internally is to setup a Maven repository manager like Nexus. External repositories like Maven Central will then be retrieved from automatically and cached locally.

如果你决定使用ivy我会推荐看的。

If you're determined to use ivy I would recommend looking at the ivy install task.

这篇关于发布一个Maven神器到本地常春藤库,递归与它的依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 18:23