-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- egradle-plugin to egradle-plugin-main - new egradle-plugin-junit-contribution project all dependencies to junit are handled here - adds itself to egradle main toolbar - contains a junit result finder - contains a compressor to build a single junit-result which can be imported... - help updated - version to 0.4.0.beta
- Loading branch information
Showing
120 changed files
with
1,085 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+6.95 KB
egradle-other/src/main/resources/images/importGradleTestsToEclipseView.pdn
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Egradle Junit contribution plugin | ||
Bundle-SymbolicName: de.jcup.egradle.eclipse.plugin.junit.contribution;singleton:=true | ||
Bundle-Version: 0.4.0.beta | ||
Bundle-Activator: de.jcup.egradle.eclipse.junit.contribution.Activator | ||
Bundle-Vendor: Albert Tregnaghi | ||
Require-Bundle: org.eclipse.ui, | ||
org.eclipse.core.runtime, | ||
org.eclipse.jdt.junit;bundle-version="3.9.0", | ||
de.jcup.egradle.eclipse.plugin.main;bundle-version="0.4.0" | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | ||
Bundle-ActivationPolicy: lazy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* special build.gradle variant for eclipse-plugin | ||
* | ||
* Divided sources into src/main/java and src/main/java-eclipse - so simple junit tests can be done inside src/test/java without any eclipse dependencies | ||
* | ||
* | ||
*/ | ||
dependencies { | ||
compile project(':egradle-plugin-main') | ||
compile library.commons_lang | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source.. = src/main/java/,\ | ||
src/main/java-eclipse/ | ||
output.. = bin/ | ||
bin.includes = plugin.xml,\ | ||
META-INF/,\ | ||
.,\ | ||
icons/ |
Binary file added
BIN
+933 Bytes
egradle-plugin-junit-contribution/icons/importGradleTestsToEclipseView.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
|
||
<extension | ||
point="org.eclipse.ui.commands"> | ||
<command | ||
name="Import JUnit-Testresults" | ||
categoryId="egradle.commands.category" | ||
id="de.jcup.egradle.eclipse.junit.contribution.commands.importTestResultCommand"> | ||
</command> | ||
</extension> | ||
<extension | ||
point="org.eclipse.ui.handlers"> | ||
<handler | ||
commandId="de.jcup.egradle.eclipse.junit.contribution.commands.importTestResultCommand" | ||
class="de.jcup.egradle.eclipse.junit.contribution.handlers.ImportGradleJunitResultsHandler"> | ||
</handler> | ||
</extension> | ||
<extension | ||
point="org.eclipse.ui.bindings"> | ||
<key | ||
commandId="de.jcup.egradle.eclipse.junit.contribution.commands.importTestResultCommand" | ||
contextId="org.eclipse.ui.contexts.window" | ||
sequence="M1+7" | ||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> | ||
</key> | ||
</extension> | ||
<extension | ||
point="org.eclipse.ui.menus"> | ||
<menuContribution | ||
allPopups="false" | ||
locationURI="toolbar:egradle.toolbars.mainToolbar?after=egradle.toolbars.refreshEclipseCommand"> | ||
<command | ||
commandId="de.jcup.egradle.eclipse.junit.contribution.commands.importTestResultCommand" | ||
icon="icons/importGradleTestsToEclipseView.gif" | ||
id="egradle.toolbars.importTestResultCommand" | ||
tooltip="Import gradle test results to junit view"> | ||
</command> | ||
</menuContribution> | ||
</extension> | ||
|
||
</plugin> |
File renamed without changes.
78 changes: 78 additions & 0 deletions
78
...tribution/src/main/java-eclipse/de/jcup/egradle/eclipse/junit/contribution/Activator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2016 Albert Tregnaghi | ||
* | ||
* 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 de.jcup.egradle.eclipse.junit.contribution; | ||
|
||
import org.eclipse.jface.resource.ImageDescriptor; | ||
import org.eclipse.ui.plugin.AbstractUIPlugin; | ||
import org.osgi.framework.BundleContext; | ||
|
||
/** | ||
* The activator class controls the plug-in life cycle | ||
*/ | ||
public class Activator extends AbstractUIPlugin { | ||
|
||
// The plug-in ID | ||
public static final String PLUGIN_ID = "de.jcup.egradle.eclipse.plugin.junit.contribution"; //$NON-NLS-1$ | ||
|
||
// The shared instance | ||
private static Activator plugin; | ||
|
||
/** | ||
* The constructor | ||
*/ | ||
public Activator() { | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) | ||
*/ | ||
public void start(BundleContext context) throws Exception { | ||
super.start(context); | ||
plugin = this; | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) | ||
*/ | ||
public void stop(BundleContext context) throws Exception { | ||
plugin = null; | ||
super.stop(context); | ||
} | ||
|
||
/** | ||
* Returns the shared instance | ||
* | ||
* @return the shared instance | ||
*/ | ||
public static Activator getDefault() { | ||
return plugin; | ||
} | ||
|
||
/** | ||
* Returns an image descriptor for the image file at the given | ||
* plug-in relative path | ||
* | ||
* @param path the path | ||
* @return the image descriptor | ||
*/ | ||
public static ImageDescriptor getImageDescriptor(String path) { | ||
return imageDescriptorFromPlugin(PLUGIN_ID, path); | ||
} | ||
|
||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...c/main/java-eclipse/de/jcup/egradle/eclipse/junit/contribution/JunitContributionUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2016 Albert Tregnaghi | ||
* | ||
* 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 de.jcup.egradle.eclipse.junit.contribution; | ||
|
||
import org.eclipse.ui.IViewPart; | ||
import org.eclipse.ui.IWorkbenchPage; | ||
import org.eclipse.ui.PartInitException; | ||
|
||
import de.jcup.egradle.eclipse.api.EGradleUtil; | ||
|
||
|
||
public class JunitContributionUtil { | ||
|
||
private static final String ECLIPSE_JDT_JUNIT_RESULT_VIEW = "org.eclipse.jdt.junit.ResultView"; | ||
|
||
public static void showTestRunnerViewPartInActivePage() { | ||
try { | ||
IWorkbenchPage page= EGradleUtil.getActivePage(); | ||
if (page == null){ | ||
return; | ||
} | ||
IViewPart view = page.findView(ECLIPSE_JDT_JUNIT_RESULT_VIEW); | ||
if (view == null) { | ||
/* create and show the result view if it isn't created yet.*/ | ||
page.showView(ECLIPSE_JDT_JUNIT_RESULT_VIEW, null, IWorkbenchPage.VIEW_VISIBLE); | ||
} | ||
} catch (PartInitException pie) { | ||
EGradleUtil.log(pie); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
...ipse/de/jcup/egradle/eclipse/junit/contribution/handlers/ImportGradleJunitResultsJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* Copyright 2016 Albert Tregnaghi | ||
* | ||
* 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 de.jcup.egradle.eclipse.junit.contribution.handlers; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.Status; | ||
import org.eclipse.core.runtime.SubMonitor; | ||
import org.eclipse.core.runtime.jobs.Job; | ||
import org.eclipse.jdt.junit.JUnitCore; | ||
import org.eclipse.swt.widgets.Display; | ||
import org.w3c.dom.Document; | ||
|
||
import de.jcup.egradle.core.api.XMLWriter; | ||
import de.jcup.egradle.eclipse.api.EGradleUtil; | ||
import de.jcup.egradle.eclipse.junit.contribution.Activator; | ||
import de.jcup.egradle.eclipse.junit.contribution.JunitContributionUtil; | ||
import de.jcup.egradle.junit.JUnitResultFilesFinder; | ||
import de.jcup.egradle.junit.JUnitResultsCompressor; | ||
|
||
public class ImportGradleJunitResultsJob extends Job { | ||
|
||
XMLWriter writer = new XMLWriter(); | ||
JUnitResultsCompressor compressor = new JUnitResultsCompressor(); | ||
JUnitResultFilesFinder finder = new JUnitResultFilesFinder(); | ||
|
||
public ImportGradleJunitResultsJob(String name) { | ||
super(name); | ||
} | ||
|
||
@Override | ||
protected IStatus run(IProgressMonitor monitor) { | ||
monitor.beginTask("Import junit results from gradle", 100); | ||
File tempFile = new File(System.getProperty("user.home")+"/.egradle/TEST-egradle-all-testresults.tmp.xml"); | ||
try { | ||
/* remove old temp file if existing */ | ||
if (tempFile.exists()) { | ||
if (!tempFile.delete()) { | ||
throw new IOException("Cannot delete temporary file for gradle results!"); | ||
} | ||
} | ||
|
||
/* fetch files*/ | ||
monitor.setTaskName("Fetching gradle junit result files"); | ||
File rootFolder = EGradleUtil.getRootProjectFolder(); | ||
|
||
Collection<File> files = finder.findTestFilesInRootProjectFolder(rootFolder); | ||
List<InputStream> streams = new ArrayList<>(); | ||
for (File file : files) { | ||
streams.add(new FileInputStream(file)); | ||
} | ||
monitor.worked(40); | ||
|
||
/* compress*/ | ||
monitor.setTaskName("Compress results for import"); | ||
Document singleDoc = compressor.compress(streams); | ||
monitor.worked(60); | ||
|
||
/* write to file*/ | ||
monitor.setTaskName("Create temp file"); | ||
tempFile.getParentFile().mkdirs(); | ||
if (!tempFile.createNewFile()){ | ||
throw new IOException("Cannot create empty temp file!"); | ||
} | ||
writer.writeDocumentToFile(singleDoc, tempFile); | ||
monitor.worked(80); | ||
|
||
/* show inside junit viewer*/ | ||
monitor.setTaskName("Load into junit view"); | ||
|
||
// JUnitCore.importTestRunSession(tempFile.toURI().toURL().toExternalForm(), monitor); | ||
JUnitCore.importTestRunSession(tempFile); | ||
monitor.worked(90); | ||
|
||
monitor.setTaskName("Open test results in view"); | ||
Display.getDefault().asyncExec(new Runnable() { | ||
|
||
@Override | ||
public void run() { | ||
JunitContributionUtil.showTestRunnerViewPartInActivePage(); | ||
monitor.worked(100); | ||
} | ||
}); | ||
} catch (Exception e) { | ||
return new Status(Status.ERROR, Activator.PLUGIN_ID, "Cannot import junit results", e); | ||
} | ||
return Status.OK_STATUS; | ||
} | ||
|
||
} |
Oops, something went wrong.