public class P2DirectorModel extends Object
Runs P2 director to install artifacts from P2 repositories.
WARNING: This part of Goomph currently has the following precondition: your project must have the property VER_ECLIPSE=4.5.2 (or some other version), and you must have installed that Eclipse using Wuff. We will remove this restriction in the future.
import com.diffplug.gradle.*
import com.diffplug.gradle.pde.*
import com.diffplug.common.swt.os.*
// list of OS values for which we want to create an installer
def INSTALLERS = OS.values()
def VER_JRE = '1.8.0.40'
// add each of the core IUs
def coreModel = new P2DirectorModel()
coreModel.addIU(APP_ID)
coreModel.addIU('com.diffplug.jre.feature.group')
coreModel.addIU('com.diffplug.native.feature.group')
// add each of the local repositories
def repoRoot = 'file:' + projectDir + '/' // reads repos from this machine
//def repoRoot = 'http://192.168.1.77/' // reads repos from another machine running hostFiles()
def assembleModel = coreModel.copy()
assembleModel.addRepo(repoRoot + P2_REPO_DIR)
ROOT_FEATURES.forEach() { feature ->
assembleModel.addRepo('file:' + project.file(ROOT_FEATURE_DIR + feature))
}
// assemble DiffPlug for each os
task assembleAll
def ASSEMBLE_TASK = 'assemble'
def assembleDir(OS os) { return project.file('build/10_assemble' + os + (os.isMac() ? ".app" : "")) }
INSTALLERS.each() { os ->
def assembleOneTask = assembleModel.taskFor(project, ASSEMBLE_TASK + os, os, assembleDir(os))
assembleOneTask.dependsOn(diffplugP2)
assembleOneTask.dependsOn(checkRootFeatures)
assembleAll.dependsOn(assembleOneTask)
// make the JRE executable if we can
if (os.isMacOrLinux() && NATIVE_OS.isMacOrLinux()) {
EclipsePlatform platform = EclipsePlatform.fromOS(os)
assembleOneTask.doLast {
def JRE_DIR = project.file(assembleDir(os).absolutePath + '/features/com.diffplug.jre.' + platform + '_' + VER_JRE + '/jre')
CmdLine.runCmd(JRE_DIR, 'chmod -R a+x .')
}
}
}
// test case which creates a DiffPlug from an existing DiffPlug
task reassembleAll
def REASSEMBLE_TASK = 'reassemble'
def reassembleDir(OS os) { return project.file('build/11_reassemble' + os + (os.isMac() ? ".app" : "")) }
INSTALLERS.each() { os ->
def reassembleModel = coreModel.copy()
def reassembleRoot = 'file:' + assembleDir(os)
reassembleModel.addMetadataRepo(reassembleRoot + '/p2/org.eclipse.equinox.p2.engine/profileRegistry/ProfileDiffPlugP2.profile')
reassembleModel.addArtifactRepo(reassembleRoot + '/p2/org.eclipse.equinox.p2.core/cache')
reassembleModel.addArtifactRepo(reassembleRoot)
def reassembleOneTask = reassembleModel.taskFor(project, REASSEMBLE_TASK + os, os, reassembleDir(os))
reassembleOneTask.dependsOn(ASSEMBLE_TASK + os)
reassembleAll.dependsOn(reassembleOneTask)
}
| Constructor and Description |
|---|
P2DirectorModel() |
| Modifier and Type | Method and Description |
|---|---|
void |
addArtifactRepo(String repo) |
void |
addIU(String iu) |
void |
addMetadataRepo(String repo) |
void |
addRepo(String repo) |
P2DirectorModel |
copy()
Returns a deep copy of this model.
|
Task |
taskFor(Project project,
String taskName,
OS os,
Object dstDir)
Creates a task which run P2 Director on the given model.
|
public P2DirectorModel copy()
Returns a deep copy of this model.
public void addIU(String iu)
public void addRepo(String repo)
public void addMetadataRepo(String repo)
public void addArtifactRepo(String repo)