| 155 | } |
| 156 | |
| 157 | @TaskAction |
| 158 | public void build() throws Exception { |
| 159 | Objects.requireNonNull(destination, "destination must not be null!"); |
| 160 | Objects.requireNonNull(base, "base must not be null!"); |
| 161 | |
| 162 | // delete the buildDir and make a fresh directory |
| 163 | File destination = getProject().file(this.destination); |
| 164 | FileMisc.cleanDir(destination); |
| 165 | |
| 166 | File base = getProject().file(this.base); |
| 167 | |
| 168 | // setup build.properties |
| 169 | PdeBuildProperties properties = new PdeBuildProperties(); |
| 170 | properties.setBasePlatform(SwtPlatform.getRunning()); |
| 171 | properties.setBuildDirectory(destination); |
| 172 | properties.setProp("base", base.getAbsolutePath()); |
| 173 | properties.setConfigs(platforms); // for all configs |
| 174 | properties.setJDK(config); |
| 175 | |
| 176 | List<File> pluginPaths = FileMisc.parseListFile(getProject(), pluginPath); |
| 177 | properties.setPluginPaths(pluginPaths); |
| 178 | |
| 179 | // now that we've set the base values, give the product part a wack at it (if there is one) |
| 180 | if (productConfig != null) { |
| 181 | PdeProductBuildConfig product = new PdeProductBuildConfig(getProject()); |
| 182 | productConfig.execute(product); |
| 183 | List<File> roots = new ArrayList<>(); |
| 184 | roots.addAll(pluginPaths); |
| 185 | product.setup(destination, properties, platforms, roots); |
| 186 | } |
| 187 | |
| 188 | // set all the properties we'd like to set |
| 189 | for (Map.Entry<String, String> entry : buildProperties.entrySet()) { |
| 190 | properties.setProp(entry.getKey(), entry.getValue()); |
| 191 | } |
| 192 | // write build.properties to the appropriate directory |
| 193 | File buildDirProperties = new File(destination, "build.properties"); |
| 194 | Files.write(properties.getContent(), buildDirProperties, StandardCharsets.UTF_8); |
| 195 | |
| 196 | // generate and execute the PDE build command |
| 197 | PdeInstallation installation = PdeInstallation.fromProject(getProject()); |
| 198 | EclipseApp app = installation.productBuildCmd(destination); |
| 199 | appModifier.execute(app); |
| 200 | app.runUsing(installation); |
| 201 | } |
| 202 | } |