Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't try to automatically detect a main artifact when packaging=pom.…

… Fixes #636.

For the rare case where a main artifact is expected, add an explicit jar()
to the dependency declaration.
  • Loading branch information...
commit c5823ad1e7b6ad9d2b79dc5ebc1c90e11cc6f2ed 1 parent a48ee68
@harrah harrah authored
View
10 ivy/src/main/scala/sbt/Ivy.scala
@@ -242,8 +242,14 @@ private object IvySbt
// Technically, this should be applied to module configurations.
// That would require custom subclasses of all resolver types in ConvertResolver (a delegation approach does not work).
// It would be better to get proper support into Ivy.
- override def locate(artifact: IArtifact) =
- if(hasImplicitClassifier(artifact)) null else super.locate(artifact)
+ //
+ // This method is only used by the pom parsing code in Ivy to find artifacts it doesn't know about.
+ // In particular, a) it looks up source and javadoc classifiers b) it looks up a main artifact for packaging="pom"
+ // sbt now provides the update-classifiers or requires explicitly specifying classifiers explicitly
+ // Providing a main artifact for packaging="pom" does not seem to be correct and the lookup can be expensive, so
+ // sbt now requires this artifact to be explicitly declared.
+ override def locate(artifact: IArtifact) = null
+// if(hasImplicitClassifier(artifact)) null else super.locate(artifact)
override def getDependency(dd: DependencyDescriptor, data: ResolveData) =
{
if(data.getOptions.getLog != LogOptions.LOG_QUIET)
View
3  sbt/src/sbt-test/dependency-management/packaging-pom/A.scala
@@ -0,0 +1,3 @@
+class A {
+ val x = classOf[org.apache.velocity.Template]
+}
View
1  sbt/src/sbt-test/dependency-management/packaging-pom/changes/pkgjar.sbt
@@ -0,0 +1 @@
+libraryDependencies += "org.apache.velocity" % "velocity" % "1.7" intransitive()
View
1  sbt/src/sbt-test/dependency-management/packaging-pom/changes/pkgpom-explicit.sbt
@@ -0,0 +1 @@
+libraryDependencies += "org.apache.velocity" % "velocity" % "1.5" intransitive() jar()
View
1  sbt/src/sbt-test/dependency-management/packaging-pom/changes/pkgpom.sbt
@@ -0,0 +1 @@
+libraryDependencies += "org.apache.velocity" % "velocity" % "1.5" intransitive()
View
1  sbt/src/sbt-test/dependency-management/packaging-pom/common.sbt
@@ -0,0 +1 @@
+ivyPaths := new IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
View
16 sbt/src/sbt-test/dependency-management/packaging-pom/test
@@ -0,0 +1,16 @@
+# velocity 1.5, packaging=pom, but has a main jar
+# this verifies that sbt does not retrieve it by default
+$ copy-file changes/pkgpom.sbt dep.sbt
+> reload
+-> compile
+
+# with an explicit jar(), sbt should know about it without
+# needing to ping the repository
+$ copy-file changes/pkgpom-explicit.sbt dep.sbt
+> reload
+> compile
+
+# velocity 1.7, packaging=jar, so this should pull in a main jar as usual
+$ copy-file changes/pkgjar.sbt dep.sbt
+> reload
+> compile
View
1  src/sphinx/Community/ChangeSummary_0.13.0.rst
@@ -13,6 +13,7 @@ Features, fixes, changes with compatibility implications (incomplete, please hel
- Support for plugin configuration in ``project/plugins/`` has been removed. It was deprecated since 0.11.2.
- Dropped support for tab completing the right side of a setting for the ``set`` command. The new task macros make this tab completion obsolete.
- The convention for keys is now camelCase only. Details below.
+- sbt no longer looks for main artifacts for poms with `packaging="pom"`. For details, see the :ref:`relevant Library Management section <packaging-pom>` and gh-636.
Features
--------
View
18 src/sphinx/Detailed-Topics/Library-Management.rst
@@ -5,7 +5,7 @@ Library Management
There's now a :doc:`getting started page </Getting-Started/Library-Dependencies>`
about library management, which you may want to read first.
-*Wiki Maintenance Note:* it would be nice to remove the overlap between
+*Documentation Maintenance Note:* it would be nice to remove the overlap between
this page and the getting started page, leaving this page with the more
advanced topics such as checksums and external Ivy files.
@@ -399,6 +399,22 @@ The default value is:
checksums := Seq("sha1", "md5")
+.. _packaging-pom:
+
+packaging="pom"
+~~~~~~~~~~~~~~~
+
+A pom.xml that has `packaging="pom"` is not supposed to have artifacts.
+However, some published poms have an associated main artifact, so Ivy checks if one exists.
+This check can be time consuming to the point of taking most of the time for `update` on larger projects.
+Therefore, sbt disables this check and requires you to explicitly request the main jar.
+
+For example,
+
+::
+
+ libraryDependencies += "org.apache.velocity" % "velocity" % "1.5" jar()
+
Publishing
~~~~~~~~~~
Please sign in to comment.
Something went wrong with that request. Please try again.