Skip to content

Commit

Permalink
Setup a clean Tycho architecture
Browse files Browse the repository at this point in the history
This architecture:
 - relies on a target platform to avoid platform-dependent builds
 - uses only OSGi bundles and avoids declaring dependencies in POM files

This commit introduces some major version changes:
 - bump Java version to 1.8
 - bump Pitest version to 1.4.6
 - bump project's version to 2.0.0-SNAPSHOT

checkstyle.xml has also been slightly modified:
 - remove deprecated maxLineLength property of LeftCurly rule
 - allow methods that start with a single lower case letter

Also clean code style so that it is consistent and in accordance
with Checkstyle's rules (fixes #70).

Build is automated with Travis CI (#69).
  • Loading branch information
echebbi committed Aug 15, 2019
1 parent 3f860c3 commit d2ec720
Show file tree
Hide file tree
Showing 207 changed files with 3,329 additions and 1,284 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
# Maven
target/
# Eclipse
.classpath
.project
.settings/
bin/
*.versionsBackup
*.versionsBackup
9 changes: 9 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>

<extensions>
<extension>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-pomless</artifactId>
<version>1.2.0</version>
</extension>
</extensions>
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: java
jdk:
- openjdk6
- openjdk8

script: cd guava-bundle && mvn install && cd ../pitest-bundles && mvn install && cd ../pitrunner && mvn install && cd ../pitclipse-plugin && mvn install
script: mvn verify
7 changes: 7 additions & 0 deletions bundles/org.pitest.pitclipse.core/.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.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
34 changes: 34 additions & 0 deletions bundles/org.pitest.pitclipse.core/.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.pitest.pitclipse.core</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>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
31 changes: 15 additions & 16 deletions bundles/org.pitest.pitclipse.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Pitclipse Core
Bundle-SymbolicName: org.pitest.pitclipse.core;singleton:=true
Bundle-Version: 1.1.7.201805090619
Bundle-Version: 2.0.0.qualifier
Bundle-Activator: org.pitest.pitclipse.core.PitCoreActivator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.jdt.core;bundle-version="3.8.3",
org.eclipse.debug.ui;bundle-version="3.8.2",
org.eclipse.jdt.debug.ui;bundle-version="3.6.100",
org.eclipse.jdt.launching;bundle-version="3.6.101",
org.eclipse.jdt.ui;bundle-version="3.8.2",
org.pitest.pitrunner;bundle-version="1.1.7",
org.pitest.osgi;bundle-version="1.1.9",
org.pitest.command-line-osgi;bundle-version="1.1.9",
org.pitest.html-report-osgi;bundle-version="1.1.9",
org.pitest.guava-shade-osgi;bundle-version="18.0.0"
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.1,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.11.2,4.0.0)",
org.pitest.pitclipse.runner;bundle-version="[2.0.0,3.0.0)",
com.google.guava;bundle-version="21.0.0",
org.pitest;bundle-version="1.4.6",
org.eclipse.core.resources;bundle-version="[3.10.1,4.0.0)",
org.eclipse.ui;bundle-version="[3.107.0,4.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: Pitest.org
Bundle-ClassPath: .
Export-Package: org.pitest.pitclipse.core,
org.pitest.pitclipse.core.extension.handler,
org.pitest.pitclipse.core.extension.point
org.pitest.pitclipse.core.extension.point,
org.pitest.pitclipse.core.launch,
org.pitest.pitclipse.core.preferences
Automatic-Module-Name: org.pitest.pitclipse.core
Import-Package: org.eclipse.jface.preference,
org.eclipse.ui.preferences
3 changes: 1 addition & 2 deletions bundles/org.pitest.pitclipse.core/build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
source.. = src/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/
.
jars.compile.order = .
65 changes: 7 additions & 58 deletions bundles/org.pitest.pitclipse.core/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,7 @@
<extension-point id="org.pitest.pitclipse.core.results" name="PitResults" schema="schema/org.pitest.pitclipse.core.results.exsd"/>
<extension-point id="org.pitest.pitclipse.core.mutations.results" name="PitMutationsResults" schema="schema/org.pitest.pitclipse.core.mutations.results.exsd"/>
<extension-point id="org.pitest.pitclipse.core.executePit" name="PitExecutor" schema="schema/org.pitest.pitclipse.core.executePit.exsd"/>
<extension
point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
name="PIT Mutation Test"
delegate="org.pitest.pitclipse.core.launch.PitLaunchConfigurationDelegate"
modes="run"
id="org.pitest.pitclipse.core.mutationTest">
</launchConfigurationType>
</extension>
<extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
<launchConfigurationTypeImage
icon="icons/pit.gif"
configTypeID="org.pitest.pitclipse.core.mutationTest"
id="org.pitest.pitclipse.core.mutationTest.icon">
</launchConfigurationTypeImage>
</extension>
<extension point="org.eclipse.debug.ui.launchShortcuts">
<shortcut
id="org.pitest.pitclipse.core.mutationTest.shortcut"
class="org.pitest.pitclipse.core.launch.PitLaunchShortcut"
label="PIT Mutation Test"
icon="icons/pit.gif"
modes="run">
<contextualLaunch>
<contextLabel mode="run" label="PIT Mutation Test" />
<enablement>

