-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from ThoughtWorksInc/javadoc.io
Prefer javadoc.io over sonatype.org
- Loading branch information
Showing
5 changed files
with
92 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.* | ||
target/ | ||
|
||
# Files created for deployment | ||
|
32 changes: 32 additions & 0 deletions
32
src/main/scala/com/thoughtworks/sbtApiMappings/JavadocIoApiMappingRule.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.thoughtworks.sbtApiMappings | ||
|
||
import sbt._ | ||
import com.thoughtworks.Extractor._ | ||
import sbt.internal.librarymanagement.mavenint.PomExtraDependencyAttributes | ||
|
||
object JavadocIoApiMappingRule extends AutoPlugin { | ||
|
||
import ApiMappings.autoImport._ | ||
|
||
override def requires = ApiMappings | ||
|
||
override def trigger = allRequirements | ||
|
||
private def nonSbtModuleID: Attributed[File] => Option[(String, String, String)] = { jar => | ||
for { | ||
moduleID <- jar.get(Keys.moduleID.key) | ||
if !moduleID.extraAttributes.contains(PomExtraDependencyAttributes.SbtVersionKey) | ||
} yield (moduleID.organization, moduleID.name, moduleID.revision) | ||
} | ||
|
||
private def javadocIoRule: PartialFunction[Attributed[File], URL] = { | ||
case nonSbtModuleID.extract(organization, libraryName, revision) => | ||
val organizationPath = organization.replace('.', '/') | ||
url(s"https://javadoc.io/page/$organization/$libraryName/$revision/index.html") | ||
} | ||
|
||
override def projectSettings = { | ||
apiMappingRules := apiMappingRules.value.orElse(javadocIoRule) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/scala/com/thoughtworks/sbtApiMappings/SonatypeApiMappingRuleForSbtPlugins.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.thoughtworks.sbtApiMappings | ||
|
||
import sbt._ | ||
import com.thoughtworks.Extractor._ | ||
import sbt.internal.librarymanagement.mavenint.PomExtraDependencyAttributes | ||
|
||
/** Mapping to sonatype.org URL only for artifacts that are not supported by javadoc.io */ | ||
object SonatypeApiMappingRuleForSbtPlugins extends AutoPlugin { | ||
|
||
import ApiMappings.autoImport._ | ||
|
||
override def requires = ApiMappings | ||
|
||
override def trigger = allRequirements | ||
|
||
private val JarBaseNameRegex = """(.*)\.jar""".r | ||
|
||
private def sbtModuleID: Attributed[File] => Option[(String, String, String, String, String, String)] = { jar => | ||
jar.data.getName match { | ||
case JarBaseNameRegex(baseName) => | ||
for { | ||
moduleID <- jar.get(Keys.moduleID.key) | ||
sbtVerion <- moduleID.extraAttributes.get(PomExtraDependencyAttributes.SbtVersionKey) | ||
scalaVerion <- moduleID.extraAttributes.get(PomExtraDependencyAttributes.ScalaVersionKey) | ||
} yield (baseName, moduleID.organization, moduleID.name, moduleID.revision, scalaVerion, sbtVerion) | ||
case _ => | ||
None | ||
} | ||
} | ||
|
||
private def sonatypeRule: PartialFunction[Attributed[File], URL] = { | ||
case sbtModuleID.extract(baseName, organization, libraryName, revision, scalaVersion, sbtVersion) => | ||
val organizationPath = organization.replace('.', '/') | ||
url( | ||
s"https://oss.sonatype.org/service/local/repositories/public/archive/$organizationPath/${libraryName}_${scalaVersion}_${sbtVersion}/$revision/$baseName-javadoc.jar/!/index.html") | ||
} | ||
|
||
override def projectSettings = { | ||
apiMappingRules := apiMappingRules.value.orElse(sonatypeRule) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters