use of org.eclipse.tycho.core.shared.BuildProperties in project tycho by eclipse.
the class PackagePluginMojo method makeJar.
private File makeJar(BuildOutputJar jar) throws MojoExecutionException {
String jarName = jar.getName();
BuildProperties buildProperties = pdeProject.getBuildProperties();
String customManifest = buildProperties.getJarToManifestMap().get(jarName);
try {
File jarFile = new File(project.getBasedir(), jarName);
JarArchiver archiver = new JarArchiver();
archiver.setDestFile(jarFile);
archiver.addDirectory(jar.getOutputDirectory());
if (customManifest != null) {
for (File sourceFolder : jar.getSourceFolders()) {
File manifestFile = new File(sourceFolder, customManifest);
if (manifestFile.isFile()) {
archiver.setManifest(manifestFile);
break;
}
}
}
archiver.createArchive();
return jarFile;
} catch (Exception e) {
throw new MojoExecutionException("Could not create jar " + jarName, e);
}
}
use of org.eclipse.tycho.core.shared.BuildProperties in project tycho by eclipse.
the class PackagePluginMojo method createPluginJar.
private File createPluginJar() throws MojoExecutionException {
try {
MavenArchiver archiver = new MavenArchiver();
archiver.setArchiver(jarArchiver);
File pluginFile = new File(buildDirectory, finalName + ".jar");
if (pluginFile.exists()) {
pluginFile.delete();
}
BuildProperties buildProperties = pdeProject.getBuildProperties();
List<String> binIncludesList = buildProperties.getBinIncludes();
List<String> binExcludesList = buildProperties.getBinExcludes();
// 1. additional filesets should win over bin.includes, so we add them first
if (additionalFileSets != null) {
for (DefaultFileSet fileSet : additionalFileSets) {
if (fileSet.getDirectory() != null && fileSet.getDirectory().isDirectory()) {
archiver.getArchiver().addFileSet(fileSet);
}
}
}
List<String> binIncludesIgnoredForValidation = new ArrayList<>();
// 2. handle dir classpath entries and "."
for (BuildOutputJar outputJar : pdeProject.getOutputJarMap().values()) {
String jarName = outputJar.getName();
if (binIncludesList.contains(jarName) && outputJar.isDirClasspathEntry()) {
binIncludesIgnoredForValidation.add(jarName);
String prefix = ".".equals(jarName) ? "" : jarName;
archiver.getArchiver().addDirectory(outputJar.getOutputDirectory(), prefix);
}
}
// 3. handle nested jars and included resources
checkBinIncludesExist(buildProperties, binIncludesIgnoredForValidation.toArray(new String[0]));
archiver.getArchiver().addFileSet(getFileSet(project.getBasedir(), binIncludesList, binExcludesList));
File manifest = updateManifest();
if (manifest.exists()) {
archive.setManifestFile(manifest);
}
archiver.setOutputFile(pluginFile);
if (!archive.isForced()) {
// optimized archive creation not supported for now because of build qualifier mismatch issues
// see TYCHO-502
getLog().warn("ignoring unsupported archive forced = false parameter.");
archive.setForced(true);
}
archiver.createArchive(session, project, archive);
return pluginFile;
} catch (IOException e) {
throw new MojoExecutionException("Error assembling JAR", e);
} catch (ArchiverException e) {
throw new MojoExecutionException("Error assembling JAR", e);
} catch (ManifestException e) {
throw new MojoExecutionException("Error assembling JAR", e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Error assembling JAR", e);
}
}
use of org.eclipse.tycho.core.shared.BuildProperties in project tycho by eclipse.
the class FeatureRootfileArtifactRepositoryTest method rootPropertiesWithGlobalAndWindowsFiles.
private BuildProperties rootPropertiesWithGlobalAndWindowsFiles() {
Properties buildProperties = new Properties();
buildProperties.put("root.win32.win32.x86", "file:rootfiles/file1.txt");
buildProperties.put("root", "file:rootfiles/file2.txt");
return new BuildPropertiesImpl(buildProperties);
}
use of org.eclipse.tycho.core.shared.BuildProperties in project tycho by eclipse.
the class BuildPropertiesParserImpl method parse.
@Override
public BuildProperties parse(File baseDir) {
File propsFile = new File(baseDir, BUILD_PROPERTIES);
String filePath = propsFile.getAbsolutePath();
BuildProperties buildProperties = cache.get(filePath);
if (buildProperties == null) {
Properties properties = readProperties(propsFile);
interpolate(properties, baseDir);
buildProperties = new BuildPropertiesImpl(properties);
cache.put(filePath, buildProperties);
}
return buildProperties;
}
use of org.eclipse.tycho.core.shared.BuildProperties in project tycho by eclipse.
the class PackageFeatureMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
outputDirectory.mkdirs();
Feature feature = Feature.loadFeature(basedir);
File licenseFeature = licenseFeatureHelper.getLicenseFeature(feature, project);
updateLicenseProperties(feature, licenseFeature);
File featureXml = new File(outputDirectory, Feature.FEATURE_XML);
try {
expandVersionQualifiers(feature);
Feature.write(feature, featureXml);
} catch (IOException e) {
throw new MojoExecutionException("Error updating feature.xml", e);
}
BuildProperties buildProperties = buildPropertiesParser.parse(project.getBasedir());
checkBinIncludesExist(buildProperties);
File featureProperties = getFeatureProperties(licenseFeature, buildProperties);
File outputJar = new File(outputDirectory, finalName + ".jar");
outputJar.getParentFile().mkdirs();
MavenArchiver archiver = new MavenArchiver();
JarArchiver jarArchiver = getJarArchiver();
archiver.setArchiver(jarArchiver);
archiver.setOutputFile(outputJar);
jarArchiver.setDestFile(outputJar);
try {
archiver.getArchiver().addFileSet(getManuallyIncludedFiles(buildProperties));
if (licenseFeature != null) {
archiver.getArchiver().addArchivedFileSet(licenseFeatureHelper.getLicenseFeatureFileSet(licenseFeature));
}
archiver.getArchiver().addFile(featureXml, Feature.FEATURE_XML);
if (featureProperties != null) {
archiver.getArchiver().addFile(featureProperties, FEATURE_PROPERTIES);
}
if (archive == null) {
archive = new MavenArchiveConfiguration();
archive.setAddMavenDescriptor(false);
}
archiver.createArchive(session, project, archive);
} catch (Exception e) {
throw new MojoExecutionException("Error creating feature package", e);
}
project.getArtifact().setFile(outputJar);
if (deployableFeature) {
assembleDeployableFeature();
}
}
Aggregations