You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2018/04/05 21:58:21 UTC

[1/2] logging-log4j-scala git commit: Add asciidoc plugin fork for rendering managed sources

Repository: logging-log4j-scala
Updated Branches:
  refs/heads/master 2c2fb91d4 -> 1b0d2a303


Add asciidoc plugin fork for rendering managed sources


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/commit/ca9a452d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/tree/ca9a452d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/diff/ca9a452d

Branch: refs/heads/master
Commit: ca9a452d2bb644eb838fe0a6b921c59c8fe5ffe4
Parents: 2c2fb91
Author: Matt Sicker <bo...@gmail.com>
Authored: Thu Apr 5 16:54:40 2018 -0500
Committer: Matt Sicker <bo...@gmail.com>
Committed: Thu Apr 5 16:57:27 2018 -0500

----------------------------------------------------------------------
 LICENSE.txt                  | 30 ++++++++++++++
 NOTICE.txt                   |  6 ++-
 project/AsciidocPlugin.scala | 85 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 120 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/ca9a452d/LICENSE.txt
----------------------------------------------------------------------
diff --git a/LICENSE.txt b/LICENSE.txt
index 6279e52..d9e61e8 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -200,3 +200,33 @@
    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.
+
+------------------------------------------------------------------------------
+
+AsciidocPlugin.scala:
+
+Copyright (c) 2008, 2009, 2010, 2011 Josh Suereth, Steven Blundy, Josh Cough,
+Mark Harrah, Stuart Roebuck, Tony Sloane, Vesa Vilhonen, Jason Zaugg
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. 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.
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.

