mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
Merge pull request #1584 from mdiazf/server_config
Add the "server" parameter (alternative to jdbcUser and jdbcPassword)
This commit is contained in:
commit
da9706932e
@ -19,10 +19,12 @@ import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.apache.maven.artifact.manager.WagonManager;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.wagon.authentication.AuthenticationInfo;
|
||||
|
||||
import com.mysema.codegen.model.SimpleType;
|
||||
import com.querydsl.codegen.BeanSerializer;
|
||||
@ -48,6 +50,18 @@ public class AbstractMetaDataExportMojo extends AbstractMojo {
|
||||
*/
|
||||
private MavenProject project;
|
||||
|
||||
/**
|
||||
* The Maven Wagon manager to use when obtaining server authentication details.
|
||||
* @component
|
||||
*/
|
||||
private WagonManager wagonManager;
|
||||
|
||||
/**
|
||||
* The server id in settings.xml to use as an alternative to jdbcUser and jdbcPassword
|
||||
* @parameter
|
||||
*/
|
||||
private String server;
|
||||
|
||||
/**
|
||||
* JDBC driver class name
|
||||
* @parameter required=true
|
||||
@ -475,7 +489,28 @@ public class AbstractMetaDataExportMojo extends AbstractMojo {
|
||||
exporter.setConfiguration(configuration);
|
||||
|
||||
Class.forName(jdbcDriver);
|
||||
Connection conn = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword);
|
||||
String user;
|
||||
String password;
|
||||
if (server == null) {
|
||||
user = jdbcUser;
|
||||
password = jdbcPassword;
|
||||
} else {
|
||||
AuthenticationInfo info = wagonManager.getAuthenticationInfo(server);
|
||||
if (info == null) {
|
||||
throw new MojoExecutionException("No authentication info for server " + server);
|
||||
}
|
||||
|
||||
user = info.getUserName();
|
||||
if (user == null) {
|
||||
throw new MojoExecutionException("Missing username from server " + server);
|
||||
}
|
||||
|
||||
password = info.getPassword();
|
||||
if (password == null) {
|
||||
throw new MojoExecutionException("Missing password from server " + server);
|
||||
}
|
||||
}
|
||||
Connection conn = DriverManager.getConnection(jdbcUrl, user, password);
|
||||
try {
|
||||
exporter.export(conn.getMetaData());
|
||||
} finally {
|
||||
@ -503,6 +538,10 @@ public class AbstractMetaDataExportMojo extends AbstractMojo {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void setServer(String server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public void setJdbcDriver(String jdbcDriver) {
|
||||
this.jdbcDriver = jdbcDriver;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user