Skip to content

Commit

Permalink
Merge pull request #77 from salamafazlul/hotfix
Browse files Browse the repository at this point in the history
Replace File.separator with "/" for cross-platform path handling
  • Loading branch information
sameeragunarathne authored Apr 8, 2024
2 parents cee4b0d + 7846f50 commit cd13e9d
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class ToolConstants {
public static final String MD_EXTENSION = ".md";
public static final String CONSTRAINTS_LIB_IMPORT = "ballerina/constraint";
public static final String ELEMENT = "Element";
public static final String RESOURCE_PATH_SEPERATOR = "/";

public enum TokenPosition {
BEGIN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void populateResourceTemplateContexts(FHIRImplementationGuide ig) {
resourceDefinitionAnnotation.setName(GeneratorUtils.getInstance().resolveSpecialCharacters(structureDefinition.getName()));
DataTypesRegistry.getInstance().addDataType(GeneratorUtils.getInstance().resolveSpecialCharacters(structureDefinition.getName()));
resourceDefinitionAnnotation.setBaseType(CommonUtil.getSplitTokenAt(structureDefinition
.getBaseDefinition(), File.separator, ToolConstants.TokenPosition.END));
.getBaseDefinition(), ToolConstants.RESOURCE_PATH_SEPERATOR, ToolConstants.TokenPosition.END));
resourceDefinitionAnnotation.setProfile(this.resourceTemplateContextInstance.getProfile());
resourceDefinitionAnnotation.setElements(new HashMap<>());
this.resourceTemplateContextInstance.setResourceDefinitionAnnotation(resourceDefinitionAnnotation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void generate(ToolContext toolContext, Map<String, Object> generatorPrope
if (!datatypeContexts.isEmpty()) {
String filePath = CommonUtil.generateFilePath(packagePath, "", "datatypes.bal");
this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH +
File.separator + "fhir_extended_datatypes.vm", templateContext, "", filePath);
ToolConstants.RESOURCE_PATH_SEPERATOR + "fhir_extended_datatypes.vm", templateContext, "", filePath);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,22 @@ private void generatePackageEssentials(BallerinaPackageGenToolConfig toolConfig)
String packagePath = (String) this.packageProperties.get("packagePath");
String filePath = CommonUtil.generateFilePath(packagePath, "Ballerina"
+ ToolConstants.TOML_EXTENSION, "");
this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + File.separator + "ballerina_toml.vm",
this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + ToolConstants.RESOURCE_PATH_SEPERATOR + "ballerina_toml.vm",
this.createTemplateContextForBallerinaToml(toolConfig), "", filePath);

filePath = CommonUtil.generateFilePath(packagePath, "Package"
+ ToolConstants.MD_EXTENSION, "");
this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + File.separator + "package.vm",
this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + ToolConstants.RESOURCE_PATH_SEPERATOR + "package.vm",
this.createTemplateContextForPackageMD(toolConfig), "", filePath);

filePath = CommonUtil.generateFilePath(packagePath, "initializer"
+ ToolConstants.BAL_EXTENSION, "");
this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + File.separator + "initializer.vm",
this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + ToolConstants.RESOURCE_PATH_SEPERATOR + "initializer.vm",
this.createTemplateContextForInitializer(), "", filePath);

filePath = CommonUtil.generateFilePath(packagePath, "variables"
+ ToolConstants.BAL_EXTENSION, "");
this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + File.separator + "variables.vm",
this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + ToolConstants.RESOURCE_PATH_SEPERATOR + "variables.vm",
this.createTemplateContextForVariables(), "", filePath);
} catch (CodeGenException e) {
throw new CodeGenException("Error occurred while generating template artifacts for ballerina package ", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void generateFHIRResources()
+ ToolConstants.BAL_EXTENSION, "");

this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH +
File.separator + "fhir_resource.vm", this.createTemplateContextForResourceSkeletons(
ToolConstants.RESOURCE_PATH_SEPERATOR + "fhir_resource.vm", this.createTemplateContextForResourceSkeletons(
resourceTemplateContext, this.packageTemplateContext), "", filePath);
}
} catch (CodeGenException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class BallerinaProjectConstants {
public static final String BASE_PACKAGE_IMPORT_SUFFIX = "ballerinax/health.fhir.";
public static final String SERVICE_PACKAGE_IMPORT_SUFFIX = "ballerinax/health.fhir";
public static final String INTERNATIONAL_PACKAGE_IMPORT_SUFFIX = "ballerinax/health.fhir.r4.international401";
public static final String RESOURCE_PATH_SEPERATOR = "/";

public class PrintStrings {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public MetaGenerator(String targetDir) throws CodeGenException {
public void generate(ToolContext toolContext, Map<String, Object> generatorProperties) throws CodeGenException {
String directoryPath = generatorProperties.get("projectAPIPath") + File.separator;
this.getTemplateEngine().generateOutputAsFile(BallerinaProjectConstants.RESOURCE_PATH_TEMPLATES +
File.separator + "packageMd.vm", createTemplateContextForMeta(generatorProperties), directoryPath,
BallerinaProjectConstants.RESOURCE_PATH_SEPERATOR + "packageMd.vm", createTemplateContextForMeta(generatorProperties), directoryPath,
"Package.md");
this.getTemplateEngine().generateOutputAsFile(BallerinaProjectConstants.RESOURCE_PATH_TEMPLATES +
File.separator + "gitignore.vm", createTemplateContextForMeta(generatorProperties), directoryPath,
BallerinaProjectConstants.RESOURCE_PATH_SEPERATOR + "gitignore.vm", createTemplateContextForMeta(generatorProperties), directoryPath,
".gitignore");
this.getTemplateEngine().generateOutputAsFile(BallerinaProjectConstants.RESOURCE_PATH_TEMPLATES +
File.separator + "apiConfig.vm", createTemplateContextForMeta(generatorProperties), directoryPath,
BallerinaProjectConstants.RESOURCE_PATH_SEPERATOR + "apiConfig.vm", createTemplateContextForMeta(generatorProperties), directoryPath,
"api_config.bal");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ServiceGenerator(String targetDir) throws CodeGenException {
public void generate(ToolContext toolContext, Map<String, Object> generatorProperties) throws CodeGenException {
String directoryPath = generatorProperties.get("projectAPIPath") + File.separator;
this.getTemplateEngine().generateOutputAsFile(BallerinaProjectConstants.RESOURCE_PATH_TEMPLATES +
File.separator + "balService.vm", createTemplateContextForBalService(
BallerinaProjectConstants.RESOURCE_PATH_SEPERATOR + "balService.vm", createTemplateContextForBalService(
generatorProperties), directoryPath, "service.bal");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public TomlGenerator(String targetDir) throws CodeGenException {
public void generate(ToolContext toolContext, Map<String, Object> generatorProperties) throws CodeGenException {
String directoryPath = generatorProperties.get("projectAPIPath") + File.separator;
this.getTemplateEngine().generateOutputAsFile(BallerinaProjectConstants.RESOURCE_PATH_TEMPLATES
+ File.separator + "ballerinaToml.vm",
+ BallerinaProjectConstants.RESOURCE_PATH_SEPERATOR + "ballerinaToml.vm",
createTemplateContextForToml(generatorProperties), directoryPath, "Ballerina.toml");
}

Expand Down

0 comments on commit cd13e9d

Please sign in to comment.