diff --git a/LICENSE b/LICENSE index 03e05768..a69e4190 100644 --- a/LICENSE +++ b/LICENSE @@ -11,3 +11,11 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + +Regarding the use of a piece of code from the sbt-native-packager plugin by Joshua Suereth: + +Copyright (c) 2012, Joshua Suereth All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/build.sbt b/build.sbt index 906990e6..87247220 100644 --- a/build.sbt +++ b/build.sbt @@ -89,7 +89,7 @@ lazy val `sbt-microsites` = (project in file(".")) .settings(addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.4.4")) .settings(addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.0.0")) .settings(addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.4")) - .enablePlugins(JavaServerAppPackaging, UniversalPlugin, JekyllPlugin, AutomateHeaderPlugin) + .enablePlugins(JekyllPlugin, AutomateHeaderPlugin) lazy val docs = (project in file("docs")) .settings(commonSettings: _*) diff --git a/project/plugins.sbt b/project/plugins.sbt index 001ebf8c..1bdf21ed 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,8 @@ -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3") -addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.4.4") -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.0.0") -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.1") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "1.6.0") -addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "0.3.1") +addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.4.4") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.0.0") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.1") +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "1.6.0") +addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "0.3.1") resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven" addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.4") libraryDependencies <+= sbtVersion("org.scala-sbt" % "scripted-plugin" % _) diff --git a/src/main/scala/microsites/MicrositesPlugin.scala b/src/main/scala/microsites/MicrositesPlugin.scala index 01575f51..edcd29a4 100644 --- a/src/main/scala/microsites/MicrositesPlugin.scala +++ b/src/main/scala/microsites/MicrositesPlugin.scala @@ -19,11 +19,6 @@ package microsites import com.typesafe.sbt.SbtGhPages.GhPagesKeys._ import com.typesafe.sbt.SbtGhPages.ghpages import com.typesafe.sbt.SbtGit.git -import com.typesafe.sbt.SbtNativePackager -import com.typesafe.sbt.SbtNativePackager.Universal -import com.typesafe.sbt.packager.MappingsHelper._ -import com.typesafe.sbt.packager.NativePackagerKeys -import com.typesafe.sbt.packager.universal.UniversalPlugin import com.typesafe.sbt.site.SitePlugin.autoImport._ import com.typesafe.sbt.site.jekyll.JekyllPlugin import microsites.domain.MicrositeSettings @@ -33,14 +28,14 @@ import sbt._ import sbt.plugins.IvyPlugin import tut.Plugin._ -object MicrositesPlugin extends AutoPlugin with NativePackagerKeys { +object MicrositesPlugin extends AutoPlugin { object autoImport extends MicrositeKeys import MicrositesPlugin.autoImport._ import com.typesafe.sbt.site.jekyll.JekyllPlugin.autoImport._ - override def requires = IvyPlugin && SbtNativePackager && JekyllPlugin && UniversalPlugin + override def requires = IvyPlugin && JekyllPlugin override def trigger = allRequirements @@ -51,7 +46,7 @@ object MicrositesPlugin extends AutoPlugin with NativePackagerKeys { ghpages.settings ++ Seq( git.remoteRepo := s"git@github.com:${micrositeGithubOwner.value}/${micrositeGithubRepo.value}.git", - mappings in Universal ++= directory("src/main/resources/microsite"), + mappings in Jekyll ++= micrositeHelper.value.directory("src/main/resources/microsite"), sourceDirectory in Jekyll := resourceManaged.value / "main" / "jekyll", tutSourceDirectory := sourceDirectory.value / "main" / "tut", tutTargetDirectory := resourceManaged.value / "main" / "jekyll" diff --git a/src/main/scala/microsites/util/MicrositeHelper.scala b/src/main/scala/microsites/util/MicrositeHelper.scala index aba99110..744f3d7d 100644 --- a/src/main/scala/microsites/util/MicrositeHelper.scala +++ b/src/main/scala/microsites/util/MicrositeHelper.scala @@ -16,6 +16,8 @@ package microsites.util +import java.io.File + import microsites.domain.MicrositeSettings import microsites.layouts._ import microsites.util.FileHelper._ @@ -111,4 +113,17 @@ class MicrositeHelper(config: MicrositeSettings) { copyFilesRecursively(s"${sourceDir.getAbsolutePath}/_config.yml", targetFile.getAbsolutePath) } + + /* + * This method has been extracted from the sbt-native-packager plugin: + * + * https://github.com/sbt/sbt-native-packager/blob/b5e2bb9027d08c00420476e6be0d876cf350963a/src/main/scala/com/typesafe/sbt/packager/MappingsHelper.scala#L21 + * + */ + def directory(sourceDirPath: String): Seq[(File, String)] = { + val sourceDir = file(sourceDirPath) + Option(sourceDir.getParentFile) + .map(parent => sourceDir.*** pair relativeTo(parent)) + .getOrElse(sourceDir.*** pair basic) + } }