</enablement>
</contextualLaunch>
</shortcut>
</extension>
<extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
type="org.pitest.pitclipse.core.mutationTest"
class="org.pitest.pitclipse.core.launch.PitLaunchConfigurationTabGroup"
id="org.pitest.pitclipse.core.mutationTest.config">
</launchConfigurationTabGroup>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
class="org.pitest.pitclipse.core.preferences.PitPreferencePage"
id="org.pitest.pitclipse.core.preferences.PitPreferencePage"
name="Pitest">
</page>
<page
id="org.pitest.pitclipse.core.preferences.PitMutatorsPreferencePage"
name="Mutators"
class="org.pitest.pitclipse.core.preferences.PitMutatorsPreferencePage"
category="org.pitest.pitclipse.core.preferences.PitPreferencePage">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.pitest.pitclipse.core.preferences.PreferenceInitializer">
</initializer>
</extension>

<extension
point="org.pitest.pitclipse.core.executePit">
<pit_options
Expand All @@ -73,4 +16,10 @@
<results
class="org.pitest.pitclipse.core.result.MutationsModelNotifier"></results>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.pitest.pitclipse.core.preferences.PreferenceInitializer">
</initializer>
</extension>
</plugin>
Original file line number Diff line number Diff line change
@@ -1,54 +1,56 @@
package org.pitest.pitclipse.core;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.BundleContext;
import org.pitest.pitclipse.pitrunner.config.PitConfiguration;
import org.pitest.pitclipse.pitrunner.config.PitExecutionMode;
import org.pitest.pitclipse.reloc.guava.collect.ImmutableList;
import org.pitest.pitclipse.runner.config.PitConfiguration;
import org.pitest.pitclipse.runner.config.PitExecutionMode;

import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;

import static com.google.common.collect.ImmutableList.copyOf;
import static com.google.common.collect.ImmutableList.of;
import static com.google.common.io.Files.createParentDirs;
import static com.google.common.io.Files.createTempDir;
import static org.eclipse.core.runtime.FileLocator.getBundleFile;
import static org.pitest.pitclipse.core.preferences.PitMutatorsPreferencePage.PIT_MUTATORS;
import static org.pitest.pitclipse.core.preferences.PitPreferencePage.AVOID_CALLS_TO;
import static org.pitest.pitclipse.core.preferences.PitPreferencePage.EXCLUDED_CLASSES;
import static org.pitest.pitclipse.core.preferences.PitPreferencePage.EXCLUDED_METHODS;
import static org.pitest.pitclipse.core.preferences.PitPreferencePage.INCREMENTAL_ANALYSIS;
import static org.pitest.pitclipse.core.preferences.PitPreferencePage.PIT_EXECUTION_MODE;
import static org.pitest.pitclipse.core.preferences.PitPreferencePage.RUN_IN_PARALLEL;
import static org.pitest.pitclipse.core.preferences.PitPreferencePage.TIMEOUT;
import static org.pitest.pitclipse.core.preferences.PitPreferencePage.TIMEOUT_FACTOR;
import static org.pitest.pitclipse.reloc.guava.collect.ImmutableList.copyOf;
import static org.pitest.pitclipse.reloc.guava.collect.ImmutableList.of;
import static org.pitest.pitclipse.reloc.guava.io.Files.createParentDirs;
import static org.pitest.pitclipse.reloc.guava.io.Files.createTempDir;
import static org.pitest.pitclipse.core.preferences.PitPreferences.AVOID_CALLS_TO;
import static org.pitest.pitclipse.core.preferences.PitPreferences.EXCLUDED_CLASSES;
import static org.pitest.pitclipse.core.preferences.PitPreferences.EXCLUDED_METHODS;
import static org.pitest.pitclipse.core.preferences.PitPreferences.INCREMENTAL_ANALYSIS;
import static org.pitest.pitclipse.core.preferences.PitPreferences.PIT_EXECUTION_MODE;
import static org.pitest.pitclipse.core.preferences.PitPreferences.PIT_MUTATORS;
import static org.pitest.pitclipse.core.preferences.PitPreferences.RUN_IN_PARALLEL;
import static org.pitest.pitclipse.core.preferences.PitPreferences.TIMEOUT;
import static org.pitest.pitclipse.core.preferences.PitPreferences.TIMEOUT_FACTOR;

