Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extension>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-pomless</artifactId>
<version>1.0.0</version>
<!-- <version>${tycho.version}</version> -->
</extension>
</extensions>

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
name="%standard.wizard.name"
class="com.google.cloud.tools.eclipse.util.service.ServiceContextFactory:com.google.cloud.tools.eclipse.appengine.newproject.standard.AppEngineStandardProjectWizard"
icon="platform:/plugin/com.google.cloud.tools.eclipse.appengine.ui/icons/gae-16x16.png"
finalPerspective="org.eclipse.jst.j2ee.J2EEPerspective"
preferredPerspectives="org.eclipse.jst.j2ee.J2EEPerspective,org.eclipse.wst.web.ui.webDevPerspective"
project="true"
category="com.google.cloud.tools.eclipse.wizards">
<description>%standard.wizard.description</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,38 @@
import com.google.cloud.tools.eclipse.appengine.ui.CloudSdkOutOfDatePage;
import com.google.cloud.tools.eclipse.sdk.ui.preferences.CloudSdkPrompter;
import com.google.cloud.tools.eclipse.ui.util.WorkbenchUtil;
import com.google.cloud.tools.eclipse.usagetracker.AnalyticsEvents;
import com.google.cloud.tools.eclipse.util.service.ServiceContextFactory;
import com.google.cloud.tools.eclipse.util.status.StatusUtil;
import com.google.common.base.Preconditions;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import javax.inject.Inject;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;

