Skip to content

Conversation

@charbelmkh
Copy link
Contributor

This PR introduces both the Android CodeGen and templates being used internally to generate all our Android Clients.

The changes includes:-

How to use the boat-android generator

  1. Clone the project
  2. Checkout the branch feat/boat-android
  3. Open Terminal and navigate to the project folder and run mvn clean install -Dgpg.skip
  4. Navigate to the folder where your api spec is
  5. Create a pom.xml file and add the following
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <name>boat-maven-plugin-android</name>
    <url>http://maven.apache.org</url>
    <groupId>com.backbase.oss</groupId>
    <artifactId>boat-android-test</artifactId>
    <version>1.0</version>
    <properties>
        <!--
        Replace Values as per the below example.
        <clientSpec.nameWithMajor>arrangement-client-api-v2</clientSpec.nameWithMajor>
        <clientSpec.moduleName>gen2-arrangement-client-2</clientSpec.moduleName>
        <clientSpec.generation>gen2</clientSpec.generation>
        <clientSpec.javaPackageName>arrangementclient2</clientSpec.javaPackageName>
        <clientVersion>1.0.3</clientVersion>
        -->
        <clientSpec.nameWithMajor>NAME_YAML_FILE_WITHOUT_EXTENSION</clientSpec.nameWithMajor>
        <clientSpec.moduleName>NAME_OF_GENERATED_CLIENT</clientSpec.moduleName>
        <clientSpec.generation>GENERATION_OF_CLIENT</clientSpec.generation>
        <clientSpec.javaPackageName>PACKAGE_NAME</clientSpec.javaPackageName>
        <clientVersion>ARTIFACT_VERSION</clientVersion>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>com.backbase.oss</groupId>
                <artifactId>boat-maven-plugin</artifactId>
                <version>0.17.17-SNAPSHOT</version>
                <configuration>
                    <openapiNormalizer>
                        <normalizer>REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true</normalizer>
                        <normalizer>SIMPLIFY_ONEOF_ANYOF=true</normalizer>
                    </openapiNormalizer>
                    <generateApiDocumentation>false</generateApiDocumentation>
                    <generateModelDocumentation>false</generateModelDocumentation>
                    <skipValidateSpec>true</skipValidateSpec>
                    <inputSpec>${project.basedir}/${clientSpec.nameWithMajor}.yaml</inputSpec>
                    <!--<templateDirectory>client-templates/android-client</templateDirectory>-->
                    <generatorName>boat-android</generatorName>
                    <groupId>com.backbase.android.client</groupId>
                    <artifactId>${clientSpec.moduleName}</artifactId>
                    <apiPackage>com.backbase.android.client.${clientSpec.generation}.${clientSpec.javaPackageName}.api
                    </apiPackage>
                    <modelPackage>
                        com.backbase.android.client.${clientSpec.generation}.${clientSpec.javaPackageName}.model
                    </modelPackage>
                    <typeMappings>
                        <typeMapping>array=kotlin.collections.List</typeMapping>
                        <typeMapping>file=kotlin.ByteArray</typeMapping>
                    </typeMappings>
                    <output>${clientSpec.moduleName}</output>
                    <enablePostProcessFile>true</enablePostProcessFile>
                    <artifactVersion>${clientVersion}</artifactVersion>
                    <packageName>com.backbase.android.${clientSpec.javaPackageName}</packageName>
                    <additionalProperties>
                        <additionalProperty>parcelizeModels=true</additionalProperty>
                        <additionalProperty>dateLibrary=java8</additionalProperty>
                        <additionalProperty>serializationLibrary=moshi</additionalProperty>
                        <additionalProperty>sourceFolder=src/main/java</additionalProperty>
                        <additionalProperty>enumPropertyNaming=PascalCase</additionalProperty>
                        <additionalProperty>modelDocs=false</additionalProperty>
                        <additionalProperty>apiDocs=false</additionalProperty>
                    </additionalProperties>
                    <model/>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
  1. Execute mvn clean package from this folder

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

83.6% 83.6% Coverage
0.0% 0.0% Duplication

@charbelmkh charbelmkh force-pushed the feat/boat-android branch 4 times, most recently from 82fa7ed to 3b059de Compare September 18, 2023 21:03
Updated mustache templates
Added Kotlin template instead
Added jacoco excludes (it was failing the build)
Using Default BoatAndroidClientCodegen
Added Default Android templates
@DevAgani
Copy link
Contributor

@charbelmkh I think it'll expedient if you'll replace isMapContainer with isMap and isListContainer with isArray i've had a battle with the same for Swift Clients

@charbelmkh charbelmkh merged commit e5c99f2 into main Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants