Skip to content

Commit

Permalink
Merge pull request #4374 from geoand/kotlin-missing-plugin
Browse files Browse the repository at this point in the history
Fix issues with gradle project generation
  • Loading branch information
aloubyansky authored Oct 7, 2019
2 parents 1332e7a + 242d2f7 commit fe5b07b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ public class GradleBuildFile extends BuildFile {

public GradleBuildFile(ProjectWriter writer) throws IOException {
super(writer, BuildTool.GRADLE);
if (writer.exists(SETTINGS_GRADLE_PATH)) {
final byte[] settings = writer.getContent(SETTINGS_GRADLE_PATH);
settingsContent = new String(settings, StandardCharsets.UTF_8);
}
if (writer.exists(BUILD_GRADLE_PATH)) {
final byte[] build = writer.getContent(BUILD_GRADLE_PATH);
buildContent = new String(build, StandardCharsets.UTF_8);
}
if (writer.exists(GRADLE_PROPERTIES_PATH)) {
final byte[] properties = writer.getContent(GRADLE_PROPERTIES_PATH);
propertiesContent.load(new ByteArrayInputStream(properties));
}
}

@Override
Expand All @@ -55,9 +43,25 @@ public void close() throws IOException {

@Override
public void completeFile(String groupId, String artifactId, String version) throws IOException {
init();
completeSettingsContent(artifactId);
completeBuildContent(groupId, version);
completeProperties(artifactId);
completeProperties();
}

protected void init() throws IOException {
if (getWriter().exists(SETTINGS_GRADLE_PATH)) {
final byte[] settings = getWriter().getContent(SETTINGS_GRADLE_PATH);
settingsContent = new String(settings, StandardCharsets.UTF_8);
}
if (getWriter().exists(BUILD_GRADLE_PATH)) {
final byte[] build = getWriter().getContent(BUILD_GRADLE_PATH);
buildContent = new String(build, StandardCharsets.UTF_8);
}
if (getWriter().exists(GRADLE_PROPERTIES_PATH)) {
final byte[] properties = getWriter().getContent(GRADLE_PROPERTIES_PATH);
propertiesContent.load(new ByteArrayInputStream(properties));
}
}

private void completeBuildContent(String groupId, String version) {
Expand Down Expand Up @@ -128,7 +132,7 @@ private void completeSettingsContent(String artifactId) {
settingsContent = res.toString();
}

private void completeProperties(String artifactId) {
private void completeProperties() {
if (propertiesContent.getProperty("quarkusVersion") == null) {
propertiesContent.setProperty("quarkusVersion", getPluginVersion());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class MavenBuildFile extends BuildFile {

public MavenBuildFile(ProjectWriter writer) throws IOException {
super(writer, BuildTool.MAVEN);
initModel();
}

private void initModel() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}

plugins {
id 'kotlin'
id 'org.jetbrains.kotlin.jvm' version "${kotlin_version}"
}

apply plugin: 'io.quarkus'
Expand All @@ -23,10 +23,20 @@ repositories {
dependencies {
implementation enforcedPlatform("io.quarkus:quarkus-bom:${quarkusVersion}")
implementation 'io.quarkus:quarkus-resteasy'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'

testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured'
}

group '${project_groupId}'
version '${project_version}'

quarkus {
setOutputDirectory("$projectDir/build/classes/kotlin/main")
}

quarkusDev {
setSourceDir("$projectDir/src/main/kotlin")
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class GradleBuildFileFromConnector extends GradleBuildFile {

public GradleBuildFileFromConnector(ProjectWriter writer) throws IOException {
super(writer);
// we need to initialize here since there is no other single point of entry
init();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.maven;

import static io.quarkus.generators.ProjectGenerator.BUILD_FILE;
import static org.fusesource.jansi.Ansi.ansi;
import static org.twdata.maven.mojoexecutor.MojoExecutor.artifactId;
import static org.twdata.maven.mojoexecutor.MojoExecutor.configuration;
Expand Down Expand Up @@ -39,6 +40,7 @@
import io.quarkus.cli.commands.AddExtensionResult;
import io.quarkus.cli.commands.AddExtensions;
import io.quarkus.cli.commands.CreateProject;
import io.quarkus.cli.commands.file.BuildFile;
import io.quarkus.cli.commands.writer.FileProjectWriter;
import io.quarkus.generators.BuildTool;
import io.quarkus.generators.SourceType;
Expand Down Expand Up @@ -160,7 +162,7 @@ public void execute() throws MojoExecutionException {
File createdDependenciesBuildFile = new File(projectRoot, buildToolEnum.getDependenciesFile());
File buildFile = new File(createdDependenciesBuildFile.getAbsolutePath());
if (success) {
AddExtensionResult result = new AddExtensions(new FileProjectWriter(buildFile.getParentFile()), buildToolEnum)
AddExtensionResult result = new AddExtensions((BuildFile) context.get(BUILD_FILE))
.addExtensions(extensions);
if (!result.succeeded()) {
success = false;
Expand Down

0 comments on commit fe5b07b

Please sign in to comment.