/**
* Base class for App Engine projection creation.
* <p>
* Expected to be created via the {@link ServiceContextFactory}.
*/
public abstract class AppEngineProjectWizard extends Wizard implements INewWizard {

protected AppEngineWizardPage page = null;
protected final AppEngineProjectConfig config = new AppEngineProjectConfig();
private IWorkbench workbench;

@Inject
protected IConfigurationElement configElement;

public AppEngineProjectWizard() {
setNeedsProgressMonitor(true);
}
Expand Down Expand Up @@ -97,8 +110,12 @@ public boolean performFinish() {
boolean cancelable = true;
getContainer().run(fork, cancelable, runnable);

// prompt to switch to preferred perspective
BasicNewProjectResourceWizard.updatePerspective(configElement);

// open most important file created by wizard in editor
IFile file = runnable.getMostImportant();
BasicNewProjectResourceWizard.selectAndReveal(file, workbench.getActiveWorkbenchWindow());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use org.eclipse.ui.wizards.newresource.BasicNewResourceWizard.selectAndReveal(IResource) instead.
Or at least change the class to BasicNewResourceWizard.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BasicNewResourceWizard.selectAndReveal(IResource) is an instance method. Do you see any real benefit of inheriting from BasicNewResourceWizard?

WorkbenchUtil.openInEditor(workbench, file);
return true;
} catch (InterruptedException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;

/**
Expand All @@ -36,7 +37,7 @@ public class BaseProjectTest {
protected IProject project;

@BeforeClass
public static void setUp() throws Exception {
public static void setUpWorkbench() throws Exception {
// verify we can find the Google Cloud SDK
new CloudSdk.Builder().build().validateCloudSdk();

Expand All @@ -48,6 +49,13 @@ public static void setUp() throws Exception {
}
}

@Before
public void setUp() {
// switch to J2EE to avoid new-project switch-perspective prompts
bot.perspectiveById("org.eclipse.jst.j2ee.J2EEPerspective").activate();

}

@After
public void tearDown() {
if (project != null) {
Expand All @@ -60,6 +68,7 @@ public void tearDown() {
SwtBotProjectActions.deleteProject(bot, project.getName());
} catch (TimeoutException ex) {
// If this fails it shouldn't fail the test, which has already run
new RuntimeException("tearDown() timed out", ex).printStackTrace();
}
project = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ public void run() {
final SWTBotStyledText consoleContents =
new SWTBotStyledText(bot.widget(widgetOfType(StyledText.class), consoleView.getWidget()));
SwtBotTestingUtilities.waitUntilStyledTextContains(bot,
"Module instance default is running at http://localhost:8080", consoleContents);
"Dev App Server is now running", consoleContents);

System.out.printf("---- Dev App Server ----\n%s\n------------------\n",
consoleContents.getText());

// Server is now running
assertEquals("Hello App Engine!",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class NewMavenBasedAppEngineProjectWizardTest extends BaseProjectTest {
public void testHelloWorld_java7() throws Exception {
String[] projectFiles =
{"src/main/webapp/WEB-INF/appengine-web.xml", "src/main/webapp/WEB-INF/web.xml", "pom.xml"};
createAndCheck("appWithPackageProject", null, "com.example.baz",
createAndCheck("appWithPackageProjectJava7", null, "com.example.baz",
AppEngineRuntime.STANDARD_JAVA_7, projectFiles);
assertEquals("1.7", getPomProperty(project, "maven.compiler.source"));
assertEquals("1.7", getPomProperty(project, "maven.compiler.target"));
Expand All @@ -76,7 +76,7 @@ public void testHelloWorld_java8() throws Exception {
Assume.assumeTrue("Requires a Java 8 JRE", JavaRuntimeUtils.hasJavaSE8());
String[] projectFiles =
{"src/main/webapp/WEB-INF/appengine-web.xml", "src/main/webapp/WEB-INF/web.xml", "pom.xml"};
createAndCheck("appWithPackageProject", null, "com.example.baz",
createAndCheck("appWithPackageProjectJava8", null, "com.example.baz",
AppEngineRuntime.STANDARD_JAVA_8, projectFiles);
assertEquals("1.8", getPomProperty(project, "maven.compiler.source"));
assertEquals("1.8", getPomProperty(project, "maven.compiler.target"));
Expand All @@ -90,7 +90,7 @@ public void testHelloWorld_nonDefaultLocation() throws Exception {

String[] projectFiles =
{"src/main/webapp/WEB-INF/appengine-web.xml", "src/main/webapp/WEB-INF/web.xml", "pom.xml"};
createAndCheck("appWithPackageProjectInTemp", location.getAbsolutePath(), "com.example.foo",
createAndCheck("appWithPackageProjectJava7InTemp", location.getAbsolutePath(), "com.example.foo",
AppEngineRuntime.STANDARD_JAVA_7, projectFiles);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.google.cloud.tools.eclipse.util.service;

import com.google.cloud.tools.eclipse.util.status.StatusUtil;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
Expand All @@ -28,38 +29,42 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;

import com.google.cloud.tools.eclipse.util.status.StatusUtil;

public class ServiceContextFactory implements IExecutableExtensionFactory, IExecutableExtension {

private Class<?> clazz;
private IConfigurationElement configElement;

@Override
public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
throws CoreException {
if (data == null || !(data instanceof String)) {
throw new CoreException(StatusUtil.error(getClass(), "Data must be a class name"));
}
String className = (String) data;
String bundleSymbolicName = config.getNamespaceIdentifier();
Bundle bundle = Platform.getBundle(bundleSymbolicName);
if (bundle == null) {
throw new CoreException(StatusUtil.error(this, "Missing bundle " + bundleSymbolicName));
}
try {
clazz = bundle.loadClass(className);
} catch (ClassNotFoundException ex) {
throw new CoreException(StatusUtil.error(this,
"Could not load class " + className
+ " from bundle " + bundle.getSymbolicName(),
ex));
}
if (data == null || !(data instanceof String)) {
throw new CoreException(StatusUtil.error(getClass(), "Data must be a class name"));
}
configElement = config;
String className = (String) data;
String bundleSymbolicName = config.getNamespaceIdentifier();
Bundle bundle = Platform.getBundle(bundleSymbolicName);
if (bundle == null) {
throw new CoreException(StatusUtil.error(this, "Missing bundle " + bundleSymbolicName));
}
try {
clazz = bundle.loadClass(className);
} catch (ClassNotFoundException ex) {
throw new CoreException(StatusUtil.error(this,
"Could not load class " + className + " from bundle " + bundle.getSymbolicName(), ex));
}
}

@Override
public Object create() throws CoreException {
BundleContext bundleContext = FrameworkUtil.getBundle(clazz).getBundleContext();
IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(bundleContext);
return ContextInjectionFactory.make(clazz, serviceContext);
IEclipseContext staticContext = EclipseContextFactory.create();
staticContext.set(IConfigurationElement.class, configElement);
try {
return ContextInjectionFactory.make(clazz, serviceContext, staticContext);
} finally {
staticContext.dispose();
}
}
}
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
<!-- build against a known target platform -->
<modules>
<module>eclipse/mars</module>
<module>third_party/patches/mars</module>
</modules>
<build>
<plugins>
Expand Down Expand Up @@ -471,6 +472,7 @@
<!-- build against a known target platform -->
<modules>
<module>eclipse/neon</module>
<module>third_party/patches/neon</module>
</modules>
<build>
<plugins>
Expand Down Expand Up @@ -505,6 +507,7 @@
<!-- build against a known target platform -->
<modules>
<module>eclipse/oxygen</module>
<module>third_party/patches/oxygen</module>
</modules>
<build>
<plugins>
Expand Down
2 changes: 2 additions & 0 deletions third_party/patches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This directory contains patched bundles from Eclipse Mars, Neon, and Oxygen.
These fixes are only for testing.
7 changes: 7 additions & 0 deletions third_party/patches/mars/org.eclipse.core.jobs/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="output" path="bin"/>
</classpath>
19 changes: 19 additions & 0 deletions third_party/patches/mars/org.eclipse.core.jobs/.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Debugging options for the org.eclipse.core.jobs bundle

# NOTE: There is a deadlock risk when using these debug flags in a workspace
# launched from Eclipse due to interaction with a lock in the debugger console.
# For details: https://bugs.eclipse.org/bugs/show_bug.cgi?id=93968

# Prints debug information on running background jobs
org.eclipse.core.jobs/jobs=false
# Includes current date and time in job debug information
org.eclipse.core.jobs/jobs/timing=false
# Prints debug information when scheduling rules begin and end, and for mismatched beginRule/endRule pairs
org.eclipse.core.jobs/jobs/beginend=false
# Pedantic assertion checking on locks and deadlock reporting
org.eclipse.core.jobs/jobs/locks=false
# Throws an IllegalStateException when deadlock occurs
org.eclipse.core.jobs/jobs/errorondeadlock=false
# Debug shutdown behaviour
org.eclipse.core.jobs/jobs/shutdown=false

34 changes: 34 additions & 0 deletions third_party/patches/mars/org.eclipse.core.jobs/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.core.jobs</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Tue May 25 15:00:03 EDT 2004
encoding/<project>=ISO-8859-1
eclipse.preferences.version=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n
Loading