2017-01-19 6 views
0

私はAntからGradleに変換するビルドに取り組んでいます。その中で、IBM iSeriesシステムと対話してファイルをパッケージ化し、ビルドを行うマシン(Windows)にダウンロードし直さなければなりません。 FTPの部分は問題ありませんが、どこに問題があるのか​​はrexecビットです。REXEC Gradleに相当する

Antでは、rexecタスクを使用できるようになりました。これは素晴らしい動作です。しかし、私はGradle側の代替案は見当たりません。私はGroovyで試してみる必要がありますか?それとも私が紛失している代替案がありますか?

答えて

0

さらに調査したところ、rexecはSSHではありませんでした。これは、主にiSeriesとの対話に使用される個別のリモート・プロトコルです。

REXECの機能を模倣した小さなプログラムを書いていたことが分かりました。 build.gradleから次に

package com.myco.mypackage; 

import java.beans.PropertyVetoException; 
import java.io.IOException; 
import com.ibm.as400.access.*; 

public class RemoteCommandExecutor { 

    private String system; 
    private String user; 
    private String password; 
    private String command; 

    public RemoteCommandExecutor(String system, String user, String password, String command) { 
     this.system = system; 
     this.user = user; 
     this.password = password; 
     this.command = command; 
    } 

    public void doCmd(){ 
     AS400 theSys = new AS400(this.getSystem(), this.getUser(), this.getPassword()); 
     CommandCall cmd = new CommandCall(theSys); 
     try { 
      cmd.run(this.getCommand()); 
      AS400Message[] messageList = cmd.getMessageList(); 
       for (int i = 0; i < messageList.length; i++) { 
       System.out.println(messageList[i].getText()); 
       } 
     } catch (AS400SecurityException 
       | ErrorCompletingRequestException 
       | IOException 
       | InterruptedException 
       | PropertyVetoException e) { 
      e.printStackTrace(); 
     } 
    } 

    public static void main(String[] args) { 
     RemoteCommandExecutor exec = new RemoteCommandExecutor(args[0],args[1],args[2], args[3]); 
     exec.doCmd(); 
    } 

    /** 
    * @return the system 
    */ 
    public String getSystem() { 
     return system; 
    } 

    /** 
    * @param system the system to set 
    */ 
    public void setSystem(String system) { 
     this.system = system; 
    } 

    /** 
    * @return the user 
    */ 
    public String getUser() { 
     return user; 
    } 

    /** 
    * @param user the user to set 
    */ 
    public void setUser(String user) { 
     this.user = user; 
    } 

    /** 
    * @return the password 
    */ 
    public String getPassword() { 
     return password; 
    } 

    /** 
    * @param password the password to set 
    */ 
    public void setPassword(String password) { 
     this.password = password; 
    } 

    /** 
    * @return the command 
    */ 
    public String getCommand() { 
     return command; 
    } 

    /** 
    * @param command the command to set 
    */ 
    public void setCommand(String command) { 
     this.command = command; 
    } 

} 

、execの閉鎖を作る...プロジェクト内のjarファイルの前提としています:それはIBM JT toolsを利用

exec{ 
     commandLine "java", "-jar", "RemoteCommandExecutor.jar", project.ext.props.get("system"), project.ext.props.get("user"),project.ext.props.get("password"), project.ext.props.get("command.to.run") 
    } 
1

Gradleで機能が提供されていない場合、通常はプラグインがあります。このGradle SSH pluginをご覧ください。これは、パスワードと証明書の両方の認証を提供します。