Maven搭建Eclipse-plugin(RCP)开发环境

 

一、下载安装:Eclipse for RCP and RAP Developers

       地址: http://www.eclipse.org/downloads/

 

二、安装插件: WindowBuilder Pro
       地址: http://www.eclipse.org/windowbuilder/download.php

 

三、安装插件:Tycho Configurator

        打开:m2e Marketplace

        查找:Tycho Configurator

        如图:Maven搭建Eclipse-plugin(RCP)开发环境

 

四、新建普通的maven项目:HelloEP

pom.xml

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.fetaoily</groupId>
	<artifactId>HelloEP</artifactId>
	<version>1.0.0-SNAPSHOT</version>
	<packaging>pom</packaging>
	<modules>
		<module>../HelloEP.application</module>
		<module>../HelloEP.feature</module>
		<module>../HelloEP.product</module>
	</modules>

	<properties>
		<tycho-version>0.18.1</tycho-version>
	</properties>

	<repositories>
		<repository>
			<id>kepler</id>
			<layout>p2</layout>
			<url>http://download.eclipse.org/releases/kepler</url>
		</repository>
	</repositories>

	<build>
		<plugins>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-maven-plugin</artifactId>
				<version>${tycho-version}</version>
				<extensions>true</extensions>
			</plugin>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>target-platform-configuration</artifactId>
				<version>${tycho-version}</version>
				<configuration>
					<environments>
						<environment>
							<os>win32</os>
							<ws>win32</ws>
							<arch>x86</arch>
						</environment>
						<environment>
							<os>win32</os>
							<ws>win32</ws>
							<arch>x86_64</arch>
						</environment>
						<environment>
							<os>linux</os>
							<ws>gtk</ws>
							<arch>x86</arch>
						</environment>
						<environment>
							<os>linux</os>
							<ws>gtk</ws>
							<arch>x86_64</arch>
						</environment>
						<environment>
							<os>macosx</os>
							<ws>cocoa</ws>
							<arch>x86</arch>
						</environment>
						<environment>
							<os>macosx</os>
							<ws>cocoa</ws>
							<arch>x86_64</arch>
						</environment>
					</environments>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

 

 

五、新建Eclipse plugin项目:HelloEP.application, 并将其转换成maven项目

pom.xml

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<relativePath>../HelloEP/pom.xml</relativePath>
		<groupId>com.fetaoily</groupId>
		<artifactId>HelloEP</artifactId>
		<version>1.0.0-SNAPSHOT</version>
	</parent>

	<artifactId>HelloEP.application</artifactId>
	<packaging>eclipse-plugin</packaging>
</project>

 

六、新建Eclipse-feature项目:HelloEP.feature, 并将其转换成maven项目

pom.xml

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<relativePath>../HelloEP/pom.xml</relativePath>
		<groupId>com.fetaoily</groupId>
		<artifactId>HelloEP</artifactId>
		<version>1.0.0-SNAPSHOT</version>
	</parent>
	<artifactId>HelloEP.feature</artifactId>
	<packaging>eclipse-feature</packaging>
</project>

 

feature.xml 

<?xml version="1.0" encoding="UTF-8"?>
<feature
      id="HelloEP.feature"
      label="Feature"
      version="1.0.0.qualifier">

   <description url="http://www.example.com/description">
      [Enter Feature Description here.]
   </description>

   <copyright url="http://www.example.com/copyright">
      [Enter Copyright Description here.]
   </copyright>

   <license url="http://www.example.com/license">
      [Enter License Description here.]
   </license>

</feature>

 

 

七、新建普通的maven项目: HelloEP.product

pom.xml

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<relativePath>../HelloEP/pom.xml</relativePath>
		<groupId>com.fetaoily</groupId>
		<artifactId>HelloEP</artifactId>
		<version>1.0.0-SNAPSHOT</version>
	</parent>

	<artifactId>HelloEP.product</artifactId>
	<packaging>eclipse-repository</packaging>

	<build>
		<plugins>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-p2-repository-plugin</artifactId>
				<version>${tycho-version}</version>
				<configuration>
					<includeAllDependencies>true</includeAllDependencies>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-p2-director-plugin</artifactId>
				<version>${tycho-version}</version>
				<executions>
					<execution>
						<id>materialize-products</id>
						<goals>
							<goal>materialize-products</goal>
						</goals>
					</execution>
					<execution>
						<id>archive-products</id>
						<goals>
							<goal>archive-products</goal>
						</goals>
					</execution>
				</executions>

				<configuration>
					<formats>
						<win32>zip</win32>
						<linux>tar.gz</linux>
						<maosx>tar.gz</maosx>
					</formats>
					<products>
						<product>
							<id>HelloEP</id>
							<attachId>HelloEP</attachId>
						</product>
					</products>
					<!-- global optional parameters (with default values) -->
					<installFeatures>true</installFeatures>
					<profile>DefaultProfile</profile>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

 

