with the normal Eclipse launch support. You can also add entries to the generator's
classpath through the same launch configuration support. This should make it easier to
access JDBC drivers, or to access your own generator plugins.
+
See the page Using the Launcher for more
+information about using the launcher.
Integrated Ant Task
See the page Using the Integrated Ant Task for more
diff --git a/eclipse/org.mybatis.generator.eclipse.doc/html-src/eclipseui/usingTheLauncher.html b/eclipse/org.mybatis.generator.eclipse.doc/html-src/eclipseui/usingTheLauncher.html
new file mode 100644
index 0000000000..547f0b317d
--- /dev/null
+++ b/eclipse/org.mybatis.generator.eclipse.doc/html-src/eclipseui/usingTheLauncher.html
@@ -0,0 +1,77 @@
+
+
+
+
+ Using the Launcher
+
+
+
+
Using the Launcher
+
The MyBatis Generator feature includes a custom launcher for
+running MyBatis generator. The launcher leverages Eclipse's launch support
+and enables you to create any number of custom launches. The launcher has far
+more capability than the previous popup menu action. Further, the launch support
+does not alter the Eclipse IDE classpath - which could happen inadvertently with
+the prior popup menu action.
+
On this page we will cover some of the technical internals of the launcher.
+We assume you are familiar with how the Eclipse launch support works in general.
+If you are not familiar with Eclipse launching, just know that launch configurations
+can be accessed with the Run>Run Configurations... or Run>Debug Configurations...
+menu options.
+
+
Launcher Internals
+
Internally the launcher uses the MyBatis Generator Ant task to run the generator. The
+launcher creates an Ant build script based on attributes in the launch
+configuration and then uses Eclipse's Ant support to run the script.
+
The launch configuration allows you to specify a SQL script to run
+before the generator is run. This can be useful when using in-memory databases
+and is used during testing of the feature. Running a SQL script is accomplished
+by using Ant's built in
+SQL task to run a script you specify. See the Ant documentation for details
+about the capabilities of the SQL task.
+
+
Working with the Classpath
+
The launcher allows you to add entries to the runtime classpath
+of the launch. This can be used to add JDBC drivers to the classpath, and could
+also be used to add Eclipse projects to the classpath. If you are developing a
+plugin, you could add your plugin project to the classpath to test your plugin.
+
If you are developing a plugin, you do not need to add MyBatis Generator
+itself to the launch classpath as it will already be added by the launcher.
+
Adding entries to the launcher classpath is generally preferable to using
+a <classPathEntry> configuration element in the generator
+configuration file. However, if you use a dependency JAR that relies on native code
+(such as some DB2 drivers) it would be better to use the
+<classPathEntry> configuration element. This because native
+code can only be loaded by a single classloader and it is likely that
+the generator classloader will be garbage collected before the launch classloader.
+
+
What's Different in a Debug Launch?
+
If you launch in debug mode, rather than run mode, the launcher will
+launch Ant in debug mode and will log all messages to
+a new Eclipse console called "MyBatis Generator". This can be useful when
+using an SQL script as you will be able to see the script progress in the
+console. You will also see many Ant configuration messages.
+
+
How Passwords are Stored
+
If you specify a password for connecting to a database with the Ant script, you
+have options on how that password is stored.
+
If you select the check box specifying that
+credentials should be stored in secure storage, then the user ID and password will
+be stored in Eclipse's internal secure storage system. The password will be encrypted
+using Eclipse's default support. The password will be in clear text in the generated Ant
+script while the launch is running, but the generated Ant file will be deleted after the
+launch completes.
+
If you do not select the check box specifying that
+credentials should be stored in secure storage, then the user ID and password will
+be stored in clear text in the Eclipse launch configuration. The password will also
+be in clear text in the generated Ant script while the launch is running, and the
+generated Ant file will not be deleted after the launch completes.
+
Launch configuration files are stored in
+<workspace-directory>/.metadata/.plugins/org.eclipse.debug.core/.launches
+
+
The generated Ant files are stored in
+<workspace-directory>/.metadata/.plugins/org.mybatis.generator.eclipse.ui/.generatedAntScripts
+
a new Eclipse console called "MyBatis Generator". This can be useful when
using an SQL script as you will be able to see the script progress in the
console. You will also see many Ant configuration messages.
+
Currently the launcher does not support breakpoints in dependent projects.
+If you are developing a plugin you may add the plugin project to the launcher
+classpath and the plugin will be executed, but any breakpoints set in
+plugin code will be ignored. This is a limitation of Ant support.
How Passwords are Stored
If you specify a password for connecting to a database with the Ant script, you
diff --git a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/GeneratorLaunchConfigurationDelegate.java b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/GeneratorLaunchConfigurationDelegate.java
index 76328b8129..04e5b1d41d 100644
--- a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/GeneratorLaunchConfigurationDelegate.java
+++ b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/GeneratorLaunchConfigurationDelegate.java
@@ -36,6 +36,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
import org.mybatis.generator.eclipse.ui.Activator;
import org.mybatis.generator.eclipse.ui.Messages;
@@ -70,7 +71,7 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun
antRunner.setBuildFileLocation(buildFile);
modifyAntClasspathIfNecessary(configuration, antRunner);
- if ("debug".equals(mode)) { //$NON-NLS-1$
+ if (ILaunchManager.DEBUG_MODE.equals(mode)) {
antRunner.setMessageOutputLevel(Project.MSG_DEBUG);
antRunner.setArguments("-debug"); //$NON-NLS-1$
antRunner.addBuildListener("org.mybatis.generator.eclipse.ui.ant.DebugBuildListener"); //$NON-NLS-1$
From 6a77034f18bac5dd014872666a971a2b6448cfd6 Mon Sep 17 00:00:00 2001
From: Jeff Butler
Date: Sun, 14 Aug 2016 17:50:08 -0400
Subject: [PATCH 3/4] i18n and license header updates
---
.../eclipse/ui/ant/DebugBuildListener.java | 15 +++++++++++++++
.../mybatis/generator/eclipse/ui/Messages.java | 6 +++++-
.../eclipse/ui/launcher/tabs/LauncherUtils.java | 8 +++++---
.../ui/launcher/tabs/SqlScriptComposite.java | 2 +-
.../generator/eclipse/ui/messages.properties | 5 +++++
.../eclipse/ui/wizards/NewConfigFileWizard.java | 12 ------------
.../ui/wizards/NewConfigFileWizardPage1.java | 2 +-
7 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/eclipse/org.mybatis.generator.eclipse.ui/antsrc/org/mybatis/generator/eclipse/ui/ant/DebugBuildListener.java b/eclipse/org.mybatis.generator.eclipse.ui/antsrc/org/mybatis/generator/eclipse/ui/ant/DebugBuildListener.java
index 6f2ca98cbc..bd69b836bc 100644
--- a/eclipse/org.mybatis.generator.eclipse.ui/antsrc/org/mybatis/generator/eclipse/ui/ant/DebugBuildListener.java
+++ b/eclipse/org.mybatis.generator.eclipse.ui/antsrc/org/mybatis/generator/eclipse/ui/ant/DebugBuildListener.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright 2006-2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.mybatis.generator.eclipse.ui.ant;
import java.io.IOException;
diff --git a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/Messages.java b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/Messages.java
index 0048e7756d..0c1bb60282 100644
--- a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/Messages.java
+++ b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/Messages.java
@@ -19,7 +19,6 @@
public class Messages extends NLS {
-
public static String FILE_PICKER_BROWSE_FILE_SYSTEM;
public static String FILE_PICKER_BROWSE_WORKSPACE;
public static String FILE_PICKER_FILE_DOESNT_EXIST;
@@ -42,11 +41,16 @@ public class Messages extends NLS {
public static String SQL_SCRIPT_TAB_PASSWORD_LABEL;
public static String SQL_SCRIPT_TAB_JDBC_DRIVER_REQUIRED;
public static String SQL_SCRIPT_TAB_JDBC_URL_REQUIRED;
+ public static String SQL_SCRIPT_TAB_SECURE_STORAGE;
public static String LAUNCH_CONFIGURATION_SELECTOR_TITLE;
public static String LAUNCH_CONFIGURATION_SELECTOR_MESSAGE;
public static String LAUNCH_ERROR_ERROR_GENERATING_ANT_FILE;
+ public static String SECURE_STORAGE_ERROR_DIALOG_TITLE;
+ public static String SECURE_STORAGE_ERROR_DIALOG_MESSAGE;
+ public static String SECURE_STORAGE_ERROR_LOG_MESSAGE;
+
static {
NLS.initializeMessages("org.mybatis.generator.eclipse.ui.messages", Messages.class); //$NON-NLS-1$
}
diff --git a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/tabs/LauncherUtils.java b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/tabs/LauncherUtils.java
index 6a5ff1d6e2..a84d8a3bf4 100644
--- a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/tabs/LauncherUtils.java
+++ b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/tabs/LauncherUtils.java
@@ -25,6 +25,7 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
import org.mybatis.generator.eclipse.ui.Activator;
+import org.mybatis.generator.eclipse.ui.Messages;
import org.mybatis.generator.eclipse.ui.launcher.GeneratorLaunchConstants;
public class LauncherUtils {
@@ -119,9 +120,10 @@ public static String getUserId(ILaunchConfiguration configuration) {
private static void logException(Shell shell, StorageException e) {
MessageDialog.openError(shell,
- "Secure Storage Error",
- "Error writing to secure storage. See error log for more details.");
- Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, "Error writing to secure storage", e);
+ Messages.SECURE_STORAGE_ERROR_DIALOG_TITLE,
+ Messages.SECURE_STORAGE_ERROR_DIALOG_MESSAGE);
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ Messages.SECURE_STORAGE_ERROR_LOG_MESSAGE, e);
Activator.getDefault().getLog().log(status);
}
diff --git a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/tabs/SqlScriptComposite.java b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/tabs/SqlScriptComposite.java
index 3f440488c6..c958ae2838 100644
--- a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/tabs/SqlScriptComposite.java
+++ b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/launcher/tabs/SqlScriptComposite.java
@@ -149,7 +149,7 @@ public void modifyText(ModifyEvent e) {
new Label(group, SWT.NONE);
btnSecureStorage = new Button(group, SWT.CHECK);
- btnSecureStorage.setText("Store Credentials in Secure Storage");
+ btnSecureStorage.setText(Messages.SQL_SCRIPT_TAB_SECURE_STORAGE);
btnSecureStorage.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
diff --git a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/messages.properties b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/messages.properties
index 3987062bfc..2ec96844f4 100644
--- a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/messages.properties
+++ b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/messages.properties
@@ -36,7 +36,12 @@ SQL_SCRIPT_TAB_USERID_LABEL=User ID
SQL_SCRIPT_TAB_PASSWORD_LABEL=Password
SQL_SCRIPT_TAB_JDBC_DRIVER_REQUIRED=JDBC Driver Class is required if you specify a file name
SQL_SCRIPT_TAB_JDBC_URL_REQUIRED=JDBC connection URL is required if you specify a file name
+SQL_SCRIPT_TAB_SECURE_STORAGE=Store Credentials in Secure Storage
LAUNCH_CONFIGURATION_SELECTOR_TITLE=Select a Launch Configuration
LAUNCH_CONFIGURATION_SELECTOR_MESSAGE=Select existing configuration:
LAUNCH_ERROR_ERROR_GENERATING_ANT_FILE=Exception generating Ant file
+
+SECURE_STORAGE_ERROR_DIALOG_TITLE=Secure Storage Error
+SECURE_STORAGE_ERROR_DIALOG_MESSAGE=Error writing to secure storage. See error log for more details.
+SECURE_STORAGE_ERROR_LOG_MESSAGE=Error writing to secure storage
diff --git a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/wizards/NewConfigFileWizard.java b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/wizards/NewConfigFileWizard.java
index e8dd6b7403..59180a60fe 100644
--- a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/wizards/NewConfigFileWizard.java
+++ b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/wizards/NewConfigFileWizard.java
@@ -47,15 +47,6 @@
import org.mybatis.generator.codegen.XmlConstants;
import org.mybatis.generator.eclipse.ui.Activator;
-/**
- * This is a sample new wizard. Its role is to create a new file resource in the
- * provided container. If the container resource (a folder or a project) is
- * selected in the workspace when the wizard is opened, it will accept it as the
- * target container. The wizard creates one file with the extension "mpe". If a
- * sample multi-page editor (also available as a template) is registered for the
- * same extension, it will be able to open it.
- */
-
public class NewConfigFileWizard extends Wizard implements INewWizard {
private NewConfigFileWizardPage1 page;
private ISelection selection;
@@ -71,7 +62,6 @@ public NewConfigFileWizard() {
/**
* Adding the page to the wizard.
*/
-
public void addPages() {
page = new NewConfigFileWizardPage1(selection);
addPage(page);
@@ -114,7 +104,6 @@ public void run(IProgressMonitor monitor)
* or just replace its contents, and open the editor on the newly created
* file.
*/
-
private void doFinish(String containerName, String fileName,
IProgressMonitor monitor) throws CoreException {
// create a sample file
@@ -155,7 +144,6 @@ public void run() {
/**
* We will initialize file contents with a sample text.
*/
-
private InputStream openContentStream() {
Document document = new Document(XmlConstants.MYBATIS_GENERATOR_CONFIG_PUBLIC_ID,
diff --git a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/wizards/NewConfigFileWizardPage1.java b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/wizards/NewConfigFileWizardPage1.java
index 1a0b26ce79..a0042c913a 100644
--- a/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/wizards/NewConfigFileWizardPage1.java
+++ b/eclipse/org.mybatis.generator.eclipse.ui/src/org/mybatis/generator/eclipse/ui/wizards/NewConfigFileWizardPage1.java
@@ -135,7 +135,7 @@ private void initialize() {
locationText.setText(container.getFullPath().toString());
}
}
- fileText.setText("generatorConfig.xml");
+ fileText.setText("generatorConfig.xml"); //$NON-NLS-1$
}
/**
From 26919d120b36176861f823982631da0d39439c68 Mon Sep 17 00:00:00 2001
From: Jeff Butler
Date: Sun, 14 Aug 2016 17:52:04 -0400
Subject: [PATCH 4/4] Update docs for new version
---
.../src/site/xhtml/running/runningWithMaven.xhtml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/core/mybatis-generator-core/src/site/xhtml/running/runningWithMaven.xhtml b/core/mybatis-generator-core/src/site/xhtml/running/runningWithMaven.xhtml
index 0e3d53a7e0..eba4af74d8 100644
--- a/core/mybatis-generator-core/src/site/xhtml/running/runningWithMaven.xhtml
+++ b/core/mybatis-generator-core/src/site/xhtml/running/runningWithMaven.xhtml
@@ -39,7 +39,7 @@ in a Maven build can be very simple. The minimum configuration is shown below:<
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
- <version>1.3.3</version>
+ <version>1.3.4</version>
</plugin>
...
</plugins>
@@ -83,7 +83,7 @@ the goal to execute automatically. An example of this is shown below:
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
- <version>1.3.3</version>
+ <version>1.3.4</version>
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
@@ -124,7 +124,7 @@ file and may be used in the normal way. For example:
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
- <version>1.3.3</version>
+ <version>1.3.4</version>
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>