Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package de.saumya.mojo.rails3;
  
  import java.io.File;
  
 
goal to run rails command with the given arguments. either to generate a fresh rails application or to run the rails script from within a rails application.

Goal:
new
 
 public class NewMojo extends AbstractRailsMojo {

    
arguments for the rails command
Command line -Drails.args=...

Parameter:
default-value="${rails.args}"
 
     protected String            railsArgs                      = null;

    
the path to the application to be generated
Command line -Dapp_path=...

Parameter:
default-value="${app_path}"
 
     protected File              appPath                        = null;

    
the database to use
Command line -Ddatabase=...

Parameter:
expression="${database}" default-value="sqlite3"
 
     protected String            database                       = null;

    
rails template to apply after create the application
Command line -Dtemplate=...

Parameter:
expression="${template}"
 
     protected String            template                       = null;

    
the rails version to use
Command line -Drails.version=...

Parameter:
expression="${rails.version}"
 
     protected String            railsVersion                   = null;

    
the groupId of the new pom
Command line -DgroupId=...

Parameter:
default-value="rails" expression="${groupId}"
 
     protected String            groupId                        = null;

    
the version of the new pom
Command line -Dversion=...

Parameter:
default-value="1.0-SNAPSHOT" expression="${version}"
 
     protected String            artifactVersion                = null;

    
select the ORM to use
Command line -Dorm=activerecord or -Dorm=datamapper

Parameter:
expression="${orm}" default-value="activerecord"
 
     protected String railsORM;

    
when the gwt package is given then the rails gets GWT as view component
Command line -Dgwt.package=...

Parameter:
expression="${gwt.package}"
    protected String gwtPackage;

    
setup GWT with session support
Command line -Dgwt.session=true

Parameter:
expression="${gwt.session}" default-value="false"
    protected boolean gwtSession;

    
setup GWT with menu support
Command line -Dgwt.menu=true

Parameter:
expression="${gwt.menu}" default-value="false"
    protected boolean gwtMenu;
    @Override
    public void execute() throws MojoExecutionExceptionMojoFailureException {
        // make sure the whole things run in the same process
        this. = false;
        super.execute();
    }
    @Override
            IOExceptionGemExceptionRailsException {
        getLog().warn"DEPRECATED: just do not use that anymore. use gem:exec or bundler:exec instead" );
        if( != null && !this..startsWith("3.")) {
            throw new MojoExecutionException("given rails version is not rails-3.x.y : "
                                             + this.);
        }
        try {
            if (this. == null) {
                final Pattern pattern = Pattern.compile(".*-d\\s+([a-z0-9]+).*");
                final Matcher matcher = pattern.matcher((this. == null
                        ? ""
                        : this.)
                        + (this. == null ? "" : this.));
                if (matcher.matches()) {
                    this. = matcher.group(1);
                }
                else {
                    this. = "sqlite3";
                }
            }
            final String[] combArgs = joinArgs(this.this.);
            if (this. == null) {
                // find appPath
                int index = 0;
                for (final String arg : combArgs) {
                    if (this. == null && !arg.startsWith("-")) {
                        this. = new File(arg);
                        break;
                    }
                    index++;
                }
                // remove found appPath from arg list
                if (index < combArgs.length) {
                    combArgs[index] = null;
                }
            }
            getLog().info("use ORM " + ORM.valueOf(this.));
            GwtOptions gwt = new GwtOptions();
            this..createNew(this.,
                                        this.,
                                        this.,
                                        this.,
                                        this.,
                                        ORM.valueOf(this.),
                                        this.,
                                        gwt,
                                        combArgs);
        }
        catch (final RailsException e) {
            throw new MojoExecutionException("error creating new rails application",
                    e);
        }
    }
New to GrepCode? Check out our FAQ X