HelloEP.product

<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product name="RCP Application" uid="HelloEP" id="HelloEP.application.product" application="HelloEP.application.application" version="1.0.0.qualifier" useFeatures="false" includeLaunchers="true">

   <configIni use="default">
   </configIni>

   <launcherArgs>
      <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
   </launcherArgs>

   <windowImages i16="icons/alt_window_16.gif" i32="icons/alt_window_32.gif"/>

   <plugins>
      <plugin id="HelloEP.application"/>
      <plugin id="com.ibm.icu"/>
      <plugin id="javax.annotation"/>
      <plugin id="javax.inject"/>
      <plugin id="javax.xml"/>
      <plugin id="org.apache.batik.css"/>
      <plugin id="org.apache.batik.util"/>
      <plugin id="org.apache.batik.util.gui"/>
      <plugin id="org.eclipse.core.commands"/>
      <plugin id="org.eclipse.core.contenttype"/>
      <plugin id="org.eclipse.core.databinding"/>
      <plugin id="org.eclipse.core.databinding.observable"/>
      <plugin id="org.eclipse.core.databinding.property"/>
      <plugin id="org.eclipse.core.expressions"/>
      <plugin id="org.eclipse.core.jobs"/>
      <plugin id="org.eclipse.core.runtime"/>
      <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/>
      <plugin id="org.eclipse.e4.core.commands"/>
      <plugin id="org.eclipse.e4.core.contexts"/>
      <plugin id="org.eclipse.e4.core.di"/>
      <plugin id="org.eclipse.e4.core.di.extensions"/>
      <plugin id="org.eclipse.e4.core.services"/>
      <plugin id="org.eclipse.e4.ui.bindings"/>
      <plugin id="org.eclipse.e4.ui.css.core"/>
      <plugin id="org.eclipse.e4.ui.css.swt"/>
      <plugin id="org.eclipse.e4.ui.css.swt.theme"/>
      <plugin id="org.eclipse.e4.ui.di"/>
      <plugin id="org.eclipse.e4.ui.model.workbench"/>
      <plugin id="org.eclipse.e4.ui.services"/>
      <plugin id="org.eclipse.e4.ui.widgets"/>
      <plugin id="org.eclipse.e4.ui.workbench"/>
      <plugin id="org.eclipse.e4.ui.workbench.addons.swt"/>
      <plugin id="org.eclipse.e4.ui.workbench.renderers.swt"/>
      <plugin id="org.eclipse.e4.ui.workbench.swt"/>
      <plugin id="org.eclipse.e4.ui.workbench3"/>
      <plugin id="org.eclipse.emf.common"/>
      <plugin id="org.eclipse.emf.ecore"/>
      <plugin id="org.eclipse.emf.ecore.change"/>
      <plugin id="org.eclipse.emf.ecore.xmi"/>
      <plugin id="org.eclipse.equinox.app"/>
      <plugin id="org.eclipse.equinox.common"/>
      <plugin id="org.eclipse.equinox.ds"/>
      <plugin id="org.eclipse.equinox.event"/>
      <plugin id="org.eclipse.equinox.preferences"/>
      <plugin id="org.eclipse.equinox.registry"/>
      <plugin id="org.eclipse.equinox.util"/>
      <plugin id="org.eclipse.help"/>
      <plugin id="org.eclipse.jface"/>
      <plugin id="org.eclipse.jface.databinding"/>
      <plugin id="org.eclipse.osgi"/>
      <plugin id="org.eclipse.osgi.services"/>
      <plugin id="org.eclipse.swt"/>
      <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/>
      <plugin id="org.eclipse.ui"/>
      <plugin id="org.eclipse.ui.workbench"/>
      <plugin id="org.w3c.css.sac"/>
      <plugin id="org.w3c.dom.smil"/>
      <plugin id="org.w3c.dom.svg"/>
   </plugins>

   <configurations>
      <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="1" />
   </configurations>

</product>

 

八、打包测试

>cd HelloEP
>mvn clean package
  

 

未完待续...