Skip to content

Latest commit

 

History

History
177 lines (132 loc) · 7.73 KB

File metadata and controls

177 lines (132 loc) · 7.73 KB

Contributing to commercetools-sync-java

These are the contribution guidelines for the commercetools-sync-java.

Thanks for taking the time to contribute 👍🎉 All contributions are welcome!

Contribution process for all committers

Typos

If you have push access to the repository you can fix them directly otherwise just make a pull request.

Features or Bug Fixes

  • Every PR should address an issue on the repository. If the issue doesn't exist, please create it first and link PR with the issue.
  • After your PR is approved by all reviewers and the build is green:
    • Use Squash and merge option on a pull request on GitHub, with that the pull request's commits should be squashed into a single commit.

      Instead of seeing all of a contributor's individual commit messages, the commits should be combined into one commit message with a clear commit description.

    • Delete the branch when the PR is closed.
    • Close the issue only if the change was released.

Development

Build

Run unit tests
./gradlew test
Package JARs
./gradlew clean jar
Package JARs and run tests
./gradlew clean check
Full build with tests, but without install to maven local repo (Recommended)
./gradlew clean build
Install to local maven repo
./gradlew clean install
Publish JavaDoc
./gradlew clean javadoc gitPublishPush -Dbuild.version={version}
Build and publish to Maven Central
./gradlew clean -Dbuild.version={version} publishToSonatype closeAndReleaseSonatypeStagingRepository

For more detailed information on the build and the release process, see Build and Release documentation.

Integration Tests

  1. The integration tests of the library require to have two CTP projects (a source project and a target project) where the data will be tested to be synced from the source to the target project.

  2. Running the tests does the following:

    • Clean all the data on both projects.
    • Create test data in either/both projects depending on the test.
    • Execute the tests.
    • Clean all the data in both projects, leaving them empty.

Running

To run the integration tests, CTP credentials are required. The credential can be obtained once you create a CTP project. For details, please refer to the following link: https://docs.commercetools.com/merchant-center/projects.html#creating-a-project

  1. Use credentials Java properties file /src/integration-test/resources/it.properties:
source.projectKey=aaaaa
source.clientId=bbbbbbb
source.clientSecret=ccc
  
target.projectKey=ddddd
target.clientId=eeeeeee
target.clientSecret=fff

Use it.properties.skeleton as a template to setup the credentials.

Note: the it.properties file must be ignored by VCS.

  1. Set the following environment variables:
export SOURCE_PROJECT_KEY = xxxxxxxxxxxxx
export SOURCE_CLIENT_ID = xxxxxxxxxxxxxxx
export SOURCE_CLIENT_SECRET = xxxxxxxxxxx
export TARGET_PROJECT_KEY = xxxxxxxxxxxxx
export TARGET_CLIENT_ID = xxxxxxxxxxxxxxx
export TARGET_CLIENT_SECRET = xxxxxxxxxxx

Note: it.properties file has precedence over environment variables. If the file exists - the environment variables are ignored. If the existing it.properties file is empty or one of the properties is missing - exception will be thrown on the execution of the tests

If one of the two options above is set - run the integration tests:

./gradlew integrationTest

Using the google java style and code formatter

We are using google-java-format to format Java source code to comply with Google Java Style.

IntelliJ, Android Studio, and other JetBrains IDEs

A google-java-format IntelliJ plugin is available from the plugin repository. To install it, go to your IDE's settings and select the Plugins category. Click the Marketplace tab, search for the google-java-format plugin, and click the Install button.

The plugin will be disabled by default. To enable it in the current project, go to File→Settings...→google-java-format Settings (or IntelliJIDEA→Preferences...→Other Settings→google-java-format Settings on macOS) and check the Enable google-java-format checkbox. (A notification will be presented when you first open a project offering to do this for you.)

To enable it by default in new projects, use File→Other Settings→Default Settings.... When enabled, it will replace the normal Reformat Code action, which can be triggered by the Code menu or with the Ctrl-Alt (by default) keyboard shortcut.

Eclipse

google-java-format Eclipse plugin can be downloaded from the releases page. Drop it into the Eclipsedrop-ins folderto activate the plugin.

The plugin adds a google-java-format formatter implementation that can be configured in Window > Preferences > Java > Code Style > Formatter > Formatter Implementation.

Spotless commands

Run Spotless Style Check
./gradlew spotlessCheck
Fix Spotless style violations
./gradlew spotlessApply

Ignoring mass reformatting commits with git blame

To exclude the formatting commits git blame supports writing the commit hashes into a file and then referencing the file with --ignore-revs-file.
To be able to archive that git blame ./file.java --ignore-revs-file .git-blame-ignore-revs command to ignore this revision to find a better git history.

Also git config blame.ignoreRevsFile .git-blame-ignore-revs could be configured to ignore this revision always.

We create .git-blame-ignore-revs that could be found in the repository.