This is an automated email from the ASF dual-hosted git repository.

snazy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 8aa8fc33 Add immutables library (#740)
8aa8fc33 is described below

commit 8aa8fc3355325c58c772646b39a76d6d3399152b
Author: Robert Stupp <[email protected]>
AuthorDate: Tue Jan 14 13:27:01 2025 +0100

    Add immutables library (#740)
    
    This PR introduces the Immutables library:
    
    https://immutables.github.io/
    
    This library is widely used in Iceberg and many other projects. The ability 
to define immutable components in an easy way, without struggling with the 
nitty-gritty details (getters, builders, equals, hashCode, toString, etc.) is a 
nice productivity boost and improves code correctness by enforcing immutability 
by default. Unlike Java records, collections in immutable values are immutable 
as well. Immutable value also have extensive support for builders, which 
removes a lot of manual du [...]
    
    This PR only adds the library, it is effectively a re-incarnation of #282.
---
 gradle/libs.versions.toml                          |  4 +++
 gradle/projects.main.properties                    |  1 +
 tools/immutables/build.gradle.kts                  | 32 ++++++++++++++++++
 .../polaris/immutables/PolarisImmutable.java       | 39 ++++++++++++++++++++++
 .../annotations/org.immutables.value.immutable     | 19 +----------
 .../extensions/org.immutables.inhibit-classpath    | 24 ++++---------
 6 files changed, 83 insertions(+), 36 deletions(-)

diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 0daf5a88..1b3a5970 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -22,6 +22,7 @@ hadoop = "3.4.1"
 iceberg = "1.7.1"
 junit = "5.11.4"
 quarkus = "3.17.6"
+immutables = "2.10.1"
 picocli = "4.7.6"
 slf4j = "2.0.16"
 swagger = "1.6.14"
@@ -54,6 +55,9 @@ hadoop-client-api = { module = 
"org.apache.hadoop:hadoop-client-api", version.re
 hadoop-client-runtime = { module = "org.apache.hadoop:hadoop-client-runtime", 
version.ref = "hadoop" }
 hadoop-common = { module = "org.apache.hadoop:hadoop-common", version.ref = 
"hadoop" }
 hadoop-hdfs-client = { module = "org.apache.hadoop:hadoop-hdfs-client", 
version.ref = "hadoop" }
+immutables-builder = { module = "org.immutables:builder", version.ref = 
"immutables" }
+immutables-value-annotations = { module = "org.immutables:value-annotations", 
version.ref = "immutables" }
+immutables-value-processor = { module = "org.immutables:value-processor", 
version.ref = "immutables" }
 iceberg-bom = { module = "org.apache.iceberg:iceberg-bom", version.ref = 
"iceberg" }
 jackson-bom = { module = "com.fasterxml.jackson:jackson-bom", version = 
"2.18.2" }
 jakarta-annotation-api = { module = 
"jakarta.annotation:jakarta.annotation-api", version = "3.0.0" }
diff --git a/gradle/projects.main.properties b/gradle/projects.main.properties
index 2a6f86a0..a6158793 100644
--- a/gradle/projects.main.properties
+++ b/gradle/projects.main.properties
@@ -29,6 +29,7 @@ polaris-eclipselink=extension/persistence/eclipselink
 polaris-jpa-model=extension/persistence/jpa-model
 polaris-tests=integration-tests
 aggregated-license-report=aggregated-license-report
+polaris-immutables=tools/immutables
 polaris-container-spec-helper=tools/container-spec-helper
 polaris-version=tools/version
 
diff --git a/tools/immutables/build.gradle.kts 
b/tools/immutables/build.gradle.kts
new file mode 100644
index 00000000..67d8a423
--- /dev/null
+++ b/tools/immutables/build.gradle.kts
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+plugins { id("polaris-client") }
+
+val processor by configurations.creating
+
+processor.extendsFrom(configurations.api.get())
+
+dependencies {
+  api(libs.immutables.builder)
+  api(libs.immutables.value.annotations)
+
+  processor(libs.immutables.value.processor)
+  processor(project)
+}
diff --git 
a/tools/immutables/src/main/java/org/apache/polaris/immutables/PolarisImmutable.java
 
b/tools/immutables/src/main/java/org/apache/polaris/immutables/PolarisImmutable.java
new file mode 100644
index 00000000..6a16c98d
--- /dev/null
+++ 
b/tools/immutables/src/main/java/org/apache/polaris/immutables/PolarisImmutable.java
@@ -0,0 +1,39 @@
+/*
+ * 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.polaris.immutables;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+import org.immutables.value.Value;
+
+/**
+ * A <a 
href="http://immutables.github.io/style.html#custom-immutable-annotation";>Custom
+ * {@code @Value.Immutable}</a> with a project-wide common style.
+ */
+@Documented
+@Target(ElementType.TYPE)
[email protected](
+    defaults = @Value.Immutable(lazyhash = true),
+    forceJacksonPropertyNames = false,
+    clearBuilder = true,
+    depluralize = true,
+    toBuilder = "toBuilder",
+    get = {"get*", "is*"})
+public @interface PolarisImmutable {}
diff --git a/gradle/projects.main.properties 
b/tools/immutables/src/main/resources/META-INF/annotations/org.immutables.value.immutable
similarity index 51%
copy from gradle/projects.main.properties
copy to 
tools/immutables/src/main/resources/META-INF/annotations/org.immutables.value.immutable
index 2a6f86a0..3bcf09e4 100644
--- a/gradle/projects.main.properties
+++ 
b/tools/immutables/src/main/resources/META-INF/annotations/org.immutables.value.immutable
@@ -16,22 +16,5 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-#
-
-polaris-core=polaris-core
-polaris-api-iceberg-service=api/iceberg-service
-polaris-api-management-model=api/management-model
-polaris-api-management-service=api/management-service
-polaris-service-common=service/common
-polaris-quarkus-service=quarkus/service
-polaris-quarkus-server=quarkus/server
-polaris-eclipselink=extension/persistence/eclipselink
-polaris-jpa-model=extension/persistence/jpa-model
-polaris-tests=integration-tests
-aggregated-license-report=aggregated-license-report
-polaris-container-spec-helper=tools/container-spec-helper
-polaris-version=tools/version
 
-polaris-config-docs-annotations=tools/config-docs/annotations
-polaris-config-docs-generator=tools/config-docs/generator
-polaris-config-docs-site=tools/config-docs/site
+org.apache.polaris.immutables.PolarisImmutable
diff --git a/gradle/projects.main.properties 
b/tools/immutables/src/main/resources/META-INF/extensions/org.immutables.inhibit-classpath
similarity index 51%
copy from gradle/projects.main.properties
copy to 
tools/immutables/src/main/resources/META-INF/extensions/org.immutables.inhibit-classpath
index 2a6f86a0..f59ae326 100644
--- a/gradle/projects.main.properties
+++ 
b/tools/immutables/src/main/resources/META-INF/extensions/org.immutables.inhibit-classpath
@@ -16,22 +16,10 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-#
-
-polaris-core=polaris-core
-polaris-api-iceberg-service=api/iceberg-service
-polaris-api-management-model=api/management-model
-polaris-api-management-service=api/management-service
-polaris-service-common=service/common
-polaris-quarkus-service=quarkus/service
-polaris-quarkus-server=quarkus/server
-polaris-eclipselink=extension/persistence/eclipselink
-polaris-jpa-model=extension/persistence/jpa-model
-polaris-tests=integration-tests
-aggregated-license-report=aggregated-license-report
-polaris-container-spec-helper=tools/container-spec-helper
-polaris-version=tools/version
 
-polaris-config-docs-annotations=tools/config-docs/annotations
-polaris-config-docs-generator=tools/config-docs/generator
-polaris-config-docs-site=tools/config-docs/site
+javax.annotation.Nullable
+javax.annotation.CheckReturnValue;
+javax.annotation.Nullable;
+javax.annotation.ParametersAreNonnullByDefault;
+javax.annotation.concurrent.Immutable;
+javax.annotation.concurrent.NotThreadSafe;

Reply via email to