Skip to content

Commit f620fe7

Browse files
committed
Create initial project configuration.
1 parent 7b46c37 commit f620fe7

File tree

13 files changed

+356
-2
lines changed

13 files changed

+356
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

.travis.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sudo: false
2+
language: scala
3+
script:
4+
- sbt ++$TRAVIS_SCALA_VERSION root/scalastyle testSuiteJVM/scalastyle testSuiteJVM/test:scalastyle testSuite/scalastyle testSuite/test:scalastyle
5+
- sbt ++$TRAVIS_SCALA_VERSION testSuiteJVM/test
6+
- sbt ++$TRAVIS_SCALA_VERSION testSuite/test
7+
- sbt ++$TRAVIS_SCALA_VERSION 'set scalaJSUseRhino in Global := false' testSuite/test
8+
- sbt ++$TRAVIS_SCALA_VERSION 'set scalaJSUseRhino in Global := false' 'set scalaJSStage in Global := FullOptStage' testSuite/test
9+
- sbt ++$TRAVIS_SCALA_VERSION publishLocal
10+
scala:
11+
- 2.10.6
12+
- 2.11.8
13+
- 2.12.0-M4
14+
jdk:
15+
- oraclejdk8

CONTRIBUTING.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Contributing guidelines
2+
3+
See the [contributing guidelines of Scala.js core](https://github.com/scala-js/scala-js/blob/master/CONTRIBUTING.md).
4+
The same guidelines apply to this repository.
5+
6+
## Very important notice
7+
8+
`scalajs-java-logging` contains a reimplementation of part of the JDK in Scala.js itself.
9+
10+
***To contribute to this code, it is strictly forbidden to even look at the
11+
source code of the Oracle JDK or OpenJDK!***
12+
13+
This is for license considerations: these JDKs are under a GPL-based license,
14+
which is not compatible with our BSD 3-clause license.
15+
16+
The only existing JDK source code that we can look at is the dead Apache
17+
Harmony project.

LICENSE.txt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2015-2016 EPFL
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without modification,
6+
are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
* Neither the name of the EPFL nor the names of its contributors
14+
may be used to endorse or promote products derived from this software
15+
without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1-
# scala-js-java-logging
2-
Scala.js implementation for java.logging
1+
# scalajs-java-logging
2+
3+
[![Build Status](https://travis-ci.org/scala-js/scala-js-java-logging.svg?branch=master)](https://travis-ci.org/scala-js/scala-js-java-logging)
4+
[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-0.6.9.svg)](https://www.scala-js.org/)
5+
6+
`scalajs-java-logging` is a BSD-licensed reimplementation of the `java.logging` API for Scala.js.
7+
It enables this API in Scala.js projects.
8+
9+
## Work in Progress / linking errors
10+
11+
This library is a work in progress.
12+
There are still many classes and methods that have not been implemented yet.
13+
If you use any of those, you will get linking errors.
14+
15+
Feel free to [contribute](./CONTRIBUTING.md) to extend the set of supported
16+
classes and methods!
17+
18+
## License
19+
20+
`scalajs-java-logging` is distributed under the
21+
[BSD 3-Clause license](./LICENSE.txt).
22+
23+
## Contributing
24+
25+
Follow the [contributing guide](./CONTRIBUTING.md).

build.sbt

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import sbt.Keys._
2+
import org.scalajs.sbtplugin.cross.CrossProject
3+
4+
val commonSettings: Seq[Setting[_]] = Seq(
5+
version := "0.0.1-SNAPSHOT",
6+
organization := "org.scala-js",
7+
scalaVersion := "2.11.8",
8+
scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings"),
9+
10+
homepage := Some(url("http://scala-js.org/")),
11+
licenses += ("BSD New",
12+
url("https://github.com/scala-js/scala-js-java-logging/blob/master/LICENSE")),
13+
scmInfo := Some(ScmInfo(
14+
url("https://github.com/scala-js/scala-js-java-logging"),
15+
"scm:git:[email protected]:scala-js/scala-js-java-logging.git",
16+
Some("scm:git:[email protected]:scala-js/scala-js-java-logging.git")))
17+
)
18+
19+
lazy val root: Project = project.in(file(".")).
20+
enablePlugins(ScalaJSPlugin).
21+
settings(commonSettings).
22+
settings(
23+
name := "scalajs-java-logging",
24+
25+
mappings in (Compile, packageBin) ~= {
26+
_.filter(!_._2.endsWith(".class"))
27+
},
28+
exportJars := true,
29+
30+
publishMavenStyle := true,
31+
publishTo := {
32+
val nexus = "https://oss.sonatype.org/"
33+
if (isSnapshot.value)
34+
Some("snapshots" at nexus + "content/repositories/snapshots")
35+
else
36+
Some("releases" at nexus + "service/local/staging/deploy/maven2")
37+
},
38+
pomExtra := (
39+
<developers>
40+
<developer>
41+
<id>sjrd</id>
42+
<name>Sébastien Doeraene</name>
43+
<url>https://github.com/sjrd/</url>
44+
</developer>
45+
<developer>
46+
<id>gzm0</id>
47+
<name>Tobias Schlatter</name>
48+
<url>https://github.com/gzm0/</url>
49+
</developer>
50+
<developer>
51+
<id>nicolasstucki</id>
52+
<name>Nicolas Stucki</name>
53+
<url>https://github.com/nicolasstucki/</url>
54+
</developer>
55+
</developers>
56+
),
57+
pomIncludeRepository := { _ => false }
58+
)
59+
60+
lazy val testSuite = CrossProject(
61+
jvmId = "testSuiteJVM",
62+
jsId = "testSuite",
63+
base = file("testSuite"),
64+
crossType = CrossType.Full
65+
).
66+
jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)).
67+
settings(commonSettings: _*).
68+
settings(
69+
testOptions +=
70+
Tests.Argument(TestFramework("com.novocode.junit.JUnitFramework"), "-v", "-a")
71+
).
72+
jsSettings(
73+
name := "java.logging testSuite on JS"
74+
).
75+
jsConfigure(_.dependsOn(root)).
76+
jvmSettings(
77+
name := "java.logging testSuite on JVM",
78+
libraryDependencies +=
79+
"com.novocode" % "junit-interface" % "0.9" % "test"
80+
)
81+
82+
lazy val testSuiteJS = testSuite.js
83+
lazy val testSuiteJVM = testSuite.jvm

project/build.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=0.13.9

project/build.sbt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.9")
2+
3+
addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "0.8.0")