http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/ca9a452d/NOTICE.txt
----------------------------------------------------------------------
diff --git a/NOTICE.txt b/NOTICE.txt
index 01b7b4b..4441e44 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -1,5 +1,9 @@
-Apache Log4j
+Apache Log4j Scala API
 Copyright 2016-2018 Apache Software Foundation
 
 This product includes software developed at
 The Apache Software Foundation (http://www.apache.org/).
+
+AsciidocPlugin.scala
+Copyright (c) 2008, 2009, 2010, 2011 Josh Suereth, Steven Blundy, Josh Cough,
+Mark Harrah, Stuart Roebuck, Tony Sloane, Vesa Vilhonen, Jason Zaugg

http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/ca9a452d/project/AsciidocPlugin.scala
----------------------------------------------------------------------
diff --git a/project/AsciidocPlugin.scala b/project/AsciidocPlugin.scala
new file mode 100644
index 0000000..0ed5ac7
--- /dev/null
+++ b/project/AsciidocPlugin.scala
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * 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.
+ */
+import java.util
+
+import com.typesafe.sbt.site.SitePlugin
+import com.typesafe.sbt.site.SitePlugin.autoImport.siteSubdirName
+import com.typesafe.sbt.site.util.SiteHelpers
+import org.asciidoctor.Asciidoctor.Factory
+import org.asciidoctor.{DirectoryWalker, Options, SafeMode}
+import sbt.Keys._
+import sbt._
+
+import scala.collection.JavaConverters._
+
+/** Asciidoctor generator. */
+object AsciidocPlugin extends AutoPlugin {
+  override lazy val requires = SitePlugin
+  override lazy val trigger = allRequirements
+
+  object autoImport {
+    val Asciidoc = config("asciidoctor")
+    val siteProperties = settingKey[Seq[(String, AnyRef)]]("Properties to filter through asciidoc")
+  }
+
+  import autoImport._
+
+  override def projectSettings = asciidoctorSettings(Asciidoc)
+
+  /** Creates settings necessary for running Asciidoctor in the given configuration. */
+  def asciidoctorSettings(config: Configuration): Seq[Setting[_]] =
+    inConfig(config)(
+      Seq(
+        includeFilter := AllPassFilter,
+        unmanagedSources := (sourceDirectory.value ** "*.adoc").get,
+        managedSources := Seq(),
+        sources := unmanagedSources.value ++ managedSources.value,
+        siteProperties := Seq("project-version" -> version.value),
+        mappings := generate(sources.value, target.value, includeFilter.value, siteProperties.value),
+        siteSubdirName := ""
+      )
+    ) ++
+      SiteHelpers.directorySettings(config) ++
+      SiteHelpers.watchSettings(config) ++
+      SiteHelpers.addMappingsToSiteDir(mappings in config, siteSubdirName in config)
+
+  /** Run asciidoctor in new ClassLoader. */
+  private def generate(inputs: Seq[File], outputDirectory: File, includeFilter: FileFilter, props: Seq[(String, AnyRef)])
+  : Seq[(File, String)] = {
+    val oldContextClassLoader = Thread.currentThread().getContextClassLoader
+    Thread.currentThread().setContextClassLoader(this.getClass.getClassLoader)
+    try {
+      val asciidoctor = Factory.create()
+      if (!outputDirectory.exists()) outputDirectory.mkdirs()
+      val options = new Options
+      options.setToDir(outputDirectory.getAbsolutePath)
+      options.setDestinationDir(outputDirectory.getAbsolutePath)
+      options.setSafe(SafeMode.UNSAFE)
+      // need to do this explicitly through HashMap because otherwise JRuby complains
+      val attributes = new util.HashMap[String, AnyRef]
+      for ((key, value) <- props) attributes.put(key, value)
+      options.setAttributes(attributes)
+      val walker = new DirectoryWalker {
+        override def scan(): util.List[File] = inputs.asJava
+      }
+      asciidoctor.renderDirectory(walker, options)
+    } finally {
+      Thread.currentThread().setContextClassLoader(oldContextClassLoader)
+    }
+    outputDirectory ** includeFilter --- outputDirectory pair Path.relativeTo(outputDirectory)
+  }
+}
\ No newline at end of file


[2/2] logging-log4j-scala git commit: Add rat report to site output

Posted by ma...@apache.org.
Add rat report to site output


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/commit/1b0d2a30
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/tree/1b0d2a30
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/diff/1b0d2a30

Branch: refs/heads/master
Commit: 1b0d2a303a4b33b31edbcc38527de091d832c787
Parents: ca9a452
Author: Matt Sicker <bo...@gmail.com>
Authored: Thu Apr 5 16:58:13 2018 -0500
Committer: Matt Sicker <bo...@gmail.com>
Committed: Thu Apr 5 16:58:13 2018 -0500

----------------------------------------------------------------------
 build.sbt                         | 44 +++++++++++++++++--------------
 project/CopyResourcesPlugin.scala | 48 ----------------------------------
 project/plugins.sbt               |  4 ++-
 src/asciidoctor/index.adoc        |  3 ++-
 4 files changed, 29 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/1b0d2a30/build.sbt
----------------------------------------------------------------------
diff --git a/build.sbt b/build.sbt
index 722267f..130f45b 100644
--- a/build.sbt
+++ b/build.sbt
@@ -14,10 +14,9 @@
  * See the license for the specific language governing permissions and
  * limitations under the license.
  */
-import Dependencies._
-import OsgiKeys._
 
-enablePlugins(org.apache.logging.log4j.scala.sbt.copyresources.CopyResourcesPlugin)
+import Dependencies._
+import com.typesafe.sbt.osgi.SbtOsgi.autoImport.OsgiKeys._
 
 lazy val metadataSettings = Seq(
   organization := "org.apache.logging.log4j",
@@ -75,17 +74,20 @@ lazy val publishSettings = Seq(
   updateOptions := updateOptions.value.withGigahorse(false)
 )
 
-lazy val packagingSettings = Seq(
-  extraResources := Seq(
-    (baseDirectory.value / "LICENSE.txt", "META-INF/LICENSE"),
-    (baseDirectory.value / "NOTICE.txt", "META-INF/NOTICE")
-  ),
-  unmanagedSources in Compile := {
-    val Some((_, minor)) = CrossVersion.partialVersion(scalaVersion.value)
-    val extras = if (minor > 10) ((sourceDirectory.value / "main" / "scala-2.11+") ** "*.scala").get else Nil
-    (unmanagedSources in Compile).value ++ extras
-  }
-)
+lazy val licensePackagingSettings =
+  for (task <- Seq(packageBin, packageSrc, packageDoc)) yield
+    mappings in (Compile, task) ++= Seq(
+      (baseDirectory.value / "LICENSE.txt", "META-INF/LICENSE"),
+      (baseDirectory.value / "NOTICE.txt", "META-INF/NOTICE")
+    )
+
+lazy val sourceSettings = Seq(
+    unmanagedSources in Compile := {
+      val Some((_, minor)) = CrossVersion.partialVersion(scalaVersion.value)
+      val extras = if (minor > 10) ((sourceDirectory.value / "main" / "scala-2.11+") ** "*.scala").get else Nil
+      (unmanagedSources in Compile).value ++ extras
+    }
+  )
 
 lazy val releaseSettings = Seq(
   releaseCrossBuild := true
@@ -93,7 +95,11 @@ lazy val releaseSettings = Seq(
 
 lazy val siteSettings = Seq(
   apiURL := Some(url(s"https://logging.apache.org/log4j/scala/api/${version.value}/")),
-  siteSubdirName in SiteScaladoc := s"api/${version.value}"
+  siteSubdirName in SiteScaladoc := s"api/${version.value}",
+  managedSources in Asciidoc += {
+    (auditReport in Compile).value
+    (target in Compile).value / "rat.adoc"
+  }
 )
 
 lazy val apiDependencies = Seq(
@@ -115,18 +121,16 @@ lazy val bundleSettings = osgiSettings ++ Seq(
 
 lazy val root = (project in file("."))
   .settings(name := "log4j-api-scala")
+  .enablePlugins(AsciidocPlugin, SiteScaladocPlugin, SbtOsgi, Distributions)
   .settings(metadataSettings: _*)
   .settings(compileSettings: _*)
   .settings(publishSettings: _*)
-  .settings(packagingSettings: _*)
+  .settings(licensePackagingSettings: _*)
+  .settings(sourceSettings: _*)
   .settings(releaseSettings: _*)
   .settings(siteSettings: _*)
   .settings(apiDependencies: _*)
-  .enablePlugins(AsciidoctorPlugin)
-  .enablePlugins(SiteScaladocPlugin)
-  .enablePlugins(SbtOsgi)
   .settings(bundleSettings: _*)
-  .enablePlugins(Distributions)
 
 lazy val nopublish = Seq(
   publish := {},

http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/1b0d2a30/project/CopyResourcesPlugin.scala
----------------------------------------------------------------------
diff --git a/project/CopyResourcesPlugin.scala b/project/CopyResourcesPlugin.scala
deleted file mode 100644
index 1f62257..0000000
--- a/project/CopyResourcesPlugin.scala
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * 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.
- */
-package org.apache.logging.log4j.scala.sbt.copyresources
-
-import sbt.Keys._
-import sbt._
-
-/**
-  * Simple SBT plugin to copy in configured files into all output jars.
-  */
-object CopyResourcesPlugin extends AutoPlugin {
-
-  object autoImport {
-    val extraResources = taskKey[Seq[(File, String)]]("Additional files to copy into packages")
-
-    lazy val baseCopyResourceSettings: Seq[Setting[_]] = Seq(
-      extraResources := Nil
-    ) ++ addExtraResourcesInAll(Compile)(packageBin, packageSrc, packageDoc)
-
-    def addExtraResourcesIn(configuration: Configuration, task: ScopedTaskable[File]): Setting[Task[Seq[(File, String)]]] =
-      mappings in (configuration, task) ++= extraResources.value
-
-    def addExtraResourcesInAll(configurations: Configuration*)(tasks: ScopedTaskable[File]*): Seq[Setting[Task[Seq[(File, String)]]]] =
-      for {
-        configuration <- configurations
-        scope <- tasks
-      } yield addExtraResourcesIn(configuration, scope)
-  }
-
-  import autoImport._
-
-  override lazy val projectSettings: Seq[Setting[_]] = baseCopyResourceSettings
-
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/1b0d2a30/project/plugins.sbt
----------------------------------------------------------------------
diff --git a/project/plugins.sbt b/project/plugins.sbt
index 2b5dba0..fedf504 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -20,4 +20,6 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-license-report" % "1.2.0")
 addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2")
 addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0")
 addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.3")
-addSbtPlugin("org.musigma" % "sbt-rat" % "0.5.0")
+// for quicker resolutions from Maven Central of new releases, uncomment:
+//resolvers += Resolver.sonatypeRepo("public")
+addSbtPlugin("org.musigma" % "sbt-rat" % "0.5.1")

http://git-wip-us.apache.org/repos/asf/logging-log4j-scala/blob/1b0d2a30/src/asciidoctor/index.adoc
----------------------------------------------------------------------
diff --git a/src/asciidoctor/index.adoc b/src/asciidoctor/index.adoc
index 41239dc..b1c80dc 100644
--- a/src/asciidoctor/index.adoc
+++ b/src/asciidoctor/index.adoc
@@ -32,10 +32,11 @@ include::build.adoc[]
 
 include::contributing.adoc[]
 
+include::../../target/rat.adoc[]
+
 ////
 TODO:
 * Apache logo
-* License report
 * Project links
 * Dependency report
 ////
\ No newline at end of file