-
Notifications
You must be signed in to change notification settings - Fork 883
Add native image builds #358
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
Comments
wow! realy fast formting. in my case I had to pass -H:IncludeResourceBundles=org.openjdk.tools.javac.resources.compiler |
graalvm 19.2.1 #!/usr/bin/env bash
die() {
echo "${@}" 1>&2
exit 1
}
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
jar="core/target/google-java-format-${version}-all-deps.jar"
if [[ ! -f "${jar}" ]]; then
echo "building ${jar}..."
mvn clean verify -DskipTests -pl core -am || die "cannot build ${jar}"
fi
echo "building native image from ${jar}..."
native-image \
-H:+ReportExceptionStackTraces \
-H:+ReportUnsupportedElementsAtRuntime \
-H:+TraceClassInitialization \
-H:IncludeResourceBundles=org.openjdk.tools.javac.resources.compiler \
-H:Class=com.google.googlejavaformat.java.Main \
-H:Name="google-java-format" \
-cp "${jar}" \
--initialize-at-build-time\
--no-fallback \
--no-server
echo "done" |
This is great. Any reason it couldn't be the main distribution format? |
Trying this with Graal CE Java11/20.2.0 + GJF 1.9 I get the following error:
This was the command I used:
|
This is what I did (I'm using GraalVM Enterprise Edition 11-20.2.0 on macOS, should work with Comunity Edition) java --version
java 11.0.8.0.2 2020-07-09 LTS
Java(TM) SE Runtime Environment GraalVM EE 20.2.0 (build 11.0.8.0.2+1-LTS-jvmci-20.2-b03)
Java HotSpot(TM) 64-Bit Server VM GraalVM EE 20.2.0 (build 11.0.8.0.2+1-LTS-jvmci-20.2-b03, mixed mode, sharing) First, I build the mvn clean verify -DskipTests -Dmaven.javadoc.skip=true -pl core -am Then I selected a few projects and created a file
and did the same with few more projects. Then inside
This will create the json files with information for graalvm And finally
Note: remove
I have a script that resumes what I did. #!/usr/bin/env bash
#
# echo -i > all.txt
# find /Users/fsousa/Projects/ipb/gdoc2 -type f -name \*.java >> all.txt
# find /Users/fsousa/Projects/ipb/candidaturas -type f -name \*.java >> all.txt
# find /Users/fsousa/Projects/egoi/te-proxy -type f -name \*.java >> all.txt
# find /Users/fsousa/Projects/code/jetty.project -type f -name \*.java >> all.txt
# mkdir -p core/src/main/resources/META-INF/native-image
# java -agentlib:native-image-agent=config-output-dir=core/src/main/resources/META-INF/native-image -jar core/target/google-java-format-1.10-SNAPSHOT-all-deps.jar @all.txt
die() {
echo "${@}" 1>&2
exit 1
}
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
jar="core/target/google-java-format-${version}-all-deps.jar"
if [[ ! -f "${jar}" ]]; then
echo "building ${jar}..."
mvn clean verify -DskipTests -Dmaven.javadoc.skip=true -pl core -am || die "cannot build ${jar}"
fi
#-H:ConfigurationResourceRoots=META-INF/native-image \
echo "building native image from ${jar}..."
native-image \
-H:+ReportExceptionStackTraces \
-H:+ReportUnsupportedElementsAtRuntime \
-H:+TraceClassInitialization \
-H:ConfigurationFileDirectories=/Users/fsousa/Projects/code/google-java-format/core/src/main/resources/META-INF/native-image \
-H:IncludeResourceBundles=com.sun.tools.javac.resources.javac \
-H:Class=com.google.googlejavaformat.java.Main \
-H:Name="google-java-format" \
-Dgraal.EnterprisePartialUnroll=true \
-cp "${jar}" \
--initialize-at-build-time\
--no-fallback \
--no-server
echo "done" for the command line, I have 2 scripts:
#!/usr/bin/env bash
TMPFILE=$(mktemp)
echo "-i" > ${TMPFILE}
find . -type f -name \*.java >> ${TMPFILE}
google-java-format @${TMPFILE} and #!/usr/bin/env bash
files=$(git diff --name-only|grep \.java$)
[[ -z ${files} ]] || google-java-format -i ${files} I'm using File Watchers plugin for IntelliJ, which formats the current file when the file is saved or format all unsaved files when compiling. Anyway, formating a file is faster than formating with the google plugin, especially when dealing with big files. |
So I followed your and it compiled but I get this error:
This is with the released jar |
It would be awesome to produce a native binary build using graalvm's native-image as part of the release.
native-image seems to work well w/ the current all-deps jar.
The text was updated successfully, but these errors were encountered: