Skip to content
Snippets Groups Projects
Commit 1349f3da authored by Sebastian Ebert's avatar Sebastian Ebert
Browse files

fixed gen of gradle build

parent cb9e4ee4
No related branches found
No related tags found
No related merge requests found
...@@ -18,13 +18,13 @@ public class Main { ...@@ -18,13 +18,13 @@ public class Main {
public static void main(java.lang.String[] args) throws IOException { public static void main(java.lang.String[] args) throws IOException {
if(args.length != 1){ // if(args.length != 1){
System.out.println("Error: Invalid arguments."); // System.out.println("Error: Invalid arguments.");
return; // return;
} // }
String configPath = args[0]; //String configPath = args[0];
//String configPath = "src/test/resources/GeneratorConfig.json"; String configPath = "src/test/resources/GeneratorConfig.json";
ObjectMapper generatorConfigObjectMapper = new ObjectMapper(); ObjectMapper generatorConfigObjectMapper = new ObjectMapper();
GeneratorConfig gc = generatorConfigObjectMapper.readValue(Files.readString(Paths.get(configPath)), GeneratorConfig.class); GeneratorConfig gc = generatorConfigObjectMapper.readValue(Files.readString(Paths.get(configPath)), GeneratorConfig.class);
......
...@@ -64,13 +64,11 @@ public class PackageStructureBuilder { ...@@ -64,13 +64,11 @@ public class PackageStructureBuilder {
if(pf.isTemplateFile()) { if(pf.isTemplateFile()) {
if(pf.isJavaFile()){ if(pf.isJavaFile()){
// System.out.println("Writing file " + pf.getName() + " to: " + packagePath + "/" + packageDirectory.getName() + "/" + pf.getName() + ".java"); System.out.println("Writing file " + pf.getName() + " to: " + packagePath + "/" + packageDirectory.getName() + "/" + pf.getName() + ".java");
//System.out.println("Content: \n" + pf.asTemplateFile().getFileContent()); //System.out.println("Content: \n" + pf.asTemplateFile().getFileContent());
writeToFile(packagePath + "/" + packageDirectory.getName() + "/" + pf.getName() + ".java", pf.asTemplateFile().getFileContent()); writeToFile(packagePath + "/" + packageDirectory.getName() + "/" + pf.getName() + ".java", pf.asTemplateFile().getFileContent());
}else { }else {
//System.out.println("Writing file " + pf.getName() + " to: " + packagePath + "/" + packageDirectory.getName() + "/" + pf.getName()); System.out.println("Writing file " + pf.getName() + " to: " + packagePath + "/" + packageDirectory.getName() + "/" + pf.getName());
writeToFile(packagePath + "/" + packageDirectory.getName() + "/" + pf.getName(), pf.asTemplateFile().getFileContent()); writeToFile(packagePath + "/" + packageDirectory.getName() + "/" + pf.getName(), pf.asTemplateFile().getFileContent());
} }
} }
...@@ -98,17 +96,20 @@ public class PackageStructureBuilder { ...@@ -98,17 +96,20 @@ public class PackageStructureBuilder {
private static void buildDinerosGeneratedFilesStructure(DinerosPackage dinerosPackage, List<PetriNet> nets, List<NetInfo> petriNetFilePaths) { private static void buildDinerosGeneratedFilesStructure(DinerosPackage dinerosPackage, List<PetriNet> nets, List<NetInfo> petriNetFilePaths) {
GradleFile buildGradle = new GradleFile();
buildGradle.setName("build.gradle");
buildGradle.setFileID(UUID.randomUUID().toString());
dinerosPackage.addFile(buildGradle);
GradleFile gradleProbs = new GradleFile();
gradleProbs.setName("gradle.properties");
gradleProbs.setFileID(UUID.randomUUID().toString());
for (PackageDirectory pd : dinerosPackage.allDirectories()) { for (PackageDirectory pd : dinerosPackage.allDirectories()) {
if (pd.getName().equals(dinerosPackage.getRootName())) {
GradleFile buildGradle = new GradleFile();
buildGradle.setName("build.gradle");
buildGradle.setFileID(UUID.randomUUID().toString());
pd.addFile(buildGradle);
GradleFile gradleProbs = new GradleFile();
gradleProbs.setName("gradle.properties");
gradleProbs.setFileID(UUID.randomUUID().toString());
pd.addFile(gradleProbs);
}
if (pd.getName().equals(dinerosPackage.getNamespace())) { if (pd.getName().equals(dinerosPackage.getNamespace())) {
MainFile mainFile = new MainFile(); MainFile mainFile = new MainFile();
mainFile.setName("Main"); mainFile.setName("Main");
...@@ -334,8 +335,6 @@ public class PackageStructureBuilder { ...@@ -334,8 +335,6 @@ public class PackageStructureBuilder {
List<String> petriNetFiles, String rosHost, String rosMasterUri, String mqttHost) { List<String> petriNetFiles, String rosHost, String rosMasterUri, String mqttHost) {
Set<String> visitedPackageFileIDs = new HashSet<>(); Set<String> visitedPackageFileIDs = new HashSet<>();
Map<String, Integer> subscriberCountMap = initSubscriberCountMap(nets);
Map<String, Integer> serviceCountMap = initServiceCountMap(nets);
for (PackageFile pf : dinerosPackage.allPackageFiles()) { for (PackageFile pf : dinerosPackage.allPackageFiles()) {
if (pf.isMapperFile()) { if (pf.isMapperFile()) {
...@@ -367,7 +366,6 @@ public class PackageStructureBuilder { ...@@ -367,7 +366,6 @@ public class PackageStructureBuilder {
if (transitionType.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_LIMITED_IN) if (transitionType.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_LIMITED_IN)
|| transitionType.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_UNLIMITED_IN)) { || transitionType.equals(PnmlConstants.TRANSITION_TYPE_TOPIC_UNLIMITED_IN)) {
System.out.println("t:" + t.getId());
pf.setName("Node" + pf.asSubscriberFile().getNetCount() + "Subscriber" + pf.asSubscriberFile().getSubscriberCount()); pf.setName("Node" + pf.asSubscriberFile().getNetCount() + "Subscriber" + pf.asSubscriberFile().getSubscriberCount());
pf.asSubscriberFile().generate(); pf.asSubscriberFile().generate();
//subscriberCountMap.put(nets.get(i).getId(), subscriberCountMap.get(nets.get(i).getId()) + 1); //subscriberCountMap.put(nets.get(i).getId(), subscriberCountMap.get(nets.get(i).getId()) + 1);
...@@ -383,9 +381,9 @@ public class PackageStructureBuilder { ...@@ -383,9 +381,9 @@ public class PackageStructureBuilder {
String transitionType = t.asInputSignalTransition().getStaticTransitionInformation().getType(); String transitionType = t.asInputSignalTransition().getStaticTransitionInformation().getType();
if (transitionType.equals(PnmlConstants.TRANSITION_TYPE_SERVICE_REQUEST_OUT)) { if (transitionType.equals(PnmlConstants.TRANSITION_TYPE_SERVICE_REQUEST_OUT)) {
pf.setName("Node" + i + "Server" + (serviceCountMap.get(nets.get(i).getId()) - 1)); pf.setName("Node" + pf.asServerFile().getNetCount() + "Subscriber" + pf.asServerFile().getServerCount());
pf.asServerFile().generate(); pf.asServerFile().generate();
serviceCountMap.put(nets.get(i).getId(), serviceCountMap.get(nets.get(i).getId()) + 1); // serviceCountMap.put(nets.get(i).getId(), serviceCountMap.get(nets.get(i).getId()) + 1);
visitedPackageFileIDs.add(pf.getFileID()); visitedPackageFileIDs.add(pf.getFileID());
} }
} }
......
...@@ -3,13 +3,13 @@ package de.tudresden.inf.st.pnml.gen.data; ...@@ -3,13 +3,13 @@ package de.tudresden.inf.st.pnml.gen.data;
public class MainExecutionContext { public class MainExecutionContext {
private String rosHost; private String rosHost;
private String rostMasterUri; private String rosMasterUri;
private String mqttHost; private String mqttHost;
private String packageNamespace; private String packageNamespace;
public MainExecutionContext(String rosHost, String rostMasterUri, String mqttHost, String packageNamespace) { public MainExecutionContext(String rosHost, String rosMasterUri, String mqttHost, String packageNamespace) {
this.rosHost = rosHost; this.rosHost = rosHost;
this.rostMasterUri = rostMasterUri; this.rosMasterUri = rosMasterUri;
this.mqttHost = mqttHost; this.mqttHost = mqttHost;
this.packageNamespace = packageNamespace; this.packageNamespace = packageNamespace;
} }
...@@ -22,12 +22,12 @@ public class MainExecutionContext { ...@@ -22,12 +22,12 @@ public class MainExecutionContext {
this.rosHost = rosHost; this.rosHost = rosHost;
} }
public String getRostMasterUri() { public String getRosMasterUri() {
return rostMasterUri; return rosMasterUri;
} }
public void setRostMasterUri(String rostMasterUri) { public void setRosMasterUri(String rosMasterUri) {
this.rostMasterUri = rostMasterUri; this.rosMasterUri = rosMasterUri;
} }
public String getMqttHost() { public String getMqttHost() {
......
...@@ -20,7 +20,7 @@ repositories { ...@@ -20,7 +20,7 @@ repositories {
dependencies { dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.3' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.3'
compile fileTree(include: ['pnml-relast-engine-fatjar-{{pnmlRelastersion}}.jar'], dir: './libs') compile fileTree(include: ['pnml-relast-engine-fatjar-{{pnmlRelastVersion}}.jar'], dir: './libs')
testCompile group: 'junit', name: 'junit', version: '4.12' testCompile group: 'junit', name: 'junit', version: '4.12'
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment