-
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.
Prefer javadoc.io over sonatype.org for artifacts other than sbt-plugins
- Loading branch information
Showing
5 changed files
with
79 additions
and
9 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 | ||
|
31 changes: 31 additions & 0 deletions
31
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,31 @@ | ||
package com.thoughtworks.sbtApiMappings | ||
|
||
import sbt._ | ||
import com.thoughtworks.Extractor._ | ||
|
||
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("sbtVersion") | ||
} 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
39 changes: 39 additions & 0 deletions
39
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,39 @@ | ||
package com.thoughtworks.sbtApiMappings | ||
|
||
import sbt._ | ||
import com.thoughtworks.Extractor._ | ||
|
||
/** 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 nonSbtModuleID: Attributed[File] => Option[(String, String, String, String)] = { jar => | ||
jar.data.getName match { | ||
case JarBaseNameRegex(baseName) => | ||
for { | ||
moduleID <- jar.get(Keys.moduleID.key) | ||
if moduleID.extraAttributes.contains("sbtVersion") | ||
} yield (baseName, moduleID.organization, moduleID.name, moduleID.revision) | ||
case _ => | ||
None | ||
} | ||
} | ||
|
||
private def sonatypeRule: PartialFunction[Attributed[File], URL] = { | ||
case nonSbtModuleID.extract(baseName, organization, libraryName, revision) => | ||
val organizationPath = organization.replace('.', '/') | ||
url(s"https://oss.sonatype.org/service/local/repositories/public/archive/$organizationPath/$libraryName/$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