我的dependencies.xml包含了运行Web应用程序所需的许多包
以下是一些值得注意的片段
<configurations>
<conf name="test" visibility="public" extends="compile" />
<conf name="compile" visibility="public" extends="runtime" />
<conf name="runtime" visibility="public" />
<conf name="provided" visibility="public" />
<conf name="junit" visibility="public" extends="test" />
</configurations>
<publications>
<artifact name="${project.name}" type="jar" ext="jar" conf="compile" />
<artifact name="${project.name}" type="zip" ext="zip" conf="compile"/>
</publications>
<dependencies>
<dependency org="org.hibernate" name="hibernate-core" rev="5.1.3.Final" transitive="false" conf="runtime->*"/>
<dependency org="org.hibernate" name="hibernate-ehcache" rev="5.1.3.Final" transitive="false" conf="runtime->*"/>
<dependency org="org.hibernate.common" name="hibernate-commons-annotations" rev="5.0.1.Final" transitive="false" conf="runtime->*"/>
<dependency org="org.hibernate.javax.persistence" name="hibernate-jpa-2.1-api" rev="1.0.0.Final" transitive="false" conf="runtime->*"/>
<dependency org="org.javassist" name="javassist" rev="3.21.0-GA" transitive="false" conf="runtime->*"/>
<dependency org="org.jboss.logging" name="jboss-logging" rev="3.3.0.Final" transitive="false" conf="runtime->*"/>
<dependency org="javax.transaction" name="jta" rev="1.1" transitive="false" conf="runtime->*"/>
<dependency org="net.sf.ehcache" name="ehcache-core" rev="2.6.11" transitive="false" conf="runtime->*"/>
<dependency org="antlr" name="antlr" rev="2.7.7" transitive="false" conf="runtime->*"/>
<dependency org="org.antlr" name="antlr4-runtime" rev="4.5.2-1" transitive="false" conf="runtime->*"/>
</dependencies>
我有来自javax.transaction的JTA包,它是 required ,用于在Tomcat下运行的应用程序,而 forbidden 用于在WebSphere下运行的应用程序 .
我需要知道如何根据目标平台制作两个不同的WAR文件 . 我不知道如何使用配置,如果是这样的话 .
Ant将为配置 runtime
执行 ivy-retrieve
,并使用从Artifactory下载的jar来构建WAR存档 .
在Ivy解决了这些工件之后,我可以通过删除来手动排除这些jar,但是嘿,我们是很酷的开发人员,我们喜欢以更清洁的方式做事 .
你怎么建议我做一个针对Tomcat的 ivy-retrieve
,包括针对除了它的Websphere的另一个针对JTA?
1 回答
build.xml:构建war文件
以下片段构建了两个war文件:
../demo.war
../demo-websphere.war
神奇的是tomcat检索任务包括两个配置:
build.xml:发布
以下答案包含有关将多个模块工件发布到Maven存储库的更多详细信息
所以我们需要一个目标来生成POM文件:
以及发布构建文件的第二个目标:
请仔细注意可选的“分类器”属性,并注意接下来如何构建常 Spring 藤文件
ivy.xml
这里发生的事情很少 .
1)使配置映射适合您
2)“extends”属性是一个set操作,这意味着编译依赖项自动包含在运行时配置中 .
一个例子是SLF4J libary . 所述SLF4J-API JAR需要时编译代码,其中作为SLF4J-log4j12 jar 包含在log4j的绑定和依赖关系,运行时(和可变)依赖性 .
3)模块中的“主”配置是特殊的,按照惯例,在Maven世界中对应于该模块发布的文件 .
4)"classifier"属性是常 Spring 藤中extra attribute的一个例子 .