From 4c84b57c4996a1826051d43d130d6f62b0426d45 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Mon, 10 Jun 2024 14:00:51 +0200 Subject: [PATCH] Publish Persistance API+Javadoc to local m2 repository (#10222) --- .github/workflows/enso4igv.yml | 9 +++++ build.sbt | 33 ++++++++++++++++--- .../java/org/enso/persist/Persistable.java | 6 ++-- .../java/org/enso/persist/package-info.java | 18 +++++----- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/.github/workflows/enso4igv.yml b/.github/workflows/enso4igv.yml index a9dd87eea4..2539891ea2 100644 --- a/.github/workflows/enso4igv.yml +++ b/.github/workflows/enso4igv.yml @@ -6,6 +6,7 @@ on: pull_request: branches: [develop] paths: + - ".github/workflows/enso4igv.yml" - "tools/enso4igv/**/*" jobs: @@ -24,6 +25,14 @@ jobs: java-version: ${{ matrix.java }} cache: maven + - uses: graalvm/setup-graalvm@v1 + with: + java-version: "21" + distribution: "graalvm-community" + + - name: Publish to Maven Repository + run: sbt publishM2 + - name: Find out pom & micro versions working-directory: tools/enso4igv run: | diff --git a/build.sbt b/build.sbt index 8cee3a0b83..829d21d758 100644 --- a/build.sbt +++ b/build.sbt @@ -47,6 +47,7 @@ val currentEdition = sys.env.getOrElse( // Note [Stdlib Version] val stdLibVersion = defaultDevEnsoVersion val targetStdlibVersion = ensoVersion +val persistanceVersion = "0.2-SNAPSHOT" // Inspired by https://www.scala-sbt.org/1.x/docs/Howto-Startup.html#How+to+take+an+action+on+startup lazy val startupStateTransition: State => State = { s: State => @@ -96,6 +97,7 @@ Global / onLoad := { ThisBuild / organization := "org.enso" ThisBuild / scalaVersion := scalacVersion +ThisBuild / publish / skip := true /* Tag limiting the concurrent access to tools/simple-library-server in tests. */ @@ -1312,11 +1314,15 @@ lazy val `ydoc-server` = project lazy val `persistance` = (project in file("lib/java/persistance")) .settings( - version := "0.1", + version := persistanceVersion, Test / fork := true, commands += WithDebugCommand.withDebug, frgaalJavaCompilerSetting, annotationProcSetting, + javadocSettings, + publish / skip := false, + autoScalaLibrary := false, + crossPaths := false, Compile / javacOptions := ((Compile / javacOptions).value), inConfig(Compile)(truffleRunOptionsSettings), libraryDependencies ++= Seq( @@ -1330,9 +1336,13 @@ lazy val `persistance` = (project in file("lib/java/persistance")) lazy val `persistance-dsl` = (project in file("lib/java/persistance-dsl")) .settings( - version := "0.1", + version := persistanceVersion, frgaalJavaCompilerSetting, - Compile / javacOptions := ((Compile / javacOptions).value ++ + publish / skip := false, + autoScalaLibrary := false, + crossPaths := false, + javadocSettings, + Compile / compile / javacOptions := ((Compile / compile / javacOptions).value ++ // Only run ServiceProvider processor and ignore those defined in META-INF, thus // fixing incremental compilation setup Seq( @@ -1677,9 +1687,9 @@ lazy val truffleDslSuppressWarnsSetting = Seq( * `(Compile/sourceManaged)` directory, usually pointing to `target/classes/src_managed`. */ lazy val annotationProcSetting = Seq( - Compile / javacOptions ++= Seq( + Compile / compile / javacOptions ++= Seq( "-s", - (Compile / sourceManaged).value.getAbsolutePath, + (Compile / compile / sourceManaged).value.getAbsolutePath, "-Xlint:unchecked" ), Compile / compile := (Compile / compile) @@ -1696,6 +1706,19 @@ lazy val annotationProcSetting = Seq( ) ) +lazy val javadocSettings = Seq( + Compile / doc / javacOptions --= Seq( + "-deprecation", + "-g", + "-Xlint:unchecked", + "-proc:full" + ), + Compile / doc / javacOptions ++= Seq( + "--snippet-path", + (Test / javaSource).value.getAbsolutePath + ) +) + /** A setting to replace javac with Frgaal compiler, allowing to use latest Java features in the code * and still compile down to JDK 17 */ diff --git a/lib/java/persistance/src/main/java/org/enso/persist/Persistable.java b/lib/java/persistance/src/main/java/org/enso/persist/Persistable.java index 33621e9b0f..3e387647b1 100644 --- a/lib/java/persistance/src/main/java/org/enso/persist/Persistable.java +++ b/lib/java/persistance/src/main/java/org/enso/persist/Persistable.java @@ -39,9 +39,9 @@ public @interface Persistable { int id(); /** - * Should the generated code use {@link Persistance.Output#writeInline(Class, T)} or not. By - * default all {@code final} or sealed classes are inlined. Inlining is however not very - * helpful when a single object is shared between multiple other objects. + * Should the generated code use {@link Persistance.Output#writeInline} or not. By default all + * {@code final} or sealed classes are inlined. Inlining is however not very helpful when + * a single object is shared between multiple other objects. * * @return */ diff --git a/lib/java/persistance/src/main/java/org/enso/persist/package-info.java b/lib/java/persistance/src/main/java/org/enso/persist/package-info.java index 6df4d97861..9aae451369 100644 --- a/lib/java/persistance/src/main/java/org/enso/persist/package-info.java +++ b/lib/java/persistance/src/main/java/org/enso/persist/package-info.java @@ -4,33 +4,33 @@ * *

{@snippet file="org/enso/persist/PersistanceTest.java" region="write"} * - *

Use sibling static {@link Persistance#read readO} method to read the byte buffer back into + *

Use sibling static {@link Persistance#read read} method to read the byte buffer back into * their memory representation. * *

{@snippet file="org/enso/persist/PersistanceTest.java" region="read"} * *

Laziness

* - * The major benefit of this framework is the ability to read only the part of the stored graph that + * The major benefit of this framework is the ability to read only a part of the stored graph that * is actually needed. One may {@linkplain Persistance.Input#readReference obtain a reference} to an * object and turn that {@link Persistance.Reference} into actual object later, when needed. * *

Manual Persistance

* * Unlike typical Java serialization (which tries to make things automatic), this framework requires - * one to implement the persistance manually. For each class that one wants to support, one has to - * implement subclass {@link Persistance} and implement its {@link Persistance#writeObject} and - * {@link Persistance#readObject} method. + * one to implement the persistance manually. For each class one wants to serde, one has to + * implement a subclass of {@link Persistance} and implement its {@link Persistance#writeObject} and + * {@link Persistance#readObject} methods. * *

{@snippet file="org/enso/persist/PersistanceTest.java" region="manual"} * *

Semi-automatic Persistance

* * Writing serialization and deserialization implementation manually is a boring, tedious and - * errorprone process. That's why there is a {@link Persistable} annotation and associated - * annotation processor that generates the necessary {@link Persistance} subclass based on the - * "richest" constructor in the class to be persisted. This approach seems to work well for Java - * records and Scala case classes. + * errorprone process. That's why there is a {@link Persistable @Persistable} annotation and + * associated annotation processor that generates the necessary {@link Persistance} subclass based + * on the "richest" constructor in the class to be persisted. This approach seems to work well for + * Java records and Scala case classes. * *

{@snippet file="org/enso/persist/PersistanceTest.java" region="annotation"} */