Package de.saumya.mojo.ruby.script

Examples of de.saumya.mojo.ruby.script.Script


        if (DATABASES.containsKey(database)) {
            database = DATABASES.get(database);
        }

        // run the "rails new"-script
        final Script script = installer.factory.newScript(installer.config.binScriptFile("rails"))
                .addArg("_" + railsVersion + "_")
                .addArg("new");
        if (appPath != null) {
            script.addArg(appPath.getAbsolutePath());
        }
        for (final String arg : args) {
            script.addArg(arg);
        }
        if (database != null) {
            script.addArg("-d", database);
        }
        if (isOffline( repositorySystemSession )) {
            this.logger.info("system is offline: using jruby rails templates from jar file - might be outdated");
        }
        if (template != null || (gwt != null && gwt.packageName != null)){
            String tmp = templateFrom(orm, isOffline( repositorySystemSession ), railsVersion);
            if(tmp != null ){
                System.setProperty("maven.rails.basetemplate", tmp);
            }
            if (template != null){
                System.setProperty("maven.rails.extratemplate", template);
            }
            if (gwt != null && gwt.packageName != null){
                System.setProperty("maven.rails.gwt", gwt.packageName);
            }
            script.addArg("-m", templateFromResource("templates"));
        }
        else {
            script.addArg("-m", templateFrom(orm, isOffline( repositorySystemSession ), railsVersion));
        }

        // skip bundler
        script.addArg("--skip-bundle");

        script.execute();

        if (appPath != null) {
            installer.factory.newScriptFromResource("maven/tools/pom_generator.rb")
                .addArg("rails")
                .addArg("Gemfile")
View Full Code Here


    public void rake(final GemsInstaller installer,
            final Object repositorySystemSession,
            final File launchDirectory, final String environment,
            final String task, final String... args) throws IOException,
            ScriptException, GemException, RailsException {
        final Script script = installer.factory.newScriptFromSearchPath("rake");
        script.addArgs(task);
        for (final String arg : args) {
            script.addArg(arg);
        }
        if(environment != null && environment.trim().length() > 0){
            script.addArg("RAILS_ENV=" + environment);
        }
        script.executeIn(launchDirectory);
    }
View Full Code Here

    public void generate(final GemsInstaller installer,
            final Object repositorySystemSession,
            final File launchDirectory, final String generator,
            final String... args) throws IOException, ScriptException,
            GemException, RailsException {
        final Script script = installer.factory.newScript(new File(new File(launchDirectory,
                "script"),
                "rails"))
                .addArg("generate")
                .addArg(generator);
        for (final String arg : args) {
            script.addArg(arg);
        }
        script.executeIn(launchDirectory);
    }
View Full Code Here

                final ArtifactRepository localRepository, List<ArtifactRepository> remoteRepos,
                String scope ) throws IOException,
                ScriptException, GemException {
        // start without script object.
        // script object will be created when first un-installed gem is found
        Script script = null;
        if (pom != null) {
            boolean hasAlreadyOpenSSL = false;
            for (final Artifact artifact : pom.getArtifacts()) {
                // assume pom.getBasedir() != null indicates the project pom
                if ( ( "compile".equals(artifact.getScope()) ||
                       "runtime".equals(artifact.getScope()) ||
                       pom.getBasedir() != null ) &&
                      ( scope == null || scope.equals(artifact.getScope()) ) ) {
                    if (!artifact.getFile().exists()) {
                        this.manager.resolve(artifact,
                                             localRepository,
                                             remoteRepos);

                    }
                    script = maybeAddArtifact(script, artifact);
                    hasAlreadyOpenSSL = hasAlreadyOpenSSL
                            || artifact.getArtifactId().equals(OPENSSL);
                }
            }
            if (artifacts != null) {
                for (final Artifact artifact : artifacts) {
                    if (!artifact.getFile().exists()) {
                        this.manager.resolve(artifact,
                                             localRepository,
                                             remoteRepos);

                    }
                    script = maybeAddArtifact(script, artifact);
                    hasAlreadyOpenSSL = hasAlreadyOpenSSL
                            || artifact.getArtifactId().equals(OPENSSL);
                }
            }
            if ( pom.getArtifact().getFile() != null
                 // to filter out target/classes
                 && pom.getArtifact().getFile().isFile()
                 // have only gem files
                 && pom.getArtifact().getFile().getName().endsWith(".gem") ) {
                script = maybeAddArtifact(script, pom.getArtifact());
            }
            if (!this.config.skipJRubyOpenSSL() && !hasAlreadyOpenSSL && script != null) {
                // keep the version hard-coded to stay reproducible
                final Artifact openssl = this.manager.createGemArtifact(OPENSSL,
                                                                        OPENSSL_VERSION);

                if (pom.getFile() == null) {
                    // we do not have a pom so we need the default gems repo
                    this.manager.addDefaultGemRepositories(remoteRepos);
                }
                for(Artifact a : this.manager.resolve(openssl,
                                                      localRepository,
                                                      remoteRepos, true) ) {
                    if (a.getFile() == null || !a.getFile().exists()) {
                        this.manager.resolve(a,
                                             localRepository,
                                             remoteRepos);

                    }
                    script = maybeAddArtifact(script, a);
                }
            }
        }

        if (script != null) {
            script.addArg("--bindir", this.config.getBinDirectory());
            if(this.config.getBinDirectory() != null && !this.config.getBinDirectory().exists()){
                this.config.getBinDirectory().mkdirs();
            }
            script.execute();
           
            if (this.config.getGemHome() != null){
                // workaround for unpatched: https://github.com/rubygems/rubygems/commit/21cccd55b823848c5e941093a615b0fdd6cd8bc7
                for(File spec : new File(this.config.getGemHome(), "specifications").listFiles(FILTER)){
                    String content = FileUtils.fileRead(spec);
View Full Code Here

    protected File   gem         = null;

    @Override
    public void executeWithGems() throws MojoExecutionException,
            ScriptException, IOException, MojoFailureException {
        final Script script = this.factory.newScriptFromJRubyJar("gem")
                .addArg("install");
        // no given gem and pom artifact in place
        if (this.gem == null && this.project.getArtifact() != null
                && this.project.getArtifact().getFile() != null
                && this.project.getArtifact().getFile().exists()) {
            final GemArtifact gemArtifact = new GemArtifact(this.project);
            // skip artifact unless it is a gem.
            // this allows to use this mojo for installing arbitrary gems
            // via the args parameter
            if (gemArtifact.isGem()) {
                script.addArg("-l", gemArtifact.getFile());
            }
        }
        else {
            // no pom artifact and no given gem so search for a gem
            if (this.gem == null) {
                for (final File f : this.launchDirectory().listFiles()) {
                    if (f.getName().endsWith(".gem")) {
                        if (this.gem == null) {
                            this.gem = f;
                        }
                        else {
                            throw new MojoFailureException("more than one gem file found, use -Dgem=... to specifiy one");
                        }
                    }
                }
            }
            if (this.gem != null) {
                getLog().info("use gem: " + this.gem);
                script.addArg("-l", this.gem);
            }
        }
        script.addArg((installRDoc ? "--" : "--no-") + "rdoc")
                .addArg((installRI ? "--" : "--no-") + "ri")
                .addArgs(this.installArgs)
                .addArgs(this.args)
                .execute();
    }
View Full Code Here

    protected String[] execArgLines = null;

    @Override
    protected void executeWithGems() throws MojoExecutionException,
            ScriptException, IOException {
        Script s;
        if (this.script != null && this.script.length() > 0) {
            s = this.factory.newScript(this.script);
        }
        else if (this.file != null) {
            s = this.factory.newScript(this.file);
        }
        else if (this.filename != null) {
            s = this.factory.newScriptFromSearchPath( this.filename );
        }
        else {
            s = this.factory.newArguments();
        }
        if ( execArgLines != null ){
            for( String arg: execArgLines ){
                s.addArg( arg );
            }
        }
        s.addArgs(this.execArgs);
        s.addArgs(this.args);
        if (s.isValid()) {
            if(outputFile != null){
                s.executeIn(launchDirectory(), outputFile);
            }
            else {
                s.executeIn(launchDirectory());
            }
        }
        else {
            getLog().warn("no arguments given. use -Dexec.script=... or -Dexec.file=...");
        }
View Full Code Here

            getLog().info("skip installing gems");
        }
        else {
            // assume we have the dependent gems in place so tell gems to
            // install them without dependency check
            final Script script = this.factory.newScriptFromJRubyJar("gem")
                    .addArg("install")
                    .addArg((installRDoc ? "--" : "--no-") + "rdoc")
                    .addArg((installRI ? "--" : "--no-") + "ri")
                    .addArg("--ignore-dependencies")
                    .addArg("-l");
            for (final String gem : gems.keySet()) {
                script.addArg(gem);
            }
            script.executeIn(launchDirectory());
        }

    }
View Full Code Here

    public void executeWithGems() throws MojoExecutionException,
            ScriptException, IOException, MojoFailureException, GemException {
        if ( getJrubyVersion().needsOpenSSL() ) {
            gemsInstaller.installOpenSSLGem(this.repoSession, localRepository, getRemoteRepos() );
        }
        final Script script = this.factory.newScriptFromJRubyJar("gem")
                .addArg("push");
        if(this.project.getArtifact().getFile() == null){
            File f = new File(this.project.getBuild().getDirectory(), this.project.getBuild().getFinalName() +".gem");
            if (f.exists()) {
                this.project.getArtifact().setFile(f);
            }
        }
        // no given gem and pom artifact in place
        if (this.gem == null && this.project.getArtifact() != null
                && this.project.getArtifact().getFile() != null
                && this.project.getArtifact().getFile().exists()) {
            final GemArtifact gemArtifact = new GemArtifact(this.project);
            // skip artifact unless it is a gem.
            // this allows to use this mojo for installing arbitrary gems
            if (!gemArtifact.isGem()) {
                throw new MojoExecutionException("not a gem artifact");
            }
            script.addArg(gemArtifact.getFile());
        }
        else {
            // no pom artifact and no given gem so search for a gem
            if (this.gem == null && null == args ) {
                for (final File f : this.launchDirectory().listFiles()) {
                    if (f.getName().endsWith(".gem")) {
                        if (this.gem == null) {
                            this.gem = f;
                        }
                        else {                           
                            throw new MojoFailureException("more than one gem file found, use -Dgem=... to specifiy one");
                        }
                    }
                }
            }
            if (this.gem != null) {
                getLog().info("use gem: " + this.gem);
                script.addArg(this.gem);
            }
        }
        script.addArgs(this.pushArgs);
        script.addArgs(this.args);
        script.execute();
    }
View Full Code Here

    protected Result runIt(ScriptFactory factory, Mode mode, final JRubyVersion version, TestScriptFactory scriptFactory)
            throws IOException, ScriptException, MojoExecutionException {
      scriptFactory.setSourceDir(new File("."));
        scriptFactory.emit();

    final Script script = factory.newScript(scriptFactory.getCoreScript());
    if (this.cucumberArgs != null) {
      script.addArgs(this.cucumberArgs);
    }
    if (this.args != null) {
      script.addArgs(this.args);
    }
    if (this.cucumberDirectory != null) {
      script.addArg(this.cucumberDirectory);
    }

        try {
            script.executeIn(launchDirectory());
        } catch (Exception e) {
            getLog().debug("exception in running tests", e);
        }

        return resultManager.generateReports(mode, version, outputfile);
View Full Code Here

        }
        else{
            scriptFactory.setSourceDir(new File(launchDirectory(), minispecDirectory));
        }

        final Script script = factory.newScript(scriptFactory.getCoreScript());
        if (this.minispecArgs != null) {
            script.addArgs(this.minispecArgs);
        }
        if (this.args != null) {
            script.addArgs(this.args);
        }

        try {
            script.executeIn(launchDirectory());
        } catch (Exception e) {
            getLog().debug("exception in running specs", e);
        }

        return resultManager.generateReports(mode, version, outputfile);
View Full Code Here

TOP

Related Classes of de.saumya.mojo.ruby.script.Script

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.