Repository: quarkusio/quarkus
Issue: NPE when using io.quarkus.cli.commands.CreateProject.doCreateProject() on native image

**Describe the bug**
Having NPE when using when using io.quarkus.cli.commands.CreateProject.doCreateProject() on native image. I suppose the template are not automatically included

```
2019-07-25 11:42:30,588 ERROR [io.und.req.io] (executor-thread-1) Exception handling request de13b80e-5c67-479a-bd61-b2c9b73ba68d-1 to /api/quarkus/download: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
--
  | at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
  | at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
  | at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:209)
  | at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
  | at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
  | at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
  | at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
  | at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
  | at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
  | at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:249)
  | at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:60)
  | at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
  | at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
  | at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
  | at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
  | at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
  | at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
  | at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
  | at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
  | at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  | at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
  | at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
  | at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
  | at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
  | at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
  | at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  | at io.quarkus.undertow.runtime.RewriteCorrectingHandlerWrappers$PostWrapper$1.handleRequest(RewriteCorrectingHandlerWrappers.java:51)
  | at io.undertow.predicate.PredicatesHandler.handleRequest(PredicatesHandler.java:110)
  | at io.undertow.server.handlers.RequestDumpingHandler.handleRequest(RequestDumpingHandler.java:162)
  | at io.undertow.predicate.PredicatesHandler.handleRequest(PredicatesHandler.java:93)
  | at io.undertow.server.handlers.SetHeaderHandler.handleRequest(SetHeaderHandler.java:90)
  | at io.undertow.predicate.PredicatesHandler.handleRequest(PredicatesHandler.java:93)
  | at io.quarkus.undertow.runtime.RewriteCorrectingHandlerWrappers$PreWrapper$1.handleRequest(RewriteCorrectingHandlerWrappers.java:31)
  | at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  | at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
  | at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
  | at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
  | at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
  | at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
  | at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
  | at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$8$1$1.call(UndertowDeploymentRecorder.java:483)
  | at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
  | at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
  | at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
  | at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
  | at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
  | at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
  | at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
  | at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1538)
  | at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1429)
  | at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
  | at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:32)
  | at java.lang.Thread.run(Thread.java:748)
  | at org.jboss.threads.JBossThread.run(JBossThread.java:479)
  | at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:473)
  | at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
  | Caused by: java.lang.NullPointerException
  | at java.io.Reader.<init>(Reader.java:78)
  | at java.io.InputStreamReader.<init>(InputStreamReader.java:113)
  | at io.quarkus.templates.rest.BasicRest.generate(BasicRest.java:119)
  | at io.quarkus.templates.rest.BasicRest.initProject(BasicRest.java:98)
  | at io.quarkus.templates.rest.BasicRest.generate(BasicRest.java:47)
  | at io.quarkus.cli.commands.CreateProject.doCreateProject(CreateProject.java:127)
  | at io.launcher.quarkus.LauncherQuarkus.download(LauncherQuarkus.kt:52)
  | at io.launcher.quarkus.LauncherQuarkus_Subclass.download$$superaccessor1(LauncherQuarkus_Subclass.zig:120)
  | at io.launcher.quarkus.LauncherQuarkus_Subclass$$function$$1.apply(LauncherQuarkus_Subclass$$function$$1.zig:51)
  | at io.quarkus.arc.InvocationContextImpl.interceptorChainCompleted(InvocationContextImpl.java:141)
  | at io.quarkus.arc.InvocationContextImpl.proceed(InvocationContextImpl.java:161)
  | at io.quarkus.hibernate.validator.runtime.interceptor.AbstractMethodValidationInterceptor.validateMethodInvocation(AbstractMethodValidationInterceptor.java:67)
  | at io.quarkus.hibernate.validator.runtime.jaxrs.JaxrsEndPointValidationInterceptor.validateMethodInvocation(JaxrsEndPointValidationInterceptor.java:29)
  | at io.quarkus.hibernate.validator.runtime.jaxrs.JaxrsEndPointValidationInterceptor_Bean.intercept(JaxrsEndPointValidationInterceptor_Bean.zig:106)
  | at io.quarkus.arc.InvocationContextImpl$InterceptorInvocation.invoke(InvocationContextImpl.java:254)
  | at io.quarkus.arc.InvocationContextImpl.invokeNext(InvocationContextImpl.java:133)
  | at io.quarkus.arc.InvocationContextImpl.proceed(InvocationContextImpl.java:157)
  | at io.launcher.quarkus.LauncherQuarkus_Subclass.download(LauncherQuarkus_Subclass.zig:204)
  | at java.lang.reflect.Method.invoke(Method.java:498)
  | at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:151)
  | at org.jboss.resteasy.core.MethodInjectorImpl.lambda$invoke$3(MethodInjectorImpl.java:122)
  | at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602)
  | at java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:614)
  | at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:1983)
  | at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:110)
  | at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:122)
  | at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:580)
  | at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:454)
  | at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:408)
  | at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
  | at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:410)
  | at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:379)
  | at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invoke$1(ResourceMethodInvoker.java:353)
  | at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:981)
  | at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2124)
  | at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:110)
  | at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:353)
  | at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:477)
  | ... 52 more
```

