Build React Native App (4) - Redux, Jest, and NativeBase

Image
From this blog, typescript feature will be added. There are couple of ways to implement static type checking like; flow from facebook, PropTypes and Typescript. Typescript is well integrated with Visual Studio Code and supports better linter, error messages, and intellisense. Reference site Github Sample Ex4 Currnet version D:\GitRepo\reactnative>npm --version 6.3.0 D:\GitRepo\reactnative>react-native --version react-native-cli: 2.0.1 react-native: n/a - not inside a React Native project directory D:\GitRepo\reactnative>yarn --version 1.9.4 Creating React Native App $ react-native init ex4 If you want to specify the version, add "--version 0.57.3" at the end. Add NativeBase to React Native $ npm install native-base --save ... + native-base@2.8.1 added 71 packages from 42 contributors, removed 50 packages, updated 829 packages and audited 34989 packages in 138.542s found 0 vulnerabilities $ $ yarn yarn install v1.9.4 warning package-lock.json found. You

Use bitbucket as private Maven repository

Introdcution

I've been using bitbucket cloud service and we would like to use pipeline, but we have a challenge on the library. Most project has library and will be needed our own repository. However, this has drawback to use pipleline if we set the repository type as private. We can't set the login and password from cloud.

Implementation Steps

  1. Generate ssh key
  2. Upload the key to bitbucket setting
  3. Test bitbucket ssh connection
  4. Create Repsository in Bitbucket
  5. Add plugin to pom.xml
  6. Add repository to pom.xml
  7. Add distributeManagement to pom.xml
  8. Set login and password for the git protocol

There are two ways to configure bitbucket as repository; one method is to use one repository with two different branch and the other mehtod is to use two different repositories to servce release and snapshot. We will choose 2nd choice.

1. Generate ssh key

Run ssh-keygen to generate id_rsa.pub key

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/alexjoh/.ssh/id_rsa):
Created directory '/Users/alexjoh/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/alexjoh/.ssh/id_rsa.
Your public key has been saved in /Users/alexjoh/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ER8bDtboRDUyIs6f/qBE4om3L+2f+/lkaKc2Hsrc0+w alexjoh@Alexs-MBP.hitronhub.home
The key's randomart image is:
+---[RSA 2048]----+
|    . ..B+=      |
|   o . ooB.=     |
|    o  o. +      |
|     . ...       |
|  . . o S        |
| o + .   .       |
|. +.. o +o+      |
| ..o.+ B+Bo      |
|  .++.B=B=E      |
+----[SHA256]-----+
alexjoh at Alexs-MBP in ~/Projects/repos/personal/blogmarkdown on master*
$ ls ~/.ssh/id_rsa.pub
/Users/alexjoh/.ssh/id_rsa.pub
alexjoh at Alexs-MBP in ~/Projects/repos/personal/blogmarkdown on master*
$

2. Upload the key to bitbucket setting

  • Copy id_rsa.pub contents to clipboard

  • Click profile icon and click and user setting

Bitbucket profile setting

Select Bitbucket Setting

Bitbucket SSH Keys

Select SSH Keys

Click Add Key

Bicbucket Add SSH Keys

Click Add Keys

3. Test bitbucket ssh connection

alexjoh at Alexs-MBP in ~/Projects/repos/personal/blogmarkdown on master*
$ ssh -T alexjoh@bitbucket.org
Warning: Permanently added the RSA host key for IP address '104.192.143.3' to the list of known hosts.
logged in as alexjoh.

You can use git or hg to connect to Bitbucket. Shell access is disabled.

If you see the "logged in ...", the ssh connection is working

4. Create Repsository in Bitbucket

There are two ways to configure for Maven repository. One is using branches, release and snapshots, and the other is creating two different repository. I prefer the second options, so I will create two maven repositories called "maven_release" and "maven_snapshots".

Maven Repos

5. Add plugin repository to pom.xml

To work with this, you will need special plugin for bitbucket

    <pluginRepositories>
        <pluginRepository>
            <id>synergian-repo</id>
            <url>https://raw.github.com/synergian/wagon-git/releases</url>
        </pluginRepository>
    </pluginRepositories>

Note: This part can be configured in settings.xml file as well.

6. Add repository to pom.xml

<repositories>
        <repository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>maven_release</id>
            <name>Maven Release</name>
            <url>git:master://git@bitbucket.org:flairitshare/maven_release.git</url>
        </repository>
        <repository>
            <id>maven_snapshot</id>
            <name>Maven Snapshot</name>
            <url>git:master://git@bitbucket.org:flairitshare/maven_snapshots.git</url>
        </repository>
    </repositories>

Note: This part can be configured in settings.xml file as well.

7. Add distributeManagement to pom.xml

    <distributionManagement>
        <repository>
            <id>maven_release</id>
            <name>Maven Release</name>
                <url>git:master://git@bitbucket.org:flairitshare/maven_release.git</url>
        </repository>
        <snapshotRepository>
            <id>maven_snapshot</id>
            <name>Maven Snapshot</name>
                <url>git:master://git@bitbucket.org:flairitshare/maven_snapshots.git</url>
        </snapshotRepository>
    </distributionManagement>   

Note: This part can be configured in settings.xml file as well.

Entire sample settings xml and pom.xml is in the github.

8. Set login and password for the git protocol

<settings>
    <localRepository>D:/mavenrepo/.m2/Repository</localRepository>
    <servers>
        <server>
            <id>maven_release</id>
            <username>username</username>
            <password>password</password>
        </server>
        <server>
            <id>maven_snapshots</id>
            <username>username</username>
            <password> password </password>
        </server> 
    </servers>    
</settings>

Result after running maven deploy

[ansible@ns01 ]$ mvn deploy
...
[INFO] Installing /home/ansible/repo/odatabuilder/target/ODataBuilder-0.0.1-SNAPSHOT.jar to /home/ansible/.m2/repository/com/local/components/ODataBuilder/0.0.1-SNAPSHOT/ODataBuilder-0.0.1-SNAPSHOT.jar
[INFO] Installing /home/ansible/repo/odatabuilder/pom.xml to /home/ansible/.m2/repository/com/local/components/ODataBuilder/0.0.1-SNAPSHOT/ODataBuilder-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ ODataBuilder ---
Downloading from snapshots: http://artifactory.svctest.local:49200/artifactory/libs-snapshot-local/com/local/components/ODataBuilder/0.0.1-SNAPSHOT/maven-metadata.xml
...

Summary

This shows how to setup bitbucket as maven repository and you can do it from github as well.

Comments

Popular posts from this blog

Export folder structure to file on Windows, Mac, and Linux

Adding SOAP Header generated by JAXB(wsimport)

Sample application for Active Directory SSO with Spring Security 4 and Waffle