Skip to content

Commit

Permalink
Generate application.properties when creating a project
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Mar 7, 2019
1 parent 1cb3094 commit 1b0dbe6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions devtools/common/src/main/java/io/quarkus/BasicRest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void generate(final File projectRoot, Map<String, Object> parameters) thr
}
createIndexPage();
createDockerFile();
createMicroProfileConfig();
createApplicationConfig();
}

private void setupContext() {
Expand Down Expand Up @@ -166,11 +166,11 @@ private void createDockerFile() throws IOException {
generate("templates/dockerfile.ftl", context, docker, "docker file");
}

private void createMicroProfileConfig() throws IOException {
File meta = new File(projectRoot, "src/main/resources/META-INF");
File file = new File(mkdirs(meta), "microprofile-config.properties");
private void createApplicationConfig() throws IOException {
File meta = new File(projectRoot, "src/main/resources");
File file = new File(mkdirs(meta), "application.properties");
if (!file.exists()) {
Files.write(file.toPath(), Arrays.asList("# Configuration file", "key = value"), StandardOpenOption.CREATE_NEW);
Files.write(file.toPath(), Arrays.asList("# Configuration file", "# key = value"), StandardOpenOption.CREATE_NEW);
System.out.println("Configuration file created in src/main/resources/META-INF/" + file.getName());
}
}
Expand Down
2 changes: 1 addition & 1 deletion devtools/common/src/main/resources/templates/index.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<ul>
<li>Add REST resources, Servlets, functions and other services in <code>src/main/java</code>.</li>
<li>Your static assets are located in <code>src/main/resources/META-INF/resources</code>.</li>
<li>Configure your application in <code>src/main/resources/META-INF/microprofile-config.properties</code>.
<li>Configure your application in <code>src/main/resources/application.properties</code>.
</li>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void createOnTopPomWithoutResource() throws IOException {
assertThat(new File(testDir, "src/main/java")).isDirectory();
assertThat(new File(testDir, "src/test/java")).isDirectory();

assertThat(new File(testDir, "src/main/resources/META-INF/microprofile-config.properties")).exists();
assertThat(new File(testDir, "src/main/resources/application.properties")).exists();
assertThat(new File(testDir, "src/main/resources/META-INF/resources/index.html")).isFile();
assertThat(new File(testDir, "src/main/java")).isDirectory().matches(f -> {
String[] list = f.list();
Expand Down Expand Up @@ -97,7 +97,7 @@ public void createOnTopPomWithResource() throws IOException {
assertThat(new File(testDir, "src/main/java")).isDirectory();
assertThat(new File(testDir, "src/test/java")).isDirectory();

assertThat(new File(testDir, "src/main/resources/META-INF/microprofile-config.properties")).exists();
assertThat(new File(testDir, "src/main/resources/application.properties")).exists();
assertThat(new File(testDir, "src/main/resources/META-INF/resources/index.html")).exists();
assertThat(new File(testDir, "src/main/java")).isDirectory();
assertThat(new File(testDir, "src/main/java/org/foo/MyResource.java")).isFile();
Expand Down Expand Up @@ -137,7 +137,7 @@ public void createNewWithCustomizations() throws IOException {
assertThat(new File(testDir, "src/main/java")).isDirectory();
assertThat(new File(testDir, "src/test/java")).isDirectory();

assertThat(new File(testDir, "src/main/resources/META-INF/microprofile-config.properties")).exists();
assertThat(new File(testDir, "src/main/resources/application.properties")).exists();
assertThat(new File(testDir, "src/main/resources/META-INF/resources/index.html")).exists();

assertThat(FileUtils.readFileToString(new File(testDir, "pom.xml"), "UTF-8"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ExampleConfigMojo() {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
File out = new File(project.getBasedir(), "src/main/resources/META-INF/example-microprofile-config.properties");
File out = new File(project.getBasedir(), "src/main/resources/application.properties");
out.getParentFile().mkdirs();

Properties properties = new Properties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public void testProjectGenerationFromScratch() throws MavenInvocationException,

assertThat(new File(testDir, "pom.xml")).isFile();
assertThat(new File(testDir, "src/main/java")).isDirectory();
assertThat(new File(testDir, "src/main/resources/META-INF/microprofile-config.properties")).isFile();
assertThat(new File(testDir, "src/main/resources/application.properties")).isFile();

String config = Files
.asCharSource(new File(testDir, "src/main/resources/META-INF/microprofile-config.properties"), Charsets.UTF_8)
.asCharSource(new File(testDir, "src/main/resources/application.properties"), Charsets.UTF_8)
.read();
assertThat(config).contains("key = value");

Expand Down Expand Up @@ -109,7 +109,7 @@ public void testProjectGenerationFromEmptyPom() throws Exception {
.contains(MojoUtils.getPluginGroupId(), MojoUtils.QUARKUS_VERSION_PROPERTY, MojoUtils.getPluginGroupId());
assertThat(new File(testDir, "src/main/java")).isDirectory();

assertThat(new File(testDir, "src/main/resources/META-INF/microprofile-config.properties")).exists();
assertThat(new File(testDir, "src/main/resources/application.properties")).exists();
assertThat(new File(testDir, "src/main/resources/META-INF/resources/index.html")).exists();

assertThat(FileUtils.readFileToString(new File(testDir, "pom.xml"), "UTF-8"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h2>What can I do from here?</h2>
<ul>
<li>Add REST resources, Servlets, functions and other services in <code>src/main/java</code>.</li>
<li>Your static assets are located in <code>src/main/resources/META-INF/resources</code>.</li>
<li>Configure your application in <code>src/main/resources/META-INF/microprofile-config.properties</code>.
<li>Configure your application in <code>src/main/resources/application.properties</code>.
</li>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h2>What can I do from here?</h2>
<ul>
<li>Add REST resources, Servlets, functions and other services in <code>src/main/java</code>.</li>
<li>Your static assets are located in <code>src/main/resources/META-INF/resources</code>.</li>
<li>Configure your application in <code>src/main/resources/META-INF/microprofile-config.properties</code>.
<li>Configure your application in <code>src/main/resources/application.properties</code>.
</li>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h2>What can I do from here?</h2>
<ul>
<li>Add REST resources, Servlets, functions and other services in <code>src/main/java</code>.</li>
<li>Your static assets are located in <code>src/main/resources/META-INF/resources</code>.</li>
<li>Configure your application in <code>src/main/resources/META-INF/microprofile-config.properties</code>.
<li>Configure your application in <code>src/main/resources/application.properties</code>.
</li>
</ul>

Expand Down

0 comments on commit 1b0dbe6

Please sign in to comment.