Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Jakarta EE 8 support #53

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 21 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ def getDevelopmentVersion() {


def releaseVersion = System.env.RELEASE_VERSION

version = releaseVersion ? releaseVersion : getDevelopmentVersion()
println "Building version = " + version
group = 'com.graphql-java'

// check if build for Jakarta EE 9
def isJakarta = hasProperty("jakarta") ? true : false
println "Build for Jakarta EE 9? $isJakarta"

if (isJakarta) {
apply from: "jakarta.gradle"
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

Expand All @@ -38,12 +47,14 @@ repositories {
mavenLocal()
}

def versionHibernateValidator = isJakarta ? "7.0.1.Final" : "6.2.0.Final"
def versionJakartaEL = isJakarta ? "4.0.1" : "3.0.4"

dependencies {
compile "com.graphql-java:graphql-java:17.0"
compile "com.graphql-java:graphql-java-extended-scalars:17.0"
compile "org.hibernate.validator:hibernate-validator:7.0.1.Final"
compile "org.glassfish:jakarta.el:4.0.0"
compile "org.hibernate.validator:hibernate-validator:$versionHibernateValidator"
compile "org.glassfish:jakarta.el:$versionJakartaEL"

testCompile 'org.slf4j:slf4j-simple:1.7.31'
testCompile 'org.spockframework:spock-core:1.3-groovy-2.5'
Expand All @@ -60,6 +71,11 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}

jar {
// add jakarta classier for Jakarta EE 9
archiveClassifier = isJakarta ? "jakarta" : ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is emtpy string the default value, or should it be null?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure the default value of the classifier, I think empty string works.

}

artifacts {
archives sourcesJar
archives javadocJar
Expand All @@ -76,7 +92,8 @@ publishing {
maven(MavenPublication) {
from components.java
groupId group
artifactId 'graphql-java-extended-validation'
// use the project name
artifactId "graphql-java-extended-validation"
version version

artifact sourcesJar
Expand All @@ -85,7 +102,7 @@ publishing {
pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name 'graphql-java-extended-validation'
name "graphql-java-extended-validation"
description 'A library fo extended validation for graphql-java'
url 'https://github.com/graphql-java/graphql-java-extended-validation'
inceptionYear '2019'
Expand Down
39 changes: 39 additions & 0 deletions jakarta.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
def generatedSrc = "$buildDir/generated-src";
def generatedTestSrc = "$buildDir/generated-testSrc";
def generatedGroovyTestSrc = "$buildDir/generated-testGroovySrc";

task generateSources() {
println "[jakarta build] replacing `javax.` with new `jakarta.`"
dependsOn("copyJavaSources", "copyTestJavaSources", "copyTestGroovySources")
}

task copyTestGroovySources(type: Copy) {
into generatedGroovyTestSrc
from 'src/test/groovy'
filter { line -> line.replaceAll("javax\\.", "jakarta\\.") }
}

task copyTestJavaSources(type: Copy) {
into generatedTestSrc
from 'src/test/java'
filter { line -> line.replaceAll("javax\\.", "jakarta\\.") }
}

task copyJavaSources(type: Copy) {
into generatedSrc
from 'src/main/java'
filter { line -> line.replaceAll("javax\\.", "jakarta\\.") }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit a funny hack to make it work. I don't mind much personally as this is rather temporary, but are we sure there are no changes between javax and jakarta outside the package name ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure for Java EE 8/Jakarta EE 9 developers there is no difference from the API level between Jakarta EE 8 and Jakarta EE 9, the biggest change is the namespace migrating to new jakarta.

}

println "[jakarta build] set generated source codes as sourceSets"
sourceSets {
main {
java.srcDirs = [generatedSrc]
resources.srcDirs = ["src/main/resources"]
}
test {
java.srcDirs = [generatedTestSrc]
groovy.srcDirs = [generatedGroovyTestSrc]
}
}
compileJava.dependsOn("generateSources")
4 changes: 2 additions & 2 deletions src/main/java/graphql/validation/el/BetterMapELResolver.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package graphql.validation.el;

import graphql.Internal;
import jakarta.el.ELContext;
import jakarta.el.MapELResolver;
import javax.el.ELContext;
import javax.el.MapELResolver;

import java.util.Arrays;
import java.util.List;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/graphql/validation/el/ELSupport.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package graphql.validation.el;

import graphql.Internal;
import jakarta.el.ELContext;
import jakarta.el.ELManager;
import jakarta.el.ExpressionFactory;
import jakarta.el.StandardELContext;
import jakarta.el.ValueExpression;
import javax.el.ELContext;
import javax.el.ELManager;
import javax.el.ExpressionFactory;
import javax.el.StandardELContext;
import javax.el.ValueExpression;
import java.lang.reflect.Method;
import java.util.Locale;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import java.util.MissingResourceException;
import java.util.Optional;
import java.util.ResourceBundle;
import jakarta.validation.Constraint;
import jakarta.validation.Path;
import jakarta.validation.Payload;
import javax.validation.Constraint;
import javax.validation.Path;
import javax.validation.Payload;
import org.hibernate.validator.internal.engine.MessageInterpolatorContext;
import org.hibernate.validator.internal.metadata.core.ConstraintHelper;
import org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl;
Expand Down
16 changes: 8 additions & 8 deletions src/test/groovy/ELDiscover.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import jakarta.el.ELContext;
import jakarta.el.ELManager;
import jakarta.el.ExpressionFactory;
import jakarta.el.StandardELContext;
import jakarta.el.ValueExpression;
import jakarta.validation.MessageInterpolator;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
import javax.el.ELContext;
import javax.el.ELManager;
import javax.el.ExpressionFactory;
import javax.el.StandardELContext;
import javax.el.ValueExpression;
import javax.validation.MessageInterpolator;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.internal.engine.MessageInterpolatorContext;
import org.hibernate.validator.internal.engine.path.PathImpl;
Expand Down