首页 文章

从常 Spring 藤检索中排除本地项目

提问于
浏览
2

我有一个多模块 Ant 常 Spring 藤项目 . 项目之间的依赖关系记录在ivy.xml文件中 .

当调用 <ivy:retrieve> 时,它将尝试下载所有依赖项,包括本地项目 .

如何从检索中排除我的本地项目?

或者也许在某种程度上可以使用Filesystem解析器,它将解析为 ${projects.dir}/*/ivy.xml ,有点像IvyDE与工作区解析器一样 .

UPDATE

我想只排除本地项目,但仍然检索它们的传递依赖项 . 我需要复制IvyDE工作区解析器的行为,但在eclipse之外 .

EXAMPLE

鉴于项目结构:

  • 个项目/

  • local.module1 /

  • bin /

  • lib /

  • build.xml

  • ivy.xml

  • <dependency org="local" name="local.module2" />

  • local.module2 /

  • bin /

  • lib /

  • build.xml

  • ivy.xml

  • <dependency org="external" name="library1" />

  • common.xml

  • build.xml

我希望 local.module1 能够检索除本地项目(local.module2)之外的所有传递依赖项(local.module2,external.library1),因此实际上这会留下 external.library1 .

从这里我想构建构建类路径,它包含对本地项目的直接引用和对外部库的jar引用 . 在module1的情况下:

  • ../local.module2/bin

  • lib / external.library1-1.0.jar

如果有人想知道为什么 - 我试图将常 Spring 藤适应现有的构建系统,只需要很少的改变 .

2 回答

  • 0

    ivy.xml 文件中,添加exclude实体 .

    <dependency org="com.vegicorp"   name="flubaster"    
        conf="compile->default"   rev="3.3">
        <exclude org="com.local"/>
    </dependency
    

    这将阻止您在存储本地jar时从“com.local”或您组织的任何内容下载任何内容 .

    (除非你是're talking about the jars for this particular project, and if that'的情况,否则它们根本不应该在你的 ivy.xml 文件中) .

  • 0

    我最近遇到了部分常 Spring 藤集成到遗留项目中的问题,只是为了从maven世界中获取一些传递依赖,同时用ant保留现有的构建过程 . 还必须通过使用假的本地文件系统解析器解析为虚拟jar来避免使用ivy发布项目模块 .

    ivysettings.xml

    <ivysettings>
        <settings defaultResolver="default">
            <property name="local.maven2.dir" value="${user.home}/.m2/repository/" override="false"/>
            <property name="local-project.cache.dir" value="${ivy.settings.dir}/cache" override="false"/>
        </settings>
        <caches resolutionCacheDir="${local-project.cache.dir}" lockStrategy="artifact-lock" useOrigin="true">
            <cache name="local-project" basedir="${local-project.cache.dir}" useOrigin="true"/>
        </caches>
        <resolvers>
            <chain name="default">
                <filesystem name="local-maven-2" m2compatible="true" checkmodified="true" changingPattern=".*SNAPSHOT">
                    <artifact pattern="${local.maven2.dir}/[organisation]/[module]/[revision]/[module]-[revision].[ext]"/>
                    <ivy pattern="${local.maven2.dir}/[organisation]/[module]/[revision]/[module]-[revision].pom"/>
                </filesystem>
                <ibiblio name="central" m2compatible="true"
                         root="http://repo1.maven.org/maven2/"/>
            </chain>
            <filesystem name="local-project" force="true" checkmodified="true" changingPattern=".*" cache="local-project">
                <artifact pattern="${ivy.settings.dir}/dummy.jar"/>
                <ivy pattern="${ivy.settings.dir}/[module]-ivy.xml"/>
            </filesystem>
        </resolvers>
        <modules>
            <module organisation="example.com" resolver="local-project"/>
        </modules>
    </ivysettings>
    

    不得不从 Ant 中排除虚拟 jar ,因为未能找到更好的常 Spring 藤方法:

    <ivy:retrieve pattern="${dependency.export.dir}/[conf]/[artifact](-[revision]).[ext]" type="jar,bundle"/>
        <delete>
            <fileset dir="${dependency.export.dir}">
                <include name="**/*@local-project.jar"/>
            </fileset>
        </delete>
    

    仍在努力寻找方便的方式exclude provided dependencies with ivy .

    如果有人对示例项目源感兴趣,可以在IVY-1443 bug附件中找到它 .

相关问题