diff --git a/.travis.yml b/.travis.yml index 050cb584..62a02597 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,33 @@ language: - - ruby - +- ruby rvm: - - 2.3.0 - +- '2.3' jdk: - - oraclejdk8 - +- oraclejdk8 env: global: - - NOKOGIRI_USE_SYSTEM_LIBRARIES=true - + - NOKOGIRI_USE_SYSTEM_LIBRARIES=true + - secure: aB+J2d/LuddkTmGJ/ygnUFBL7NBJaWXwX5myI7jzJRdiMVvnw6jqpZFqrGJZ3pFp7q5sN+lZCXIG/UGCTHtr/a9I2Yg3wMjSpwp62m+2/1N6vxT+AAz96f76HDTZsIGOkhxOOhLvSg6gOrgLh8wn2xSKbcVRHJjxchD1jTxD6+o= + - secure: mIG7WfaKMeDCnENGCPn6nc3kZta7dKhQcy7mIbmceofifYVa6uXcbpKf7YyXOAlN9nHYUNQsHrThWB94BKh2Ch0/rpZx2E/yKN0ILjSO2xkfWW7LtE9C6LePMDh72VNVKOKJ2mPaLGSHHAYp8prKkGEro5H3WrWb7cPy8Jnln2I= + - secure: ZSBAwRsYDWVLMDuIbwCZhL003XSF1auo9koZ7SFV4adGcZiP+itWkeN7BaFlCLB4SmAHPxFroapyAibVvhEEAYUTeIYwWpb2Wxi0JPdku1nmx4jcRojNTjsmAmicNVykGeZWwJZpCma54OKeRzpdr/6kgIuKC54lwmujIYwhNT4= + - secure: mfJkzhFguMNu2KRSEVgn/1Oi3qJZoc2jbRWwINNuQ0ffk6LhmXh1rdgUWfi86YPoChs+YNEsAt+wgIdsZ4d/N0vthS6wyJge5E+fPHbR2dSqkRSORMLaaoK8ijhoqCQtDFijndGS2IcadoCaYEKk6z0tlVSG4olgy2p11nGHgSA= notifications: email: false - services: - - mysql - +- mysql install: true - before_script: - - export RAILS_ENV=development - # This variable needs to be unset because after rvm installs ruby 2.3, BUNDLE_GEMFILE is set to the - # Gemfile under the root path, which fails the dependency installation in the two test projects. - - unset BUNDLE_GEMFILE - +- export RAILS_ENV=development +- unset BUNDLE_GEMFILE script: - - mvn test -B -Pmysql - - bundle exec rspec +- mvn test -B -Pmysql +- bundle exec rspec +before_deploy: +- openssl aes-256-cbc -K $encrypted_498697054cdc_key -iv $encrypted_498697054cdc_iv + -in .travis/gpg.asc.enc -out .travis/gpg.asc -d +deploy: + skip_cleanup: true + on: + branch: master + provider: script + script: rvm use $TRAVIS_RUBY_VERSION do ./deploy diff --git a/.travis/gpg.asc.enc b/.travis/gpg.asc.enc new file mode 100644 index 00000000..2b8bb7d0 Binary files /dev/null and b/.travis/gpg.asc.enc differ diff --git a/.travis/mvn-settings.xml b/.travis/mvn-settings.xml new file mode 100644 index 00000000..f53d27df --- /dev/null +++ b/.travis/mvn-settings.xml @@ -0,0 +1,29 @@ + + + + + ossrh + ${env.OSSRH_JIRA_USERNAME} + ${env.OSSRH_JIRA_PASSWORD} + + + + + + ossrh + + true + + + gpg + ${env.GPG_KEY_NAME} + ${env.GPG_PASSPHRASE} + + + + diff --git a/README.md b/README.md index 85da4680..abc87757 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -Project Jack ------------- +# Jack -[![Build Status](https://travis-ci.org/LiveRamp/jack.svg?branch=master)](https://travis-ci.org/LiveRamp/jack) +[![Build Status](https://travis-ci.com/LiveRamp/jack.svg?branch=master)](https://travis-ci.com/LiveRamp/jack) Do you use Ruby/Rails and Java in your company? We do. And we're sick and tired of maintaining two different sets of schemas, models, and whatnot! @@ -11,15 +10,14 @@ To that end, we've created Jack (**J**ava **AC**tive record (+**K**)). The proje - a Ruby parser for schema.rb and ActiveRecord models that generates Java code - a Java library that provides model-oriented database access and database-wide query on top of standard database connections -Project Organization -==== +## Project Organization A Jack project consists of two things: 1. The **project definition file** 1. One or more Rails project -### Project Definition File ### +### Project Definition File The project definition file is a YAML file that tells Jack where to find your Rails projects and how to generate code. Here's an annotated example: @@ -50,22 +48,20 @@ databases: models: database_2/app/models ``` -### Rails Projects ### +### Rails Projects Jack supports generating code for an arbitrary number of inter-related Rails 3 projects. If you only have one Rails project, then things are easy - just configure your project.yml appropriately. If you have more than one project, here's the setup we suggest. (We use this ourselves.) /all_my_databases - /project.yml + /project.yml /rails_project_1 /rails_project_2 /ruby_project_that_uses_rails_project_2 /include/rails_project_2 # <= svn external to /all_my_databases/rails_project_2 - -Running the Generator -==== +### Running the Generator Running the Jack generator is easy. From a fresh clone, do the following: @@ -83,16 +79,15 @@ Assuming everything is configured correctly, that's it. _Note: We know that the path thing stinks. We're going to improve this in a future version._ -Layout of the Generated Code -==== +### Layout of the Generated Code The Java code that Jack produces is designed around interfaces so that it is very modular and mockable. -### Models ### +#### Models The generated models contain getters and setters for all the fields, as well as getters for detected associations. In contrast to ActiveRecord models, there are no CRUD methods on the Java models. -### Model Persistences ### +#### Model Persistences This is where the CRUD methods live. The generic base class supports: @@ -108,38 +103,45 @@ while there is a unique, per-model interface and implementation that additionall - create -### Databases ### +#### Databases You get one Database per database entry in your project.yml. Their main purpose is to provide a collection of all the individual model persistences. You can also execute queries across all models within each database. -### All Databases ### +#### All Databases Finally, there is one overarching Databases class that serves as a collection for all of the databases configured in your project.yml. Generally, this is what you will instantiate, though you can subsequently get the Database or Persistence instance you actually care about and use that. -Download -==== -You can either build jack from source or pull the latest jar from the Liveramp Maven repository: +## Download + +You can either build jack from source or pull the latest snapshot from +Sonatype: ```xml - repository.liveramp.com - liveramp-repositories - http://repository.liveramp.com/artifactory/liveramp-repositories + sonatype-snapshots + http://oss.sonatype.org/content/repositories/snapshots + default + + false + + + true + always + ``` -The 1.0-SNAPSHOT build can be retrieved there: +Depend on the JAR like so: ```xml - com.liveramp - jack - 1.0-SNAPSHOT + com.liveramp + jack + 1.0-SNAPSHOT ``` -License -==== +## License Copyright 2014 LiveRamp diff --git a/build.xml b/build.xml deleted file mode 100755 index 3d666faf..00000000 --- a/build.xml +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Tests failed! - - - - - - - Specified testcase was not found! - - - - - - - - - - - - - Tests failed! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/deploy b/deploy new file mode 100755 index 00000000..b71b4bea --- /dev/null +++ b/deploy @@ -0,0 +1,38 @@ +#!/bin/bash +# expects variables to be set: +# - OSSRH_JIRA_USERNAME +# - OSSRH_JIRA_PASSWORD +# - GPG_KEY_NAME +# - GPG_PASSPHRASE +# expects file to exist: +# - .travis/gpg.asc + +set -e + +# Check the variables are set +if [ -z "$OSSRH_JIRA_USERNAME" ]; then + echo "missing environment value: OSSRH_JIRA_USERNAME" >&2 + exit 1 +fi + +if [ -z "$OSSRH_JIRA_PASSWORD" ]; then + echo "missing environment value: OSSRH_JIRA_PASSWORD" >&2 + exit 1 +fi + +if [ -z "$GPG_KEY_NAME" ]; then + echo "missing environment value: GPG_KEY_NAME" >&2 + exit 1 +fi + +if [ -z "$GPG_PASSPHRASE" ]; then + echo "missing environment value: GPG_PASSPHRASE" >&2 + exit 1 +fi + +# Prepare the local keyring (requires travis to have decrypted the file +# beforehand) +gpg --fast-import .travis/gpg.asc + +# Run the maven deploy steps +mvn deploy -P publish -DskipTests=true --settings "${TRAVIS_BUILD_DIR}/.travis/mvn-settings.xml" diff --git a/pom.xml b/pom.xml index d1f7d139..49b3ed72 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,30 @@ 1.1-SNAPSHOT + Jack + A set of scripts for generating fully functional Java database models from Ruby's ActiveRecord models and migrations. + + + LiveRamp Engineering + info@liveramp.com + + + + + GitHub + https://github.com/LiveRamp/jack/issues + + + https://liveramp.com + + + + Apache 2 + https://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + root "" @@ -67,4 +91,94 @@ + + + publish + + + + + org.apache.maven.plugins + maven-source-plugin + 2.4 + + + attach-sources + + jar-no-fork + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.0.0 + + + + + none + + attach-javadocs + + jar + + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + + sign + + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + ossrh + https://oss.sonatype.org/ + true + + + + + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + +