Permalink
Browse files

polishing up. added gwt command

  • Loading branch information...
1 parent 416e1c1 commit 73093a99c32ea573fef2f18cba7a24564989ac1f @mkristian committed Sep 18, 2011
Showing with 361 additions and 174 deletions.
  1. +5 −0 TODO
  2. +76 −69 pom.xml
  3. +12 −6 src/main/gemspec/maven.gemspec
  4. +59 −0 src/main/resources/bin/gwt
  5. +4 −99 src/main/resources/bin/rmvn
  6. +205 −0 src/main/resources/lib/ruby/ruby_maven.rb
View
5 TODO
@@ -0,0 +1,5 @@
+* log with rmvn prefix
+
+* rmvn rake db:migrate should look for bundler
+
+* rails rake should not default env to development, use empty default instead
View
145 pom.xml
@@ -18,76 +18,83 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.sonatype.pmaven</groupId>
- <artifactId>pmaven</artifactId>
- <version>0.8-SNAPSHOT</version>
- </parent>
-
- <groupId>rubygems</groupId>
- <artifactId>ruby-maven</artifactId>
- <packaging>gem</packaging>
- <name>ruby wrapper around maven and more</name>
-
- <dependencies>
- </dependencies>
-
- <properties>
- <!-- if some more gem releases are needed you can append some number
- here with the gem.version -->
- <jruby.plugins.version>0.28.3</jruby.plugins.version>
- <gem.version>${project.parent.version}.${mavenVersion}.${jruby.plugins.version}</gem.version>
- <gem.basedir>${project.build.directory}/ruby-maven-${gem.version}</gem.basedir>
- </properties>
- <build>
- <finalName>ruby-maven-${gem.version}-java.gem</finalName>
- <resources>
- <resource>
- <targetPath>${gem.basedir}/pmaven-${project.parent.version}</targetPath>
- <directory>${project.basedir}/src/main/resources</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <phase>process-sources</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <outputAbsoluteArtifactFilename>false</outputAbsoluteArtifactFilename>
- <artifactItems>
- <artifactItem>
- <groupId>org.sonatype.pmaven</groupId>
- <artifactId>pmaven-cli</artifactId>
- <version>${project.parent.version}</version>
- <classifier>bin</classifier>
- <type>zip</type>
- <outputDirectory>${gem.basedir}</outputDirectory>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ <!-- <parent>
+ <groupId>org.sonatype.pmaven</groupId>
+ <artifactId>pmaven</artifactId>
+ <version>0.8-SNAPSHOT</version>
+ </parent>
+ -->
+ <groupId>rubygems</groupId>
+ <artifactId>ruby-maven</artifactId>
+ <version>${maven.version}.${jruby.plugins.version}</version>
+ <packaging>gem</packaging>
+ <name>ruby wrapper around maven and more</name>
- <plugin>
- <groupId>de.saumya.mojo</groupId>
- <artifactId>gem-maven-plugin</artifactId>
- <version>${jruby.plugins.version}</version>
- <extensions>true</extensions>
- <configuration>
- <gemspec>${project.basedir}/src/main/gemspec/maven.gemspec</gemspec>
- <launchDirectory>${gem.basedir}/pmaven-${project.parent.version}</launchDirectory>
- <includeOpenSSL>false</includeOpenSSL>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <dependencies>
+ </dependencies>
+ <properties>
+ <!-- if some more gem releases are needed you can append some number
+ here with the gem.version -->
+ <jruby.plugins.version>0.28.4</jruby.plugins.version>
+ <maven.version>3.0.3</maven.version>
+ <!-- <gem.version>${project.parent.version}.${mavenVersion}.${jruby.plugins.version}</gem.version> -->
+ <gem.basedir>${project.build.directory}/ruby-maven-${project.version}</gem.basedir>
+ </properties>
+ <build>
+ <resources>
+ <resource>
+ <targetPath>${gem.basedir}/apache-maven-${maven.version}</targetPath>
+ <directory>${project.basedir}/src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <outputAbsoluteArtifactFilename>false</outputAbsoluteArtifactFilename>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>apache-maven</artifactId>
+ <version>${maven.version}</version>
+ <classifier>bin</classifier>
+ <type>zip</type>
+ <outputDirectory>${gem.basedir}</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>de.saumya.mojo</groupId>
+ <artifactId>ruby-tools</artifactId>
+ <version>${jruby.plugins.version}</version>
+ <outputDirectory>${gem.basedir}/apache-maven-${maven.version}/lib/ruby</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>de.saumya.mojo</groupId>
+ <artifactId>gem-maven-plugin</artifactId>
+ <version>${jruby.plugins.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <gemspec>${project.basedir}/src/main/gemspec/maven.gemspec</gemspec>
+ <launchDirectory>${gem.basedir}/apache-maven-${maven.version}</launchDirectory>
+ <includeOpenSSL>true</includeOpenSSL>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
@@ -1,7 +1,6 @@
require 'fileutils'
Gem::Specification.new do |s|
- s.platform = 'java'
s.name = %q{ruby-maven}
s.version = "#{File.basename(File.expand_path('..')).sub(/-SNAPSHOT/, '').sub(/[a-zA-Z-]+-/, '').gsub(/-/, '.')}"
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
@@ -13,22 +12,29 @@ Gem::Specification.new do |s|
FileUtils.cp("bin/jetty-run", "bin/tomcat-run")
s.files = Dir.glob("*.txt") +
+ Dir.glob("bin/gwt") +
Dir.glob("bin/*-run") +
+ Dir.glob("bin/mvn*") +
Dir.glob("bin/rmvn") +
Dir.glob("bin/m2.conf") +
Dir.glob("boot/*") +
Dir.glob("conf/*") +
- Dir.glob("lib/*")
+ Dir.glob("lib/*") +
+ Dir.glob("lib/ext/*") +
+ Dir.glob("lib/ruby/ruby_maven.rb") +
+ Dir.glob("lib/ruby/maven/**/*")
ext = Dir.glob("ext/*ruby*")
ext.delete(ext.detect{ |f| f =~ /jruby-complete/ })
s.files += ext
s.bindir = "bin"
- s.executables = ['rmvn', 'jetty-run', 'tomcat-run']
+ s.executables = ['rmvn', 'gwt', 'jetty-run']#, 'tomcat-run']
s.homepage = %q{http://github.com/mkristian/ruby-maven}
- s.rdoc_options = ["--main", "README.txt"]
- s.require_paths = ['none']
+ s.rdoc_options = ["--main", "README.md"]
+ s.require_paths = ['lib/ruby']
s.rubygems_version = %q{1.3.5}
- s.summary = %q{maven support for rubygems}
+ s.summary = %q{maven support for ruby projects with gemspec, Gemfile}
+ s.add_dependency 'thor', '~> 0.14.6'
+ File.chmod(0755, File.join("bin", "mvn"))
end
View
@@ -0,0 +1,59 @@
+#!/usr/bin/env ruby
+require 'ruby_maven'
+require 'thor'
+
+class GWTCommand < Thor
+ no_tasks do
+ def mvn
+ @mvn ||= Maven::RubyMaven.new
+ end
+
+ def exec(*args)
+ ARGV.clear # clean up in case another script gets executed
+ print "maven commandline: "
+ mvn.exec(args)
+ end
+ end
+
+ desc "new APP_PATH GWT_PACKAGE_NAME [rails-options] [-- maven-options]", "create a new rails application with GWT UI given the path of the application and its package for the new GWT module"
+ method_option :session, :type => :boolean, :default => false, :desc => 'adds session support'
+ method_option :menu, :type => :boolean, :default => false, :desc => 'adds menu support'
+ def new(app_path, gwt_package, *args)
+ args = ARGV.dup
+ args.delete('new')
+ args.delete(app_path)
+ args.delete(gwt_package)
+ args.delete_if {|a| a =~ /^--session|^--menu/ }
+ if i = args.index("--")
+ maven_args = args[i..-1]
+ args = i == 0 ? [] : args[0..(i-1)]
+ end
+ margs = ["rails3:new", "-Dargs=\"#{[app_path, args].flatten!.join ' '}\"", "-Dgwt.package=#{gwt_package}", "-Dgwt.session=#{options['session'] || false}", "-Dgwt.menu=#{options['menu'] || false}", maven_args || []].flatten!
+ exec(margs)
+ end
+
+ def help(*args)
+ super
+ exec ["rails3:new", "-Dargs=--help"] if File.exists?('Gemfile')
+ end
+
+ desc "run [maven_options]", "starts the GWT development shell"
+ def server(*args)
+ args = ARGV.dup
+ args.delete('server')
+
+ exec ["gwt:run", args].flatten!
+ end
+
+ desc "compile [maven_options]", "compiles the gwt java code to javascript"
+ def compile(*args)
+ args = ARGV.dup
+ args.delete('compile')
+
+ exec ["compile", "gwt:compile", args].flatten!
+ end
+end
+if ARGV[0] == 'run'
+ ARGV[0] = 'server'
+end
+GWTCommand.start
View
@@ -1,104 +1,9 @@
-#!/usr/bin/env jruby
-begin
- require 'java'
-rescue LoadError => e
- raise "this executable needs jruby. quit."
-end
+require 'ruby_maven'
-# make the command line for the goals of the jruby-maven-plugins nicer
-plugins = {
- :rake => [:rake],
- :ruby => [:jruby, :compile],
- :gem => [:package, :install, :push, :exec, :pom, :initialize, :irb],
- :gemify => [:gemify, :versions],
- :rails2 => [:new, :generate, :rake, :server, :console],
- :rails3 => [:new, :generate, :rake, :server, :console, :dbconsole, :pom, :initialize],
- :cucumber => [:test],
- :rspec => [:test],
- :runit => [:test],
- :bundler => [:install]
-}
-aliases = {:jruby => :ruby, :spec => :rspec, :rails => :rails3, :bundle => :bundler}
+mvn = Maven::RubyMaven.new
-log = File.join('log', 'rmvn.log')
-if File.exists? File.dirname(log)
- File.open(log, 'a') do |f|
- f.puts ARGV.join ' '
- end
-end
-if ARGV.size > 0
- name = ARGV[0].to_sym
- name = aliases[name] || name
- if plugins.member?(name)
- start = 1
- if ARGV.size > 1
- if plugins[name].member? ARGV[1].to_sym
- goal = ARGV[1].to_sym
- start = 2
- else
- goal = plugins[name][0]
- end
- else
- goal = plugins[name][0]
- end
- args = if index = ARGV.index("--")
- ARGV[index + 1, 1000]
- else
- []
- end
- ruby_args = (ARGV[start, (index || 1000) - start] || []).join(' ')
-
- # determine the version and delete from ARGV if given
- version = ARGV.detect do |a|
- a =~ /^-Dplugin.version=/
- end
- if version
- args.delete(version)
- version.sub!(/^-Dplugin.version=/, ':')
- end
- args << "de.saumya.mojo:#{name}-maven-plugin#{version}:#{goal}"
- args << "-Dargs=#{ruby_args}" if ruby_args.size > 0
- ARGV.replace(args)
- else
- ARGV.delete("--")
- end
-end
-if ARGV.size == 0 || ARGV[0] == "--help"
- puts "usage: rmvn [<plugin name>|<plugin alias> [<args>] [-- <maven options>] | [<maven goal>|<maven phase> <maven options>] | --help"
- ARGV.replace(["--help"])
- plugins.each do |name, goals|
- puts
- print "plugin #{name}"
- print " - alias: #{aliases[name]}" if aliases[name]
- puts
- if goals.size > 1
- print "\tgoals : #{goals.join(',')}"
- puts
- end
- print "\tdefault goal: #{goals[0]}"
- puts
- end
- puts
-end
-
-print "maven commandline: "
args = ARGV.dup
ARGV.clear # clean up in case another script gets executed it gets clear ARGV
-puts args.join ' '
-
-
-bin = File.dirname(__FILE__)
-
-boot = File.join(bin, "..", "boot")
-ext = File.join(bin, "..", "ext")
-(Dir.glob(boot + "/*jar") + Dir.glob(ext + "/ruby-tools*jar")).each do |path|
- require path
-end
-
-java.lang.System.setProperty("classworlds.conf", File.join(bin, "m2.conf"))
-
-java.lang.System.setProperty("maven.home", File.join(bin, ".."))
-
-
-org.codehaus.plexus.classworlds.launcher.Launcher.main(args)
+print "maven commandline: "
+mvn.exec(args)
Oops, something went wrong.

0 comments on commit 73093a9

Please sign in to comment.