diff --git a/build-config/resources/package/BalTool.toml b/build-config/resources/package/BalTool.toml index de8d558..7ac3947 100644 --- a/build-config/resources/package/BalTool.toml +++ b/build-config/resources/package/BalTool.toml @@ -2,4 +2,10 @@ id = "copybook" [[dependency]] -path = "resources/copybook-cli-@toml.version@.jar" +path = "build/libs/copybook-cli-@project.version@.jar" + +[[dependency]] +path = "build/libs/antlr4-runtime-@toml.antlrVersion@.jar" + +[[dependency]] +path = "build/libs/copybook-commons-@toml.copybookParserVersion@.jar" diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/cmd/CopybookCmd.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/cmd/CopybookCmd.java index 17a2e55..d8aa800 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/cmd/CopybookCmd.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/cmd/CopybookCmd.java @@ -71,14 +71,12 @@ public CopybookCmd() { } public CopybookCmd(PrintStream outStream, Path executionDir, boolean exitWhenFinish) { - this.outStream = outStream; this.executionPath = executionDir; this.exitWhenFinish = exitWhenFinish; } private static void exitError(boolean exit) { - if (exit) { Runtime.getRuntime().exit(1); } @@ -86,7 +84,6 @@ private static void exitError(boolean exit) { @Override public void execute() { - try { if (helpFlag) { printLongDesc(new StringBuilder()); @@ -103,7 +100,6 @@ public void execute() { } private void validateInputFlags() throws CmdException, IOException { - if (inputPathFlag) { if (argList == null) { throw new CmdException(DiagnosticMessages.COPYBOOK_TYPE_GEN_100, null); @@ -129,7 +125,6 @@ private void executeOperation() throws CopybookTypeGenerationException, CmdExcep private void generateType(String filePath) throws CmdException, CopybookTypeGenerationException, FormatterException, IOException { - final File copybookFile = new File(filePath); if (!copybookFile.exists()) { throw new CmdException(DiagnosticMessages.COPYBOOK_TYPE_GEN_102, null, @@ -149,7 +144,6 @@ private void generateType(String filePath) } private Path getTargetOutputPath() { - Path targetOutputPath = executionPath; if (this.outputPath != null) { if (Paths.get(outputPath).isAbsolute()) { diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/diagnostic/Constants.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/diagnostic/Constants.java index 6878193..da8c217 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/diagnostic/Constants.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/diagnostic/Constants.java @@ -23,7 +23,7 @@ public class Constants { " only the Copybook definition files with .cpy or .cob extension. %nPlease provide the path of the input " + " file with -i or --input flag.%ne.g: bal copybook --input "; public static final String MESSAGE_CAN_NOT_READ_COPYBOOK_FILE = - "Provided Definition file \"%s\" is not allowed to be read"; + "Provided definition file \"%s\" is not allowed to be read"; public static final String MESSAGE_FOR_INVALID_COPYBOOK_PATH = - "The Copybook definition file does not exist in the given path"; + "The copybook definition file does not exist in the given path"; } diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/diagnostic/DiagnosticMessages.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/diagnostic/DiagnosticMessages.java index a7ffa08..5c22b42 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/diagnostic/DiagnosticMessages.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/diagnostic/DiagnosticMessages.java @@ -25,8 +25,7 @@ public enum DiagnosticMessages { " is missing. Please provide the path of the Copybook definition file with -i or --input flag.", DiagnosticSeverity.ERROR), COPYBOOK_TYPE_GEN_102("COPYBOOK_TYPE_GEN_102", "Copybook types generation failed: %s", DiagnosticSeverity.ERROR), - COPYBOOK_TYPE_GEN_103("COPYBOOK_TYPE_GEN_103", "Failed to create output directory: %s", DiagnosticSeverity.ERROR), - ; + COPYBOOK_TYPE_GEN_103("COPYBOOK_TYPE_GEN_103", "Failed to create output directory: %s", DiagnosticSeverity.ERROR); private final String code; private final String description; private final DiagnosticSeverity severity; diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/AnnotationGenerator.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/AnnotationGenerator.java index 675f950..a232791 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/AnnotationGenerator.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/AnnotationGenerator.java @@ -39,7 +39,6 @@ public class AnnotationGenerator { public static AnnotationNode generateStringConstraint(DataItem node) { - List fields = getStringAnnotFields(node); if (fields.isEmpty()) { return null; @@ -50,7 +49,6 @@ public static AnnotationNode generateStringConstraint(DataItem node) { } public static AnnotationNode generateIntConstraint(DataItem node) { - List fields = getIntAnnotFields(node); if (fields.isEmpty()) { return null; @@ -61,7 +59,6 @@ public static AnnotationNode generateIntConstraint(DataItem node) { } public static AnnotationNode generateNumberConstraint(DataItem node) { - List fields = getNumberAnnotFields(node); if (fields.isEmpty()) { return null; @@ -72,7 +69,6 @@ public static AnnotationNode generateNumberConstraint(DataItem node) { } private static List getStringAnnotFields(DataItem node) { - List fields = new ArrayList<>(); int value = node.getReadLength(); String fieldRef = GeneratorConstants.MAX_LENGTH + GeneratorConstants.COLON + value; @@ -81,7 +77,6 @@ private static List getStringAnnotFields(DataItem node) { } private static List getIntAnnotFields(DataItem node) { - List fields = new ArrayList<>(); if (!node.isSinged()) { int minValue = 0; @@ -95,11 +90,12 @@ private static List getIntAnnotFields(DataItem node) { } private static List getNumberAnnotFields(DataItem node) { - List fields = new ArrayList<>(); int maxIntegerDigits = 1; - if (node.isSinged() || node.getPicture().startsWith(NEGATIVE_DECIMAL_PIC) || node.getPicture().startsWith( - GeneratorConstants.POSITIVE_DECIMAL_PIC)) { + if (node.isSinged()) { + maxIntegerDigits = node.getReadLength() - node.getFloatingPointLength() - 1; + } else if (node.getPicture().startsWith(NEGATIVE_DECIMAL_PIC) || + node.getPicture().startsWith(GeneratorConstants.POSITIVE_DECIMAL_PIC)) { maxIntegerDigits = node.getReadLength() - node.getFloatingPointLength() - 2; } else { int minValue = 0; @@ -116,10 +112,9 @@ private static List getNumberAnnotFields(DataItem node) { } public static AnnotationNode createAnnotationNode(String annotationReference, String annotFields) { - MappingConstructorExpressionNode annotationBody = null; - SimpleNameReferenceNode annotReference = createSimpleNameReferenceNode( - createIdentifierToken(annotationReference)); + SimpleNameReferenceNode annotReference = + createSimpleNameReferenceNode(createIdentifierToken(annotationReference)); ExpressionNode expressionNode = NodeParser.parseExpression(annotFields); if (expressionNode.kind() == MAPPING_CONSTRUCTOR) { annotationBody = (MappingConstructorExpressionNode) expressionNode; diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/ArrayTypeGenerator.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/ArrayTypeGenerator.java index d888911..8680716 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/ArrayTypeGenerator.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/ArrayTypeGenerator.java @@ -50,8 +50,8 @@ public ArrayTypeGenerator(CopybookNode groupItemNode) { this.schemaValue = groupItemNode; } - @Override public TypeDescriptorNode generateTypeDescriptorNode(List typeDefList) { - + @Override + public TypeDescriptorNode generateTypeDescriptorNode(List typeDefList) { if (schemaValue instanceof GroupItem) { return getGroputItemDescriptorNode(typeDefList); } else { @@ -60,7 +60,6 @@ public ArrayTypeGenerator(CopybookNode groupItemNode) { } private TypeDescriptorNode getGroputItemDescriptorNode(List typeDefList) { - BasicLiteralNode length = createBasicLiteralNode(SyntaxKind.NUMERIC_LITERAL, createLiteralValueToken(SyntaxKind.DECIMAL_INTEGER_LITERAL_TOKEN, String.valueOf(schemaValue.getOccurringCount()), @@ -75,7 +74,6 @@ private TypeDescriptorNode getGroputItemDescriptorNode(List } private TypeDescriptorNode getDataItemDescriptorNode(List typeDefList) { - TypeDefinitionNode fieldType = generateFieldTypeDefNode( (DataItem) schemaValue, getTypeReferenceName(schemaValue, false)); addToFieldTypeDefinitionList(fieldType, typeDefList); diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CodeGenerator.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CodeGenerator.java index 7d88470..90102bb 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CodeGenerator.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CodeGenerator.java @@ -38,12 +38,10 @@ public abstract class CodeGenerator { protected CodeGenerator() { - } public static void generate(Path cbFilePath, Path targetOutputPath, PrintStream outStream) throws CopybookTypeGenerationException, FormatterException, IOException { - Schema schema = Copybook.parse(cbFilePath.toString()); if (!schema.getErrors().isEmpty()) { List errorList = schema.getErrors(); diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CodeGeneratorUtils.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CodeGeneratorUtils.java index cd7a385..d70a290 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CodeGeneratorUtils.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CodeGeneratorUtils.java @@ -72,39 +72,33 @@ private CodeGeneratorUtils() { } public static TypeGenerator getTypeGenerator(CopybookNode schemaValue) { - if (schemaValue.getOccurringCount() > 0) { return new ArrayTypeGenerator(schemaValue); } else if (schemaValue instanceof DataItem dataItem) { return new ReferencedTypeGenerator(dataItem); - } else { - return new RecordTypeGenerator((GroupItem) schemaValue); } + return new RecordTypeGenerator((GroupItem) schemaValue); } public static String getTypeReferenceName(CopybookNode copybookNode, boolean isRecordFieldReference) { - if (copybookNode instanceof DataItem dataItem) { if (isRecordFieldReference) { return extractTypeReferenceName(dataItem); - } else { - if (dataItem.isNumeric()) { - if (dataItem.getFloatingPointLength() > 0) { - return DECIMAL; - } - return INT; - } else if (dataItem.getPicture().contains(COMP_PIC)) { - return BYTE_ARRAY; - } else { - return STRING; + } + if (dataItem.isNumeric()) { + if (dataItem.getFloatingPointLength() > 0) { + return DECIMAL; } + return INT; + } else if (dataItem.getPicture().contains(COMP_PIC)) { + return BYTE_ARRAY; } + return STRING; } return copybookNode.getName(); } public static ImportDeclarationNode getImportDeclarationNode(String orgName, String moduleName) { - Token importKeyword = AbstractNodeFactory.createIdentifierToken(IMPORT, SINGLE_WS_MINUTIAE, SINGLE_WS_MINUTIAE); Token orgNameToken = AbstractNodeFactory.createIdentifierToken(orgName); @@ -119,7 +113,6 @@ public static ImportDeclarationNode getImportDeclarationNode(String orgName, Str } public static NodeList createImportDeclarationNodes() { - List imports = new ArrayList<>(); ImportDeclarationNode importForHttp = CodeGeneratorUtils.getImportDeclarationNode(GeneratorConstants.BALLERINA, GeneratorConstants.CONSTRAINT); @@ -128,25 +121,21 @@ public static NodeList createImportDeclarationNodes() { } private static MinutiaeList getSingleWSMinutiae() { - Minutiae whitespace = AbstractNodeFactory.createWhitespaceMinutiae(" "); return AbstractNodeFactory.createMinutiaeList(whitespace); } public static AnnotationNode generateConstraintNode(DataItem dataItem) { - String ballerinaType = getConstraintType(dataItem); if (ballerinaType.equals(DECIMAL)) { return generateNumberConstraint(dataItem); } else if (ballerinaType.equals(INT)) { return generateIntConstraint(dataItem); - } else { - return generateStringConstraint(dataItem); } + return generateStringConstraint(dataItem); } private static String getConstraintType(DataItem dataItem) { - if (dataItem.isNumeric() && dataItem.getFloatingPointLength() > 0) { return DECIMAL; } else if (dataItem.isNumeric()) { @@ -156,7 +145,6 @@ private static String getConstraintType(DataItem dataItem) { } public static String extractTypeReferenceName(DataItem dataItem) { - String typeName = null; if (dataItem.isNumeric()) { if (dataItem.getFloatingPointLength() > 0) { @@ -193,7 +181,6 @@ public static String extractTypeReferenceName(DataItem dataItem) { } public static String getValidName(String identifier) { - if (!identifier.matches("\\b[0-9]*\\b")) { String[] split = identifier.split(GeneratorConstants.SPECIAL_CHAR_REGEX); StringBuilder validName = new StringBuilder(); @@ -208,7 +195,6 @@ public static String getValidName(String identifier) { } public static String escapeIdentifier(String identifier) { - if (identifier.matches("\\b[0-9]*\\b")) { return "'" + identifier; } else if (!identifier.matches("\\b[_a-zA-Z][_a-zA-Z0-9]*\\b") @@ -238,7 +224,6 @@ public static String escapeIdentifier(String identifier) { } public static String getFileName(String filePath) { - String fileName = filePath.substring(filePath.lastIndexOf(File.separator) + 1); fileName = fileName.substring(0, fileName.lastIndexOf('.')); return String.join("", fileName, BAL_EXTENSION); diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CopybookTypeGenerator.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CopybookTypeGenerator.java index 2bfda30..60111d9 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CopybookTypeGenerator.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/CopybookTypeGenerator.java @@ -62,13 +62,11 @@ public class CopybookTypeGenerator { private final List fieldTypeDefinitionList; public CopybookTypeGenerator(Schema schema) { - this.schema = schema; this.fieldTypeDefinitionList = new ArrayList<>(); } public String generateSourceCode() throws FormatterException { - List typeDefinitions = schema.getTypeDefinitions(); List typeDefinitionList = new ArrayList<>(); typeDefinitions.forEach(typeDefinition -> typeDefinitionList.add(generateTypeDefNode(typeDefinition))); @@ -78,7 +76,6 @@ public String generateSourceCode() throws FormatterException { } public List addRecordFields(List fields) { - List recordFieldList = new ArrayList<>(); for (CopybookNode fieldNode : fields) { String fieldNameStr = CodeGeneratorUtils.escapeIdentifier(fieldNode.getName().trim()); @@ -92,7 +89,6 @@ public List addRecordFields(List imports = createImportDeclarationNodes(); NodeList moduleMembers = AbstractNodeFactory.createNodeList( fieldTypeDefinitionList.toArray(new TypeDefinitionNode[0])); @@ -129,7 +124,6 @@ public SyntaxTree generateSyntaxTree() { } public static void addToFieldTypeDefinitionList(TypeDefinitionNode node, List typeDefList) { - boolean isExist = typeDefList.stream().anyMatch(typeDefinitionNode -> typeDefinitionNode.typeName().toString().equals(node.typeName().toString())); if (!isExist) { diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/GeneratorConstants.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/GeneratorConstants.java index fbf4b3f..07f041f 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/GeneratorConstants.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/GeneratorConstants.java @@ -24,6 +24,9 @@ public class GeneratorConstants { + private GeneratorConstants() { + } + public static final String SPECIAL_CHAR_REGEX = "([\\[\\]\\\\?!<>@#&~`*\\=^+();:\\/\\_{}\\s|.$])"; public static final String ESCAPE_PATTERN = "([\\[\\]\\\\?!<>@#&~`*\\-=^+();:\\/\\_{}\\s|.$])"; diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/RecordTypeGenerator.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/RecordTypeGenerator.java index e637b86..856d2ff 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/RecordTypeGenerator.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/RecordTypeGenerator.java @@ -45,12 +45,11 @@ public class RecordTypeGenerator extends TypeGenerator { GroupItem groupItemNode; public RecordTypeGenerator(GroupItem groupItemNode) { - this.groupItemNode = groupItemNode; } - @Override public TypeDescriptorNode generateTypeDescriptorNode(List typeDefList) { - + @Override + public TypeDescriptorNode generateTypeDescriptorNode(List typeDefList) { List recordFields = new LinkedList<>(); RecordMetadata metadataBuilder = getRecordMetadata(); List fields = groupItemNode.getChildren(); @@ -63,7 +62,6 @@ public RecordTypeGenerator(GroupItem groupItemNode) { } public List addRecordFields(List fields, List typeDefList) { - List recordFieldList = new ArrayList<>(); for (CopybookNode field : fields) { String fieldNameStr = CodeGeneratorUtils.escapeIdentifier(field.getName().trim()); diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/ReferencedTypeGenerator.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/ReferencedTypeGenerator.java index 9b6a7a2..7349df6 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/ReferencedTypeGenerator.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/generator/ReferencedTypeGenerator.java @@ -35,7 +35,6 @@ public class ReferencedTypeGenerator extends TypeGenerator { DataItem fieldSchema; public ReferencedTypeGenerator(DataItem fieldSchema) { - this.fieldSchema = fieldSchema; } @@ -44,7 +43,6 @@ public ReferencedTypeGenerator(DataItem fieldSchema) { */ @Override public TypeDescriptorNode generateTypeDescriptorNode(List typeDefList) { - String extractName = getTypeReferenceName(fieldSchema, true); String typeName = CodeGeneratorUtils.getValidName(extractName); TypeDefinitionNode fieldType = generateFieldTypeDefNode(fieldSchema, getTypeReferenceName(fieldSchema, false)); diff --git a/copybook-cli/src/main/java/io/ballerina/tools/copybook/utils/NullLocation.java b/copybook-cli/src/main/java/io/ballerina/tools/copybook/utils/NullLocation.java index 4002888..a5b48c9 100644 --- a/copybook-cli/src/main/java/io/ballerina/tools/copybook/utils/NullLocation.java +++ b/copybook-cli/src/main/java/io/ballerina/tools/copybook/utils/NullLocation.java @@ -38,14 +38,12 @@ public static synchronized NullLocation getInstance() { @Override public LineRange lineRange() { - LinePosition from = LinePosition.from(-2, -2); return LineRange.from("", from, from); } @Override public TextRange textRange() { - return TextRange.from(-2, -2); } } diff --git a/copybook-cli/src/test/java/io/ballerina/tools/copybook/cmd/CopybookCmdTest.java b/copybook-cli/src/test/java/io/ballerina/tools/copybook/cmd/CopybookCmdTest.java index 1debe61..dfd5f63 100644 --- a/copybook-cli/src/test/java/io/ballerina/tools/copybook/cmd/CopybookCmdTest.java +++ b/copybook-cli/src/test/java/io/ballerina/tools/copybook/cmd/CopybookCmdTest.java @@ -34,13 +34,11 @@ public class CopybookCmdTest extends CopybookTest { @BeforeTest(description = "This will create a new ballerina project for testing below scenarios.") public void setupBallerinaProject() throws IOException { - super.setup(); } @Test(description = "Test copybook command with help flag") public void testCopybookHelpFlag() throws IOException { - String[] args = {"-h"}; CopybookCmd copybookCmd = new CopybookCmd(printStream, tmpDir, false); new CommandLine(copybookCmd).parseArgs(args); @@ -52,7 +50,6 @@ public void testCopybookHelpFlag() throws IOException { @Test(description = "Test copybook command with help flag") public void testCopybookTypeGeneration() throws IOException { - String[] args = {"-i", resourceDir.resolve("copybookDefinitions/valid/copybook.cob").toString(), "-o", tmpDir.toString()}; CopybookCmd copybookCmd = new CopybookCmd(printStream, tmpDir, false); @@ -69,7 +66,6 @@ public void testCopybookTypeGeneration() throws IOException { @Test(description = "Test copybook type generation with multiple root levels") public void testTypeGenerationWithMultipleRootLevels() throws IOException { - String[] args = {"-i", resourceDir.resolve("copybookDefinitions/valid/hospital.cpy").toString(), "-o", tmpDir.toString()}; CopybookCmd copybookCmd = new CopybookCmd(printStream, tmpDir, false); @@ -86,7 +82,6 @@ public void testTypeGenerationWithMultipleRootLevels() throws IOException { @Test(description = "Test copybook type generation with multiple root levels") public void testTypeGenerationWithRedefines() throws IOException { - String[] args = {"-i", resourceDir.resolve("copybookDefinitions/valid/redefine.cpy").toString(), "-o", tmpDir.toString()}; CopybookCmd copybookCmd = new CopybookCmd(printStream, tmpDir, false); @@ -103,7 +98,6 @@ public void testTypeGenerationWithRedefines() throws IOException { @Test(description = "Test copybook type generation with multiple root levels") public void testTypeGenerationForInvalidSchema() throws IOException { - String[] args = {"-i", resourceDir.resolve("copybookDefinitions/invalid/copybook.cpy").toString(), "-o", tmpDir.toString()}; CopybookCmd copybookCmd = new CopybookCmd(printStream, tmpDir, false); diff --git a/copybook-cli/src/test/java/io/ballerina/tools/copybook/cmd/TestUtils.java b/copybook-cli/src/test/java/io/ballerina/tools/copybook/cmd/TestUtils.java index 21d6375..3634905 100644 --- a/copybook-cli/src/test/java/io/ballerina/tools/copybook/cmd/TestUtils.java +++ b/copybook-cli/src/test/java/io/ballerina/tools/copybook/cmd/TestUtils.java @@ -25,6 +25,10 @@ import java.util.stream.Stream; public class TestUtils { + + private TestUtils() { + } + protected static String readContentWithFormat(Path filePath) throws IOException { Stream schemaLines = Files.lines(filePath); String schemaContent = schemaLines.collect(Collectors.joining(System.getProperty("line.separator"))); diff --git a/copybook-tool/Ballerina.toml b/copybook-tool/Ballerina.toml index 8b35c51..ccdcf94 100644 --- a/copybook-tool/Ballerina.toml +++ b/copybook-tool/Ballerina.toml @@ -2,4 +2,7 @@ org = "ballerina" name = "copybook" version = "0.1.0" +authors = ["Ballerina"] +keywords = ["copybook"] +license = ["Apache-2.0"] distribution = "2201.8.0" diff --git a/copybook-tool/build.gradle b/copybook-tool/build.gradle index 72b46c1..c0800a6 100644 --- a/copybook-tool/build.gradle +++ b/copybook-tool/build.gradle @@ -16,9 +16,7 @@ */ import org.apache.tools.ant.taskdefs.condition.Os -version stripBallerinaExtensionVersion("${project.version}") - -description = 'Ballerina - Copybook took package' +description = 'Ballerina - Copybook tool package' def packageName = "copybook" def packageOrg = "ballerina" @@ -34,8 +32,9 @@ tasks.register('updateTomlFiles') { newConfig = newConfig.replace("@toml.version@", tomlVersion) ballerinaTomlFile.text = newConfig - def newToolConfig = balToolTomlFilePlaceHolder.text.replace("@project.version@", project.version) - newToolConfig = newToolConfig.replace("@toml.version@", tomlVersion) + def newToolConfig = balToolTomlFilePlaceHolder.text.replace("@project.version@", version) + newToolConfig = newToolConfig.replace("@toml.antlrVersion@", antlrVersion) + newToolConfig = newToolConfig.replace("@toml.copybookParserVersion@", copybookParserVersion) balToolTomlFile.text = newToolConfig } } @@ -71,4 +70,6 @@ tasks.register('copyCopybookCliJar') { copyCopybookCliJar.dependsOn deleteOldCopybookCliJars copyCopybookCliJar.dependsOn ":copybook-cli:build" +commitTomlFiles.dependsOn updateTomlFiles +copyCopybookCliJar.dependsOn commitTomlFiles build.dependsOn copyCopybookCliJar