Fineract-CN projects depend on each other. The simplest option is to build all projects locally so artifacts are published to local maven repository and available from there.

Sometomes still there is need to only work with a single project and resolve the other fineract-cn-* dependencies from public repository. Also in order for continous integration (Travis-ci.com) to build a specific project it needs that all the dependencies are available.

JFrog Artifactory has been set up to host these artifacts in https://mifos.jfrog.io/mifos/. Maven Central would not be suitable for the task as it doesn't hold "work-in-progress" snapshots.

In this artifacotry there are two repositories:

In order to use snapshot builds one needs to have following line in repositories list:

repositories {
  jcenter()
  mavenLocal()
  maven { url 'https://mifos.jfrog.io/mifos/libs-snapshot/' }
}

How snapshots are built by Travis

All apache/fineract-cn-* repositories are configured to be built with Travis-CI.com. Whenever something is pushed to a repository travis tries to run gradle build on it. Travis also detects the branch name that the changes were pushed to.

Changes pushed/merged to "develop" branch

If travis detects that the changes were pushed to "develop" branch and build doesn't fail then it uploads the new snapshot artifacts to the public repository. You can pick them up the same way as artifacts deployed to local Maven:

dependencies {
compile(
[group: 'org.apache.fineract.cn', name: 'reponame', version: '0.1.0-BUILD-SNAPSHOT']
)
)

Changes pushed/merged to other branches (not "develop")

Travis builds and publishes the snapshots out of all branches but for branches not named "develop" it overwrites the version of the artifact (defined in build.gradle) with "branchname-SNAPSHOT". If you want to point some other project to branch "myfeaturebranch" then you need to use:

dependencies {
compile(
[group: 'org.apache.fineract.cn', name: 'reponame', version: 'myfeaturebranch-SNAPSHOT']
)
)

Handling pull requests

Travis also builds all pull requests but for security reasons it doesn't upload any artifacts built from pull requests.

How releases work

If a release is tagged in github then Travis-CI builds that as a release and uploads it under different repoKey - release artifacts are available at https://mifos.jfrog.io/mifos/libs-release

Travis and Artifactory setup

Following instructions are useful if you want to set up a new project or change existing setup.

Configure a new fineract-cn-* project to upload artifacts to artifactory

Encrypt Artifactory password


You need command line travis client.

travis encrypt --com -r apache/fineract-cn-reponame ARTIFACTORY_PASSWORD=enter-password-here

copy the encrypted secure value to .travis.yml

How to test build locally


export ARTIFACTORY_URL=https://mifos.jfrog.io/mifos ARTIFACTORY_USER=travis-ci ARTIFACTORY_PASSWORD=xxx

./gradlew -PartifactoryRepoKey=libs-snapshot-local artifactoryPublish


Verify

Design principles

JFrog Artifactory configuration

How to verify that the new artifact was uploaded

Let's take this pull request as an example: https://github.com/apache/fineract-cn-lang/pull/10

When this pull request was merged - new jar (and pom) should have been built and uploaded to Mifos Jfrog Artifactory. Let's check if it happened correctly.

We can check the Travis builds of fineract-cn-lang from here: https://travis-ci.com/apache/fineract-cn-lang/builds

Find the correct pull request from the list (pull request #10) and on the same line click on "develop" in the beginning of row.

Build details page (https://travis-ci.com/apache/fineract-cn-lang/builds/114688396) opens up. 

Scroll to the end of the logs - you can see:

Deploying artifact: https://mifos.jfrog.io/mifos/libs-snapshot-local/org/apache/fineract/cn/lang/0.1.0-BUILD-SNAPSHOT/lang-0.1.0-BUILD-SNAPSHOT.jar

Now we can navigate to Jfrog and check if we see it from there:

Go to Artifactory (no need to log in): https://mifos.jfrog.io/mifos/

Choose "Artifact repository browser" icon from the left (icon is like pile of paper).

You will end up on this page: https://mifos.jfrog.io/mifos/webapp/#/artifacts/browse/tree/General/libs-release

Choose "libs-snapshot" from the left. You will end up here: 

https://mifos.jfrog.io/mifos/webapp/#/artifacts/browse/tree/General/libs-snapshot

Click "find" icon on top and search "fineract-cn-lang".

"org" appears in search result. Expand it to org → apache → fineract → cn → lang → 0.1.0-BUILD-SNAPSHOT

In the end of list you should see the uploaded artifact (you can use the upload date to check).

In our example the uploaded artifact is this:

https://mifos.jfrog.io/mifos/webapp/#/artifacts/browse/tree/General/libs-snapshot/org/apache/fineract/cn/lang/0.1.0-BUILD-SNAPSHOT/lang-0.1.0-BUILD-20190607.052703-26.jar