scalastyle-config.xml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<scalastyle>
2+
<name>Scalastyle configuration for Scala.js</name>
3+
4+
<check level="error" enabled="true" class="org.scalastyle.file.FileTabChecker"/>
5+
<check level="error" enabled="true" class="org.scalastyle.file.WhitespaceEndOfLineChecker"/>
6+
<check level="error" enabled="true" class="org.scalastyle.file.NewLineAtEofChecker"/>
7+
8+
<!--Indentation checker, whilst useful gives false positives on the file headers, so disabled for now-->
9+
<check level="error" enabled="false" class="org.scalastyle.file.IndentationChecker"/>
10+
11+
<!--
12+
Enforce the hard limit on line length, which is 120 characters.
13+
Most of the time the soft limit of 80 characters should be observed, but
14+
we can hardly tell an automated style checker about a soft limit.
15+
-->
16+
<check level="error" enabled="true" class="org.scalastyle.file.FileLineLengthChecker">
17+
<parameters>
18+
<parameter name="maxLineLength"><![CDATA[120]]></parameter>
19+
</parameters>
20+
</check>
21+
22+
<check level="error" enabled="true" class="org.scalastyle.scalariform.RedundantIfChecker"/>
23+
<check level="error" enabled="true" class="org.scalastyle.scalariform.SimplifyBooleanExpressionChecker"/>
24+
25+
<check level="error" enabled="true" class="org.scalastyle.scalariform.UppercaseLChecker"/>
26+
27+
<check level="error" enabled="true" class="org.scalastyle.scalariform.ProcedureDeclarationChecker"/>
28+
29+
<check level="error" enabled="true" class="org.scalastyle.scalariform.ClassNamesChecker">
30+
<parameters>
31+
<parameter name="regex"><![CDATA[^[A-Z][A-Za-z0-9]*$]]></parameter>
32+
</parameters>
33+
</check>
34+
<check level="error" enabled="true" class="org.scalastyle.scalariform.ObjectNamesChecker">
35+
<parameters>
36+
<parameter name="regex"><![CDATA[^[A-Z][A-Za-z0-9]*$]]></parameter>
37+
</parameters>
38+
</check>
39+
<check level="error" enabled="true" class="org.scalastyle.scalariform.PackageObjectNamesChecker">
40+
<parameters>
41+
<parameter name="regex"><![CDATA[^[a-z][A-Za-z]*$]]></parameter>
42+
</parameters>
43+
</check>
44+
45+
<check level="error" enabled="true" class="org.scalastyle.scalariform.EqualsHashCodeChecker"/>
46+
<check level="error" enabled="true" class="org.scalastyle.scalariform.CovariantEqualsChecker"/>
47+
48+
<check level="error" enabled="true" class="org.scalastyle.scalariform.IllegalImportsChecker">
49+
<parameters>
50+
<parameter name="illegalImports"><![CDATA[sun._,java.awt._]]></parameter>
51+
</parameters>
52+
</check>
53+
54+
<check level="error" enabled="true" class="org.scalastyle.scalariform.ReturnChecker"/>
55+
56+
<check level="error" enabled="true" class="org.scalastyle.scalariform.EmptyClassChecker"/>
57+
58+
<!-- Currently too strict, see https://github.com/scalastyle/scalastyle/issues/142 -->
59+
<check level="error" enabled="false" class="org.scalastyle.scalariform.ForBraceChecker"/>
60+
61+
<check level="error" enabled="true" class="org.scalastyle.scalariform.PublicMethodsHaveTypeChecker"/>
62+
63+
<check level="error" enabled="true" class="org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker"/>
64+
<check level="error" enabled="true" class="org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker"/>
65+
66+
<check level="error" enabled="true" class="org.scalastyle.scalariform.DisallowSpaceBeforeTokenChecker">
67+
<parameters>
68+
<parameter name="tokens">COLON, COMMA, RPAREN</parameter>
69+
</parameters>
70+
</check>
71+
<check level="error" enabled="true" class="org.scalastyle.scalariform.DisallowSpaceAfterTokenChecker">
72+
<parameters>
73+
<parameter name="tokens">LPAREN</parameter>
74+
</parameters>
75+
</check>
76+
<check level="error" enabled="true" class="org.scalastyle.scalariform.EnsureSingleSpaceAfterTokenChecker">
77+
<parameters>
78+
<parameter name="tokens">IF, FOR, WHILE, DO, TRY</parameter>
79+
</parameters>
80+
</check>
81+
</scalastyle>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* __ *\
2+
** ________ ___ / / ___ __ ____ Scala.js Test Suite **
3+
** / __/ __// _ | / / / _ | __ / // __/ (c) 2013, LAMP/EPFL **
4+
** __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \ http://scala-js.org/ **
5+
** /____/\___/_/ |_/____/_/ | |__/ /____/ **
6+
** |/____/ **
7+
\* */
8+
package org.scalajs.testsuite.utils
9+
10+
import scala.scalajs.runtime
11+
12+
object Platform {
13+
/** Returns `true` if and only if the code is executing on a JVM.
14+
* Note: Returns `false` when executing on any JS VM.
15+
*/
16+
final val executingInJVM = false
17+
18+
final val executingInJVMOnJDK6 = false
19+
20+
final val executingInJVMOnJDK7OrLower = false
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.scalajs.testsuite.utils
2+
3+
object Platform {
4+
/** Returns `true` if and only if the code is executing on a JVM.
5+
* Note: Returns `false` when executing on any JS VM.
6+
*/
7+
final val executingInJVM = true
8+
9+
def executingInJVMOnJDK6: Boolean = jdkVersion == 6
10+
11+
def executingInJVMOnJDK7OrLower: Boolean = jdkVersion <= 7
12+
13+
private lazy val jdkVersion = {
14+
val v = System.getProperty("java.version")
15+
if (v.startsWith("1.")) Integer.parseInt(v.drop(2).takeWhile(_.isDigit))
16+
else throw new Exception("Unknown java.version format")
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.scalajs.testsuite.javalib.logging
2+
3+
import org.junit.Test
4+
5+
class DummyTest {
6+
@Test def test(): Unit = ()
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package org.scalajs.testsuite.utils
2+
3+
object AssertThrows {
4+
/** Backport implementation of Assert.assertThrows to be used until JUnit 4.13 is
5+
* released. See org.junit.Assert.scala in jUnitRuntime.
6+
*/
7+
private def assertThrowsBackport(expectedThrowable: Class[_ <: Throwable],
8+
runnable: ThrowingRunnable): Unit = {
9+
expectThrowsBackport(expectedThrowable, runnable)
10+
}
11+
12+
/** Backport implementation of Assert.expectThrows to be used until JUnit 4.13 is
13+
* released. See org.junit.Assert.scala in jUnitRuntime.
14+
*/
15+
private def expectThrowsBackport[T <: Throwable](expectedThrowable: Class[T],
16+
runnable: ThrowingRunnable): T = {
17+
try {
18+
runnable.run()
19+
val message =
20+
s"expected ${expectedThrowable.getSimpleName} to be thrown," +
21+
" but nothing was thrown"
22+
throw new AssertionError(message)
23+
} catch {
24+
case actualThrown: Throwable =>
25+
if (expectedThrowable.isInstance(actualThrown)) {
26+
actualThrown.asInstanceOf[T]
27+
} else {
28+
val mismatchMessage = "unexpected exception type thrown;" +
29+
expectedThrowable.getSimpleName + " " + actualThrown.getClass.getSimpleName
30+
31+
val assertionError = new AssertionError(mismatchMessage)
32+
assertionError.initCause(actualThrown)
33+
throw assertionError
34+
}
35+
}
36+
}
37+
38+
/** Backport implementation of Assert.ThrowingRunnable to be used until
39+
* JUnit 4.13 is released. See org.junit.Assert.scala in jUnitRuntime.
40+
*/
41+
private trait ThrowingRunnable {
42+
def run(): Unit
43+
}
44+
45+
private def throwingRunnable(code: => Unit): ThrowingRunnable = {
46+
new ThrowingRunnable {
47+
def run(): Unit = code
48+
}
49+
}
50+
51+
def assertThrows[T <: Throwable, U](expectedThrowable: Class[T], code: => U): Unit =
52+
assertThrowsBackport(expectedThrowable, throwingRunnable(code.asInstanceOf[Unit]))
53+
54+
def expectThrows[T <: Throwable, U](expectedThrowable: Class[T], code: => U): T =
55+
expectThrowsBackport(expectedThrowable, throwingRunnable(code.asInstanceOf[Unit]))
56+
}

0 commit comments

Comments
 (0)