**Expected behavior**
(Describe the expected behavior clearly and concisely.)

**Actual behavior**
(Describe the actual behavior clearly and concisely.)


**To Reproduce**
Steps to reproduce the behavior:
1. Use `doCreateProject` with a valid `CreateProject` in a quarkus project and bind it to a rest endpoint
2. Create a native image
3. Call

example: https://github.com/fabric8-launcher/launcher-quarkus/blob/master/src/main/kotlin/io/launcher/quarkus/LauncherQuarkus.kt#L52

**Workaround**
```
<plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${version.quarkus}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                        </goals>
                        <configuration>
                            <additionalBuildArgs>-H:IncludeResources=templates/.*</additionalBuildArgs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
```


Changed files:
devtools/common/src/main/java/io/quarkus/generators/rest/BasicRestProjectGenerator.java

diff --git a/devtools/common/src/main/java/io/quarkus/generators/rest/BasicRestProjectGenerator.java b/devtools/common/src/main/java/io/quarkus/generators/rest/BasicRestProjectGenerator.java
index bd9c600c8f7..dacd619630b 100644
--- a/devtools/common/src/main/java/io/quarkus/generators/rest/BasicRestProjectGenerator.java
+++ b/devtools/common/src/main/java/io/quarkus/generators/rest/BasicRestProjectGenerator.java
@@ -5,7 +5,9 @@
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
@@ -111,9 +113,15 @@ private void generate(final String templateName, final Map<String, Object> conte
                 throws IOException {
             if (!writer.exists(outputFilePath)) {
                 String path = templateName.startsWith("/") ? templateName : "/" + templateName;
-                try (final BufferedReader stream = new BufferedReader(
-                        new InputStreamReader(getClass().getResourceAsStream(path), StandardCharsets.UTF_8))) {
-                    String template = stream.lines().collect(Collectors.joining("\\n"));
+                URL resource = getClass().getResource(path);
+                if (resource == null) {
+                    throw new IOException("Template resource is missing: " + path);
+                }
+                try (
+                        InputStream resourceStream = resource.openStream();
+                        InputStreamReader streamReader = new InputStreamReader(resourceStream, StandardCharsets.UTF_8);
+                        BufferedReader bufferedReader = new BufferedReader(streamReader)) {
+                    String template = bufferedReader.lines().collect(Collectors.joining("\\n"));
                     for (Entry<String, Object> e : context.entrySet()) {
                         if (e.getValue() != null) { // Exclude null values (classname and path can be null)
                             template = template.replace(format("${%s}", e.getKey()), e.getValue().toString());