Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A major refactoring and move to polyglot maven build #2

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

monkstone
Copy link

Hi recently I have been working on https://github.com/jruby/jruby-examples/tree/master/extensions/basic, and I thought an update of your Poplar could be used to complement it (with a nearer real world example albeit JRuby now has Rational Number support, what do you think (basically rake is all that is required to build and test ruby the Commons.Math3.Fraction is downloaded from maven repository (which is why I've changed .gitignore to exclude jars. (maven -3.3+ required)

@monkstone
Copy link
Author

@yokolet the more I've thought about the more I'm convinced myself that this would be an excellent example to include in https://github.com/jruby/jruby-examples. It has lots of advantages:-

  1. The work has been done
  2. No one is likely to try and use it seriously as Rational has now been implemented
  3. It is simple and easy to understand
  4. There is use of an underlying java library
    On the other hand the original work was done by you, and I'm not sure to if we'd be able to retain commit history at https://github.com/jruby/jruby-examples, as it would not be fork.

@monkstone
Copy link
Author

@yokolet I am completely neutral as to whether you accept this pull request, and I hope the following does not make you think this was an ambush, but in the course of this PR crystallised some ideas for me. Some time back @headius and the guys (including @mkristian) became unhappy about rake-compiler and wanted to move toward a maven type way of imposing version control on jars included in jruby-extensions. Possibly as a separate development polyglot maven was born but @mkristian is somewhat involved. One of the beauties of polyglot maven is you can write your pom in a DSL for ruby, scala, clojure (xml is horrible but I guess you are the expert), further inclusion of a pom probably creates a cross ide project for the developers (works for Netbeans, must work for eclipse I expect it works for Intellij). The bit that's missing is the ability to include jar dependencies during gem install? @mkristian is making progress in this area https://github.com/mkristian/ruby-maven-demo/tree/no_vendored_jars. In the meantime @enebo and @headius set up this project to provide a guide for jruby extensions etc, which is where I came in.
In this PR I have pushed the limits in terms of using a ruby DSL and found that it can in the main support modern (post 1.9) hashes eg

source: '1.7'
# instead of the hash-rocket form
'source' => '1.7'

And in many cases you can use snake-case in place of camel-case but there are exceptions

manifestFile: 'MANIFEST.MF' # works, manifest_file: 'MANIFEST.MF' does not

Anyway by combination of a Rakefile and pom.rb, I have been able to introduce maven version control for the developer, and providing the required artifacts (jars or pom) are available at maven central that is all that is needed dependency:copy puts the jar where you want it.

@@ -0,0 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is only needed when you use these maven-wrappers: https://github.com/takari/maven-wrapper

which I think is good thing to add. we use it for jruby build as well and recently added it to jruby-17 branch

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my bad I just copied over .mvn from my JRubyArt project (which includes maven-wrapper)

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.

2 participants