当我在某个sbt项目上运行sbt publishLocal
时,发现生成的ivy.xml
是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
<info organisation="com.thoughtworks" module="pact-jvm-provider-spring-mvc_2.11" revision="0.1" status="release" publication="20150225152253">
<description>
pact-jvm-provider-spring-mvc
</description>
</info>
<configurations>
<conf name="compile" visibility="public" description=""/>
<conf name="runtime" visibility="public" description="" extends="compile"/>
<conf name="test" visibility="public" description="" extends="runtime"/>
<conf name="provided" visibility="public" description=""/>
<conf name="optional" visibility="public" description=""/>
<conf name="sources" visibility="public" description=""/>
<conf name="docs" visibility="public" description=""/>
<conf name="pom" visibility="public" description=""/>
</configurations>
<publications>
<artifact name="pact-jvm-provider-spring-mvc_2.11" type="pom" ext="pom" conf="pom"/>
<artifact name="pact-jvm-provider-spring-mvc_2.11" type="jar" ext="jar" conf="compile"/>
<artifact name="pact-jvm-provider-spring-mvc_2.11" type="src" ext="jar" conf="sources" e:classifier="sources"/>
<artifact name="pact-jvm-provider-spring-mvc_2.11" type="doc" ext="jar" conf="docs" e:classifier="javadoc"/>
</publications>
<dependencies>
<dependency org="org.scala-lang" name="scala-library" rev="2.11.0" conf="compile->default(compile)"/>
<dependency org="au.com.dius" name="pact-jvm-model_2.11" rev="2.1.11" conf="compile->default(compile)"/>
<dependency org="au.com.dius" name="pact-jvm-consumer-junit_2.11" rev="2.1.10" conf="compile->default(compile)"/>
<dependency org="org.springframework" name="spring-test" rev="4.1.3.RELEASE" conf="compile->default(compile)"/>
<dependency org="org.springframework" name="spring-webmvc" rev="4.1.3.RELEASE" conf="compile->default(compile)"/>
<dependency org="org.springframework" name="spring-context" rev="4.1.3.RELEASE" conf="compile->default(compile)"/>
<dependency org="org.springframework" name="spring-core" rev="4.1.3.RELEASE" conf="compile->default(compile)"/>
<dependency org="junit" name="junit" rev="4.12" conf="compile->default(compile)"/>
<dependency org="javax.servlet" name="javax.servlet-api" rev="3.0.1" conf="compile->default(compile)"/>
<dependency org="org.mockito" name="mockito-core" rev="1.9.5" conf="compile->default(compile)"/>
<dependency org="org.specs2" name="specs2_2.11" rev="2.4.2" conf="test->default(compile)"/>
</dependencies>
</ivy-module>
您可以看到所有依赖项都在使用配置compile
或test
,而不是default
,并且那里没有default
配置。
因此,当我想从另一个项目中使用它时,我必须明确指定compile
配置:
compile group: "com.thoughtworks", name: "pact-jvm-provider-spring-mvc_2.11", version: "0.1", configuration: 'compile'
而不是简单的:
compile "com.reagroup:pact-jvm-provider-spring-mvc_2.11:0.1"
我检查了一些其他库,他们都声明了default
并将其用作默认值。
所以我的问题是为什么sbt publishLocal
会在没有default
配置的情况下生成ivy.xml?