Skip to content

Commit

Permalink
🎨 调整代码生成插件支持新版本ssh-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
hengboy committed May 28, 2024
1 parent 7b959ed commit 8c195cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>ssh-agent</artifactId>
<version>${ssh-agent.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
import org.minbox.framework.api.boot.maven.plugin.mybatis.enhance.codegen.tools.CamelTools;
import org.minbox.framework.api.boot.maven.plugin.mybatis.enhance.codegen.writer.JavaClassWriter;
import org.minbox.framework.ssh.agent.AgentConnection;
import org.minbox.framework.ssh.agent.DefaultAgentConnection;
import org.minbox.framework.ssh.agent.AgentSupport;
import org.minbox.framework.ssh.agent.apache.ApacheMinaSshdAgentConnection;
import org.minbox.framework.ssh.agent.config.AgentConfig;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

Expand Down Expand Up @@ -171,6 +173,11 @@ public class ApiBootMybatisEnhanceCodegen extends AbstractMojo {
*/
@Parameter
private boolean enableSshProxy = false;
/**
* ssh代理连接方式,默认为Apache Mina
*/
@Parameter
private AgentSupport sshProxySupport = AgentSupport.mina;
/**
* Ssh Proxy代理参数设置
*/
Expand Down Expand Up @@ -211,7 +218,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("The entity class corresponding to the " + tableNames.size() + " tables will be generated,and the table name list: " +
JSON.toJSONString(tableNames));
}
tableNames.stream().forEach(tableName -> {
tableNames.forEach(tableName -> {
LocalDateTime startGetInfoTime = LocalDateTime.now();
// get table
Table table = dataBase.getTable(tableName);
Expand Down Expand Up @@ -297,7 +304,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
private AgentConnection startingSshProxy(SshProxySetting setting) {
AgentConnection connection = null;
try {
connection = new DefaultAgentConnection(setting);
this.sshProxySupport = this.sshProxySupport == null ? AgentSupport.mina : this.sshProxySupport;
connection = (AgentConnection) Class.forName(this.sshProxySupport.getClassName()).getDeclaredConstructor(AgentConfig.class).newInstance(setting);
connection.connect();
} catch (Exception e) {
getLog().error("SSH Connection:" + setting.getServerIp() + ":" + setting.getForwardTargetPort() + ",try agent failure.", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>ssh-agent</artifactId>
<version>${ssh-agent.version}</version>
</dependency>
</dependencies>
</project>

0 comments on commit 8c195cc

Please sign in to comment.