Skip to content

Commit

Permalink
fix groupId not replaced and spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
vegegoku committed Nov 9, 2020
1 parent ca263bf commit eda6f9d
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.dominokit.cli.model;

import java.lang.Boolean;
import java.lang.Class;
import java.lang.Object;
import java.lang.Override;
Expand All @@ -9,6 +10,7 @@
import org.dominokit.jacksonapt.JsonDeserializationContext;
import org.dominokit.jacksonapt.JsonDeserializer;
import org.dominokit.jacksonapt.JsonDeserializerParameters;
import org.dominokit.jacksonapt.deser.BooleanJsonDeserializer;
import org.dominokit.jacksonapt.deser.StringJsonDeserializer;
import org.dominokit.jacksonapt.deser.bean.AbstractBeanJsonDeserializer;
import org.dominokit.jacksonapt.deser.bean.BeanPropertyDeserializer;
Expand Down Expand Up @@ -118,6 +120,28 @@ public void setValue(Project bean, String value, JsonDeserializationContext ctx)
bean.setModuleShortName(value);
}
});
map.put("hasParent", new BeanPropertyDeserializer<Project, Boolean>() {
@Override
protected JsonDeserializer<?> newDeserializer() {
return BooleanJsonDeserializer.getInstance();
}

@Override
public void setValue(Project bean, Boolean value, JsonDeserializationContext ctx) {
bean.setHasParent(value);
}
});
map.put("parentArtifactId", new BeanPropertyDeserializer<Project, String>() {
@Override
protected JsonDeserializer<?> newDeserializer() {
return StringJsonDeserializer.getInstance();
}

@Override
public void setValue(Project bean, String value, JsonDeserializationContext ctx) {
bean.setParentArtifactId(value);
}
});
return map;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.dominokit.cli.model;

import java.lang.Boolean;
import java.lang.Class;
import java.lang.Override;
import java.lang.String;
import org.dominokit.jacksonapt.JsonSerializationContext;
import org.dominokit.jacksonapt.JsonSerializer;
import org.dominokit.jacksonapt.ser.BooleanJsonSerializer;
import org.dominokit.jacksonapt.ser.StringJsonSerializer;
import org.dominokit.jacksonapt.ser.bean.AbstractBeanJsonSerializer;
import org.dominokit.jacksonapt.ser.bean.BeanPropertySerializer;
Expand All @@ -20,7 +22,7 @@ public Class getSerializedType() {

@Override
protected BeanPropertySerializer[] initSerializers() {
BeanPropertySerializer[] result = new BeanPropertySerializer[6];
BeanPropertySerializer[] result = new BeanPropertySerializer[8];
result[0] = new BeanPropertySerializer<Project, String>("name") {
@Override
protected JsonSerializer<?> newSerializer() {
Expand Down Expand Up @@ -87,6 +89,28 @@ public String getValue(Project bean, JsonSerializationContext ctx) {
return bean.getModuleShortName();
}
};
result[6] = new BeanPropertySerializer<Project, Boolean>("hasParent") {
@Override
protected JsonSerializer<?> newSerializer() {
return BooleanJsonSerializer.getInstance();
}

@Override
public Boolean getValue(Project bean, JsonSerializationContext ctx) {
return bean.isHasParent();
}
};
result[7] = new BeanPropertySerializer<Project, String>("parentArtifactId") {
@Override
protected JsonSerializer<?> newSerializer() {
return StringJsonSerializer.getInstance();
}

@Override
public String getValue(Project bean, JsonSerializationContext ctx) {
return bean.getParentArtifactId();
}
};
return result;
}
}
9 changes: 9 additions & 0 deletions src/main/java/org/dominokit/cli/commands/CLIConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.dominokit.cli.commands;

import java.util.Arrays;
import java.util.List;

public class CLIConfig {

public static final List<String> RESOURCE_EXTENSIONS = Arrays.asList("ico", "png", "jpg");
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.apache.commons.io.FileUtils;
import org.apache.maven.model.Model;
import org.dominokit.cli.PomUtil;
import org.dominokit.cli.model.Module;
import org.dominokit.cli.model.Project;
import org.dominokit.cli.structure.files.VelocityContentProcessor;
import org.dominokit.cli.structure.folders.Folder;
Expand Down Expand Up @@ -89,6 +88,7 @@ public void run() {
}
} else {
project.setVersion(VERSION);
project.setGroupId(groupId);
}

project.setRootPackage(groupId);
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/dominokit/cli/commands/TemplateConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ public class TemplateConfig {
private Map<String, String> conditions = new HashMap<>();

public TemplateConfig(String name, Path templateRoot) throws IOException {
Properties properties = new Properties();
properties.load(Test.class.getClassLoader().getResourceAsStream("cli-config.properties"));
resourcesExtensions = Arrays.asList(properties.getProperty("resources.extensions").split(","));
resourcesExtensions = CLIConfig.RESOURCE_EXTENSIONS;
this.templateRoot = templateRoot;
this.name = name;
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/dominokit/cli/commands/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public static void main(String[] args) {
String[] module3Args = new String[]{"gen", "module", "-n", "home", "-sp", "home.street", "-t","-d", out+"/sample"};
commandLine.execute(module3Args);

String[] module4Args = new String[]{"gen", "app", "-t", "basic", "-n", "j2cltest", "--j2cl", "-g", "com.foo","-d", out};
String[] module4Args = new String[]{"gen", "app", "-t", "basic", "-n", "j2cltest", "--j2cl", "-g", "com.foo","-d", out+"/sample"};
commandLine.execute(module4Args);

String[] basicGwt = new String[]{"gen", "app", "-t", "basic", "-n", "gwttest", "-g", "com.foo","-d", out+"/sample"};
commandLine.execute(basicGwt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void addFrontEndDependencies(Module module, String frontEndPomString) th
"\n\t\t\t<version>${project.version}</version>" +
"\n\t\t</dependency>" +
"\n" +
"\n\t</dependencies>");
"\t</dependencies>");

if(!module.isJ2cl()) {
frontEndPomString = frontEndPomString
Expand All @@ -68,33 +68,31 @@ private void addFrontEndDependencies(Module module, String frontEndPomString) th
"\n\t\t\t<classifier>sources</classifier>" +
"\n\t\t</dependency>" +
"\n" +
"\n\t</dependencies>");
"\t</dependencies>");
}

frontEndPomString = frontEndPomString
.replace("</dependencies>",
"\n" +
"\n\t\t<dependency>" +
"\n\t\t\t<groupId>" + module.getProject().getGroupId() + "</groupId>" +
"\n\t\t\t<artifactId>" + module.getArtifactId() + "-frontend-ui</artifactId>" +
"\n\t\t\t<version>${project.version}</version>" +
"\n\t\t</dependency>" +
"\n" +
"\n\t</dependencies>");
"\t</dependencies>");

if(!module.isJ2cl()){

frontEndPomString = frontEndPomString
.replace("</dependencies>",
"\n" +
"\n\t\t<dependency>" +
"\n\t\t\t<groupId>" + module.getProject().getGroupId() + "</groupId>" +
"\n\t\t\t<artifactId>" + module.getArtifactId() + "-frontend-ui</artifactId>" +
"\n\t\t\t<version>${project.version}</version>" +
"\n\t\t\t<classifier>sources</classifier>" +
"\n\t\t</dependency>" +
"\n" +
"\n\t</dependencies>");
"\t</dependencies>");
}

FileUtils.write(module.getFrontendPom().getPomFile(), frontEndPomString, StandardCharsets.UTF_8);
Expand Down

0 comments on commit eda6f9d

Please sign in to comment.