Difference between revisions of "DSDP/MTJ/Requirements/MTJ Build"

From Eclipsepedia

< DSDP‎ | MTJ‎ | Requirements
Jump to: navigation, search
(ID: build:FR007 - MTJ shall define an extension point for Build Hooks)
(ID: build:FR007 - MTJ shall define an extension point for build hooks)
Line 84: Line 84:
 
** <font color="blue">build-hook</font> (Element reference) ('''1 - *''')
 
** <font color="blue">build-hook</font> (Element reference) ('''1 - *''')
  
 +
*'''''Example'''''
 +
The example bellow illustrates an example extension:
 +
<pre>
 +
<extension point="org.eclipse.mtj.core.mtjbuildhook">
 +
    <build-hook
 +
          hook="org.eclipse.mtj.core.build.SunBuildHook"
 +
          priority="1"
 +
          sdk-filter="Sun.*">
 +
    </build-hook>
 +
    <build-hook
 +
          hook="org.eclipse.mtj.core.build.CommonBuildHook"
 +
          priority="100"
 +
          sdk-filter=".*">
 +
    </build-hook>
 +
</extension>
 +
</pre>
 +
 +
The example bellow illustrates an IMTJBuildHook Interface implementation:
 +
<pre>
 +
//
 +
// THIS BUILD HOOK ADDS A README.TXT FROM THE HOOK PROVIDER
 +
// INTO A SOURCE FOLDER IN ORDER TO HAVE IT PACKAGED WITH THE
 +
// APPLICATION'S JAR FILE DURING BUILD. IT REMOVES THE FILE
 +
// RIGHT AFTER THE PACKAGE BUILD HAS FINISHED.
 +
//
 +
public class SunBuildHook implements IMTJBuildHook {
 +
 +
private File readme;
 +
 +
@Override
 +
public void preBuild(IMTJProject project, IProgressMonitor _monitor)  throws CoreException {
 +
if (!(project instanceof IMidletSuiteProject)) {
 +
return;
 +
}
 +
IMidletSuiteProject suiteProject = (IMidletSuiteProject) project;
 +
IFolder src = suiteProject.getJavaProject().getProject().getFolder("src");
 +
 +
try {
 +
readme = new File(src.getLocation().toFile(), "README.TXT");
 +
PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(readme)));
 +
writer.write("Sun Readme...");
 +
writer.close();
 +
} catch (Exception e) {
 +
throw new CoreException(MTJCore.newStatus(IStatus.ERROR, 999, e.getMessage(), e));
 +
} finally {
 +
src.refreshLocal(IResource.DEPTH_ONE, _monitor);
 +
}
 +
}
 +
 +
@Override
 +
public void posBuild(IMTJProject project, IProgressMonitor _monitor) throws CoreException {
 +
if (readme != null) {
 +
readme.delete();
 +
}
 +
}
 +
}
 +
</pre>
 
'''Priority:''' 1
 
'''Priority:''' 1
  

Revision as of 14:08, 7 April 2009

Contents

ID: build:FR001 - MTJ shall provide a MIDP Packing Build Process.

Description: TBD

Priority: 1

Owner: Motorola/Craig Setera

Status: Accepted on 17-June-2008

Community Review: 17-June-2008

ID: build:FR002 - MTJ shall provide an option to setup proguard code obfuscation.

Description: TBD

Priority: 1

Owner: Motorola/Craig Setera

Status: Accepted on 17-June-2008

Community Review: 17-June-2008

ID: build:FR003 - MTJ shall provide an option to setup a signing keystore.

Description: TBD

Priority: 1

Owner: Motorola/Craig Setera

Status: Accepted on 17-June-2008

Community Review: 17-June-2008

ID: build:FR004 - MTJ shall provide an option to build the MIDlet Suite JAR without obfuscation.

Description: TBD

Priority: 1

Owner: Motorola/Craig Setera

Status: Accepted on 17-June-2008

Community Review: 17-June-2008

ID: build:FR005 - MTJ shall provide an option to build an obfuscated MIDlet Suite JAR.

Description: TBD

Priority: 1

Owner: Motorola/Craig Setera

Status: Accepted on 17-June-2008

Community Review: 17-June-2008

ID: build:FR006 - MTJ shall provide an option to export all build process an an antenna build XML file.

Description: TBD

Priority: 1

Owner: Motorola/Craig Setera

Status: Accepted on 17-June-2008

Community Review: 17-June-2008

ID: build:FR007 - MTJ shall define an extension point for build hooks

Description: An Extension Point where third party plugins can provide build hooks to run before and after the build process.

The extension point will be composed by the following elements:

  • build-hook
    • sdk-filter (String Attribute) [REQUIRED]

      Description: A regular expression matching the target SDKs names in order to filter the hook usage among all available SDKs.

    • hook (Java Attribute) [REQUIRED]

      Description: IMTJBuildHook Interface defines methods for pre and pos build operations. It must be implemented by the hooks providers.

    • priority (String Attribute) [REQUIRED]

      Description: An integer defining the priority order of the hook. It must be a number greater that or equal to zero, the lower numbers means higher priorities.

  • Sequence compositor
    • build-hook (Element reference) (1 - *)
  • Example

The example bellow illustrates an example extension:

 <extension point="org.eclipse.mtj.core.mtjbuildhook">
    <build-hook
          hook="org.eclipse.mtj.core.build.SunBuildHook"
          priority="1"
          sdk-filter="Sun.*">
    </build-hook>
    <build-hook
          hook="org.eclipse.mtj.core.build.CommonBuildHook"
          priority="100"
          sdk-filter=".*">
    </build-hook>
 </extension>

The example bellow illustrates an IMTJBuildHook Interface implementation:

//
// THIS BUILD HOOK ADDS A README.TXT FROM THE HOOK PROVIDER
// INTO A SOURCE FOLDER IN ORDER TO HAVE IT PACKAGED WITH THE
// APPLICATION'S JAR FILE DURING BUILD. IT REMOVES THE FILE
// RIGHT AFTER THE PACKAGE BUILD HAS FINISHED.
//
public class SunBuildHook implements IMTJBuildHook {

	private File readme;
	
	@Override
	public void preBuild(IMTJProject project, IProgressMonitor _monitor)  throws CoreException {
		if (!(project instanceof IMidletSuiteProject)) {
			return;
		}
		IMidletSuiteProject suiteProject = (IMidletSuiteProject) project;
		IFolder src = suiteProject.getJavaProject().getProject().getFolder("src");

		try {
			readme = new File(src.getLocation().toFile(), "README.TXT");
			PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(readme)));
			writer.write("Sun Readme...");
			writer.close();
		} catch (Exception e) {
			throw new CoreException(MTJCore.newStatus(IStatus.ERROR, 999, e.getMessage(), e));
		} finally {
			src.refreshLocal(IResource.DEPTH_ONE, _monitor);
		}
	}

	@Override
	public void posBuild(IMTJProject project, IProgressMonitor _monitor) throws CoreException {
		if (readme != null) {
			readme.delete();
		}
	}
}

Priority: 1

Owner: David Marques

Status: Proposed on 07-Mar-2009

Community Review: TBD

Related Bugs: TBD



Back to main DSDP/MTJ/Requirements