forked from OpenFeign/feign
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a test that compile native using graalVM
- Loading branch information
Showing
13 changed files
with
347 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# | ||
# Copyright 2012-2019 The Feign Authors | ||
# | ||
# Licensed 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. | ||
# | ||
|
||
# build native image | ||
FROM oracle/graalvm-ce:19.0.0 | ||
LABEL vendor="The Last Pickle" | ||
|
||
RUN gu install native-image | ||
|
||
COPY reflectconfig.json . | ||
COPY ${project.artifactId}-${project.version}.jar . | ||
|
||
RUN native-image --verbose \ | ||
--no-fallback \ | ||
-H:ReflectionConfigurationFiles=reflectconfig.json \ | ||
-H:EnableURLProtocols=https \ | ||
-jar ${project.artifactId}-${project.version}.jar \ | ||
-cp ${project.artifactId}-${project.version}.jar | ||
|
||
|
||
|
||
# test the native image | ||
FROM ubuntu | ||
|
||
COPY --from=0 /opt/graalvm-ce-19.0.0/jre/lib/amd64/libsunec.so / | ||
COPY --from=0 /${project.artifactId}-${project.version} / | ||
|
||
RUN /${project.artifactId}-${project.version} | ||
|
||
|
||
|
||
# create docker image with native | ||
FROM ubuntu | ||
|
||
COPY --from=0 /opt/graalvm-ce-19.0.0/jre/lib/amd64/libsunec.so / | ||
COPY --from=0 /${project.artifactId}-${project.version} / | ||
|
||
CMD /${project.artifactId}-${project.version} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[ | ||
{ | ||
"name" : "example.github.Repository", | ||
"allDeclaredConstructors" : true, | ||
"allPublicConstructors" : true, | ||
"allDeclaredMethods" : true, | ||
"allPublicMethods" : true | ||
}, | ||
{ | ||
"name" : "example.github.Repository", | ||
"fields" : [ | ||
{ "name" : "name" } | ||
] | ||
}, | ||
{ | ||
"name" : "example.github.Contributor", | ||
"allDeclaredConstructors" : true, | ||
"allPublicConstructors" : true, | ||
"allDeclaredMethods" : true, | ||
"allPublicMethods" : true | ||
}, | ||
{ | ||
"name" : "example.github.Contributor", | ||
"fields" : [ | ||
{ "name" : "login" } | ||
] | ||
}, | ||
{ | ||
"name" : "example.github.GitHubClientError", | ||
"allDeclaredConstructors" : true, | ||
"allPublicConstructors" : true, | ||
"allDeclaredMethods" : true, | ||
"allPublicMethods" : true | ||
}, | ||
{ | ||
"name" : "example.github.GitHubClientError", | ||
"fields" : [ | ||
{ "name" : "message" } | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
apt-generator/src/test/java/feign/aptgenerator/github/GitHubFactoryExampleIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright 2012-2019 The Feign Authors | ||
* | ||
* Licensed 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 feign.aptgenerator.github; | ||
|
||
import static org.junit.Assert.assertThat; | ||
import org.apache.commons.exec.CommandLine; | ||
import org.apache.commons.exec.DefaultExecutor; | ||
import org.hamcrest.CoreMatchers; | ||
import org.junit.Test; | ||
import java.io.File; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* Run main for {@link GitHubFactoryExample} | ||
*/ | ||
public class GitHubFactoryExampleIT { | ||
|
||
@Test | ||
public void runMain() throws Exception { | ||
final String jar = Arrays.stream(new File("target").listFiles()) | ||
.filter(file -> file.getName().startsWith("feign-apt-generator") | ||
&& file.getName().endsWith(".jar")) | ||
.findFirst() | ||
.map(File::getAbsolutePath) | ||
.get(); | ||
|
||
final String line = "java -jar " + jar; | ||
final CommandLine cmdLine = CommandLine.parse(line); | ||
final int exitValue = new DefaultExecutor().execute(cmdLine); | ||
|
||
assertThat(exitValue, CoreMatchers.equalTo(0)); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
example-github/src/main/java/example/github/Contributor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Copyright 2012-2019 The Feign Authors | ||
* | ||
* Licensed 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 example.github; | ||
|
||
public class Contributor { | ||
public String login; | ||
} |
23 changes: 23 additions & 0 deletions
23
example-github/src/main/java/example/github/GitHubClientError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright 2012-2019 The Feign Authors | ||
* | ||
* Licensed 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 example.github; | ||
|
||
public class GitHubClientError extends RuntimeException { | ||
private String message; // parsed from json | ||
|
||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
} |
Oops, something went wrong.