Skip to content

Commit

Permalink
Merge branch 'master' into scala-2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
mduerig committed May 15, 2018
2 parents fcb405a + 59be3a0 commit 362b1bb
Show file tree
Hide file tree
Showing 14 changed files with 213 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>michid</groupId>
<artifactId>script-oak-parent_2.11</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.4</version>
<relativePath>./script-oak-parent/pom.xml</relativePath>
</parent>

Expand Down
6 changes: 1 addition & 5 deletions script-oak-core-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@
<parent>
<groupId>michid</groupId>
<artifactId>script-oak-parent_2.11</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.4</version>
<relativePath>../script-oak-parent/pom.xml</relativePath>
</parent>

<artifactId>script-oak-core-test_2.11</artifactId>
<name>Script Oak Core Test</name>

<properties>
<oak.version>1.9.0</oak.version>
</properties>

<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion script-oak-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>michid</groupId>
<artifactId>script-oak-parent_2.11</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.4</version>
<relativePath>../script-oak-parent/pom.xml</relativePath>
</parent>

Expand Down
3 changes: 2 additions & 1 deletion script-oak-fixture-reactor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>michid</groupId>
<artifactId>script-oak-parent_2.11</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.4</version>
<relativePath>../script-oak-parent/pom.xml</relativePath>
</parent>

Expand All @@ -16,5 +16,6 @@
<modules>
<module>script-oak-fixtures</module>
<module>script-oak-1.9.0</module>
<module>script-oak-1.9.1</module>
</modules>
</project>
2 changes: 2 additions & 0 deletions script-oak-fixture-reactor/script-oak-1.9.0/fixture.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
interp.repositories() ++= Seq(coursier.MavenRepository("file://" + java.lang.System.getProperties.get("user.home") + "/.m2/repository/"))
interp.load.ivy(coursier.Dependency("michid"%%"script-oak-1.9.0", "1.3"))
2 changes: 1 addition & 1 deletion script-oak-fixture-reactor/script-oak-1.9.0/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>michid</groupId>
<artifactId>script-oak-parent_2.11</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.4</version>
<relativePath>../../script-oak-parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 2 additions & 0 deletions script-oak-fixture-reactor/script-oak-1.9.1/fixture.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
interp.repositories() ++= Seq(coursier.MavenRepository("file://" + java.lang.System.getProperties.get("user.home") + "/.m2/repository/"))
interp.load.ivy(coursier.Dependency("michid"%%"script-oak-1.9.1", "1.4"))
68 changes: 68 additions & 0 deletions script-oak-fixture-reactor/script-oak-1.9.1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>michid</groupId>
<artifactId>script-oak-parent_2.11</artifactId>
<version>1.4</version>
<relativePath>../../script-oak-parent/pom.xml</relativePath>
</parent>

<artifactId>script-oak-1.9.1_2.11</artifactId>
<name>Script Oak 1.9.1 Fixture</name>

<properties>
<oak.fixture.version>1.9.1</oak.fixture.version>
</properties>

<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>oak-segment-tar</artifactId>
<version>${oak.fixture.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>oak-blob</artifactId>
<version>${oak.fixture.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>oak-blob-plugins</artifactId>
<version>${oak.fixture.version}</version>
</dependency>
<dependency>
<groupId>com.lihaoyi</groupId>
<artifactId>ammonite-ops_2.11</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>michid</groupId>
<artifactId>script-oak-core_2.11</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>oak-tooling-api</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package michid.script.oak.fixture

import java.io.{ByteArrayInputStream, IOException, InputStream}

import org.apache.jackrabbit.oak.spi.blob.{BlobOptions, BlobStore}

/**
* Utility BlobStore implementation to be used in tooling that can work with a
* FileStore without the need of the DataStore being present locally
*/
class BasicReadOnlyBlobStore extends BlobStore {
@throws[IOException]
override def writeBlob(in: InputStream) = throw new UnsupportedOperationException

/**
* Ignores the options provided and delegates to `writeBlob(InputStream)`
*
* @param in the input stream to write
* @param options the options to use
* @return
* @throws IOException
*/
@throws[IOException]
override def writeBlob(in: InputStream, options: BlobOptions): String = writeBlob(in)

@throws[IOException]
override def readBlob(blobId: String, pos: Long, buff: Array[Byte], off: Int, length: Int) = throw new UnsupportedOperationException

@throws[IOException]
override def getBlobLength(blobId: String): Long = { // best effort length extraction
val indexOfSep = blobId.lastIndexOf("#")
if (indexOfSep != -1) java.lang.Long.valueOf(blobId.substring(indexOfSep + 1))
else -1
}

@throws[IOException]
override def getInputStream(blobId: String) = new ByteArrayInputStream(new Array[Byte](0))

override def getBlobId(reference: String): String = reference

override def getReference(blobId: String): String = blobId
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package michid.script.oak

import java.io.Closeable

import ammonite.ops.{Path, pwd}
import michid.script.oak.filestore.FileStoreAnalyser
import org.apache.jackrabbit.oak.plugins.blob.datastore.{DataStoreBlobStore, OakFileDataStore}
import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder
import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder
import org.apache.jackrabbit.oak.segment.file.proc.Proc
import org.apache.jackrabbit.oak.spi.blob.BlobStore
import org.apache.jackrabbit.oak.tooling.filestore.bindings.nodestate.NodeStateBackedSegmentStore

import scala.util.Random

/** Common predefs used by script-oak */
package object fixture {

/** A blob store that actually ignores the binaries. Useful if the blob store is not available */
val dummyBlobStore: BlobStore = new BasicReadOnlyBlobStore

/** A plain file store builder that can be customised and passed to pass to fileStoreAnalyser */
val plainFileStoreBuilder: Path => FileStoreBuilder =
path => fileStoreBuilder(path.toNIO.toFile)

/** A customised file store builder, which configures a dummyBlobStore */
val dummyBlobStoreBuilder: Path => FileStoreBuilder =
plainFileStoreBuilder(_).withBlobStore(dummyBlobStore)

/** A file data store based blob store */
def newBlobStore(directory: Path): BlobStore = {
val delegate = new OakFileDataStore
delegate.setPath(directory.toString)
delegate.init(null)
new DataStoreBlobStore(delegate)
}

/** Create a new file store analyser. If no data store exists at the given path the
* segment store is created without an external data store unless one is specified
* within the passed builder. */
def fileStoreAnalyser(
segmentStoreDirectory: Path = pwd / "segmentstore",
dataStoreDirectory: Path = pwd / "datastore",
readOnly: Boolean = true,
builder: Path => FileStoreBuilder = plainFileStoreBuilder)
: FileStoreAnalyser = {
val fileStoreBuilder = builder(segmentStoreDirectory)
if (dataStoreDirectory.toIO.exists())
fileStoreBuilder.withBlobStore(newBlobStore(dataStoreDirectory))

val fileStore = if (readOnly)
fileStoreBuilder.buildReadOnly() else
fileStoreBuilder.build()

val store = NodeStateBackedSegmentStore.newSegmentStore(
Proc.of(fileStoreBuilder.buildProcBackend(fileStore)))
new FileStoreAnalyser(store) with Closeable {
override def close(): Unit = {
super.close()
fileStore.close()
}
}
}

object EmptyFileStore {
def path: Path = {
val path = pwd / "target" / Random.nextInt(1000000).toString / "segmentstore"
plainFileStoreBuilder(path).build().close()
path
}
}
}
2 changes: 1 addition & 1 deletion script-oak-fixture-reactor/script-oak-fixtures/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>michid</groupId>
<artifactId>script-oak-parent_2.11</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.4</version>
<relativePath>../../script-oak-parent/pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ package object fixtures {
}

val oakFixtures: Map[String, OakFixture] = Map(
oak_1_9_0.oakVersion -> oak_1_9_0
oak_1_9_0.oakVersion -> oak_1_9_0,
oak_1_9_1.oakVersion -> oak_1_9_1
)

val latest: OakFixture = oak_1_9_0
val latest: OakFixture = oak_1_9_1

object oak_1_9_0 extends OakFixture {
val oakVersion = "oak-1.9.0"
Expand All @@ -50,4 +51,19 @@ package object fixtures {
|""").stripMargin
}

object oak_1_9_1 extends OakFixture {
val oakVersion = "oak-1.9.1"

override def toString: String = oakVersion

// michid .m2 resolve should be there by default
val predef: String = ("""
|interp.repositories() ++= Seq(coursier.MavenRepository("file://" + java.lang.System.getProperties.get("user.home") + "/.m2/repository/"))
|interp.load.ivy(coursier.Dependency("michid"%%"script-""" + oakVersion + """", """" + scriptOakVersion + """"))
|@
|import michid.script.oak._
|import michid.script.oak.fixture._
|""").stripMargin
}

}
2 changes: 1 addition & 1 deletion script-oak-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>michid</groupId>
<artifactId>script-oak-parent_2.11</artifactId>
<name>Script Oak Parent POM</name>
<version>1.4-SNAPSHOT</version>
<version>1.4</version>
<packaging>pom</packaging>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion script-oak-shell/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>michid</groupId>
<artifactId>script-oak-parent_2.11</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.4</version>
<relativePath>../script-oak-parent/pom.xml</relativePath>
</parent>

Expand Down

0 comments on commit 362b1bb

Please sign in to comment.