/**
* The activator class controls the plug-in life cycle
*/
public class PitCoreActivator extends AbstractUIPlugin {
public class PitCoreActivator extends Plugin {

private static final String HTML_RESULTS_DIR = "html_results";
private static final String HTML_FILE = "index.html";
private static final String STATE_FILE = "state-1.1.0.out";
private static final String HISTORY_DIR = "history";

// The plug-in ID
public static final String PLUGIN_ID = "org.pitest.pitclipse.core"; //$NON-NLS-1$

// The shared instance
private static PitCoreActivator plugin;

private IPreferenceStore preferences;

private ImmutableList<String> pitClasspath = of();

Expand All @@ -63,6 +65,13 @@ public List<String> getPitClasspath() {
private void setPitClasspath(List<String> classpath) {
pitClasspath = copyOf(classpath);
}

public IPreferenceStore getPreferenceStore() {
if (preferences == null) {
preferences = new ScopedPreferenceStore(InstanceScope.INSTANCE, PLUGIN_ID);
}
return preferences;
}

/*
* (non-Javadoc)
Expand All @@ -76,21 +85,38 @@ public void start(BundleContext context) throws Exception { // NOPMD - Base
// class defines
// signature
super.start(context);
plugin = this;
// this.context = context;
setActivator(this);
setupStateDirectories();
ImmutableList.Builder<String> builder = ImmutableList.builder();
builder.add(getBundleFile(Platform.getBundle("org.pitest.command-line-osgi")).getCanonicalPath());
builder.add(getBundleFile(Platform.getBundle("org.pitest.html-report-osgi")).getCanonicalPath());
builder.add(getBundleFile(Platform.getBundle("org.pitest.osgi")).getCanonicalPath());
builder.add(getBundleFile(Platform.getBundle("org.pitest.pitrunner")).getCanonicalPath());
builder.add(getBundleFile(Platform.getBundle("org.pitest.guava-shade-osgi")).getCanonicalPath());
setPitClasspath(builder.build());

ImmutableList<String> pitestClasspath = ImmutableList.of(
getBundleFile(Platform.getBundle("org.pitest")).getCanonicalPath(),
getBundleFile(Platform.getBundle("org.pitest.pitclipse.runner")).getCanonicalPath(),
getBundleFile(Platform.getBundle("org.pitest.pitclipse.runner")).getCanonicalPath() + File.separator + "bin",
getBundleFile(Platform.getBundle("org.pitest")).getCanonicalPath() + File.separator + "pitest-1.4.6.jar",
getBundleFile(Platform.getBundle("org.pitest")).getCanonicalPath() + File.separator + "pitest-entry-1.4.6.jar",
getBundleFile(Platform.getBundle("org.pitest")).getCanonicalPath() + File.separator + "pitest-command-line-1.4.6.jar",
getBundleFile(Platform.getBundle("org.pitest")).getCanonicalPath() + File.separator + "pitest-html-report-1.4.6.jar",
getBundleFile(Platform.getBundle("com.google.guava")).getCanonicalPath()
);
Builder<String> pitclipseClasspath = ImmutableList.<String>builder().addAll(pitestClasspath);

if (Platform.getBundle("org.pitest.pitclipse.listeners") != null) {
pitclipseClasspath.add(getBundleFile(Platform.getBundle("org.pitest.pitclipse.listeners")).getCanonicalPath());
pitclipseClasspath.add(getBundleFile(Platform.getBundle("org.pitest.pitclipse.listeners")).getCanonicalPath() + File.separator + "bin");
}
setPitClasspath(pitclipseClasspath.build());
}

private void setupStateDirectories() {
setupResultDir();
setupHistoryFile();
}

// private static IPath getStateLocation() {
// return Platform.getStateLocation(context.getBundle());
// }

private void setupHistoryFile() {
IPath pluginLocation = getStateLocation();
Expand Down Expand Up @@ -149,17 +175,17 @@ public static PitCoreActivator 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);
}
// /**
// * 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);
// }

public static void log(String msg) {
log(Status.INFO, msg, null);
Expand All @@ -177,30 +203,6 @@ public static void warn(String msg, Throwable t) {
log(Status.WARNING, msg, t);
}

public static Shell getActiveWorkbenchShell() {
IWorkbenchWindow workBenchWindow = getActiveWorkbenchWindow();
if (workBenchWindow == null) {
return null;
}
return workBenchWindow.getShell();
}

/**
* Returns the active workbench window
*
* @return the active workbench window
*/
public static IWorkbenchWindow getActiveWorkbenchWindow() {
if (plugin == null) {
return null;
}
IWorkbench workBench = plugin.getWorkbench();
if (workBench == null) {
return null;
}
return workBench.getActiveWorkbenchWindow();
}

public File emptyResultDir() {
recursiveClean(resultDir);
return resultDir;
Expand Down
Loading

0 comments on commit d2ec720

Please sign in to comment.