-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tycho already offers to run an eclipse application with the tycho-extras/tycho-eclipserun-plugin, usually used to run an eclipse application. Recently there was a demand to even execute a project "like in eclipse", and there is even an (ant based) solution to run "tests in eclipse". Because of this it seem suitable to collect all these demands in a plugin dedicated to eclipse task
- Loading branch information
Showing
15 changed files
with
932 additions
and
6 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
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
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
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,8 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 | ||
org.eclipse.jdt.core.compiler.compliance=17 | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore | ||
org.eclipse.jdt.core.compiler.release=disabled | ||
org.eclipse.jdt.core.compiler.source=17 |
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,65 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho</artifactId> | ||
<version>5.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>tycho-eclipse-plugin</artifactId> | ||
<name>Tycho Eclipse Plugin</name> | ||
<packaging>maven-plugin</packaging> | ||
<prerequisites> | ||
<maven>${minimal-maven-version}</maven> | ||
</prerequisites> | ||
<description>Maven Plugins for working with Eclipse</description> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-plugin-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.plugin-tools</groupId> | ||
<artifactId>maven-plugin-annotations</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-utils</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.pde</groupId> | ||
<artifactId>org.eclipse.pde.core</artifactId> | ||
<version>3.17.100</version> | ||
<type>jar</type> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>sisu-equinox-launching</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-component-metadata</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
83 changes: 83 additions & 0 deletions
83
...eclipse-plugin/src/main/java/org/eclipse/tycho/eclipsebuild/BundleListTargetLocation.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,83 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Red Hat Inc. and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* - Mickael Istria (Red Hat Inc.) | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.eclipsebuild; | ||
|
||
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.pde.core.target.ITargetDefinition; | ||
import org.eclipse.pde.core.target.ITargetLocation; | ||
import org.eclipse.pde.core.target.TargetBundle; | ||
import org.eclipse.pde.core.target.TargetFeature; | ||
|
||
class BundleListTargetLocation implements ITargetLocation { | ||
|
||
private TargetBundle[] bundles; | ||
|
||
public BundleListTargetLocation(TargetBundle[] bundles) { | ||
this.bundles = bundles; | ||
} | ||
|
||
@Override | ||
public <T> T getAdapter(Class<T> adapter) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public IStatus resolve(ITargetDefinition definition, IProgressMonitor monitor) { | ||
return Status.OK_STATUS; | ||
} | ||
|
||
@Override | ||
public boolean isResolved() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public IStatus getStatus() { | ||
return Status.OK_STATUS; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return "BundleList"; //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
public String getLocation(boolean resolve) throws CoreException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public TargetBundle[] getBundles() { | ||
return this.bundles; | ||
} | ||
|
||
@Override | ||
public TargetFeature[] getFeatures() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String[] getVMArguments() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String serialize() { | ||
return null; | ||
} | ||
|
||
} |
142 changes: 142 additions & 0 deletions
142
tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipsebuild/EclipseBuild.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,142 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.eclipsebuild; | ||
|
||
import java.io.IOException; | ||
import java.io.Serializable; | ||
import java.nio.file.Path; | ||
import java.util.concurrent.Callable; | ||
|
||
import org.eclipse.core.resources.IMarker; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IProjectDescription; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.resources.IWorkspace; | ||
import org.eclipse.core.resources.IWorkspaceDescription; | ||
import org.eclipse.core.resources.IncrementalProjectBuilder; | ||
import org.eclipse.core.resources.ResourcesPlugin; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IPath; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.core.runtime.Platform; | ||
|
||
public class EclipseBuild implements Callable<EclipseBuildResult>, Serializable { | ||
|
||
private boolean debug; | ||
private String baseDir; | ||
|
||
EclipseBuild(Path projectDir, boolean debug) { | ||
this.debug = debug; | ||
this.baseDir = pathAsString(projectDir); | ||
} | ||
|
||
@Override | ||
public EclipseBuildResult call() throws Exception { | ||
EclipseBuildResult result = new EclipseBuildResult(); | ||
Platform.addLogListener((status, plugin) -> debug(status.toString())); | ||
disableAutoBuild(); | ||
deleteAllProjects(); | ||
IProject project = importProject(); | ||
IProgressMonitor debugMonitor = new IProgressMonitor() { | ||
|
||
@Override | ||
public void worked(int work) { | ||
|
||
} | ||
|
||
@Override | ||
public void subTask(String name) { | ||
debug("SubTask: " + name); | ||
} | ||
|
||
@Override | ||
public void setTaskName(String name) { | ||
debug("Task: " + name); | ||
} | ||
|
||
@Override | ||
public void setCanceled(boolean value) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isCanceled() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void internalWorked(double work) { | ||
|
||
} | ||
|
||
@Override | ||
public void done() { | ||
|
||
} | ||
|
||
@Override | ||
public void beginTask(String name, int totalWork) { | ||
setTaskName(name); | ||
} | ||
}; | ||
project.build(IncrementalProjectBuilder.CLEAN_BUILD, debugMonitor); | ||
project.build(IncrementalProjectBuilder.FULL_BUILD, debugMonitor); | ||
for (IMarker marker : project.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)) { | ||
result.addMarker(marker); | ||
debug(marker.toString()); | ||
} | ||
ResourcesPlugin.getWorkspace().save(true, new NullProgressMonitor()); | ||
return result; | ||
} | ||
|
||
static void disableAutoBuild() throws CoreException { | ||
IWorkspace workspace = ResourcesPlugin.getWorkspace(); | ||
IWorkspaceDescription desc = workspace.getDescription(); | ||
desc.setAutoBuilding(false); | ||
workspace.setDescription(desc); | ||
} | ||
|
||
private void deleteAllProjects() throws CoreException { | ||
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { | ||
project.delete(IResource.NEVER_DELETE_PROJECT_CONTENT | IResource.FORCE, new NullProgressMonitor()); | ||
} | ||
} | ||
|
||
private IProject importProject() throws CoreException, IOException { | ||
IPath projectPath = IPath.fromOSString(baseDir); | ||
IPath projectDescriptionFile = projectPath.append(IProjectDescription.DESCRIPTION_FILE_NAME); | ||
IProjectDescription projectDescription = ResourcesPlugin.getWorkspace() | ||
.loadProjectDescription(projectDescriptionFile); | ||
projectDescription.setLocation(projectPath); | ||
// projectDescription.setBuildSpec(new ICommand[0]); | ||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectDescription.getName()); | ||
project.create(projectDescription, new NullProgressMonitor()); | ||
project.open(new NullProgressMonitor()); | ||
return project; | ||
} | ||
|
||
private void debug(String string) { | ||
if (debug) { | ||
System.out.println(string); | ||
} | ||
} | ||
|
||
static String pathAsString(Path path) { | ||
if (path != null) { | ||
return path.toAbsolutePath().toString(); | ||
} | ||
return null; | ||
} | ||
|
||
} |
Oops, something went wrong.