Search in sources :

Example 6 with BuildProperties

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);
    }
}
Also used : BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) File(java.io.File) JarArchiver(org.codehaus.plexus.archiver.jar.JarArchiver) ManifestException(org.codehaus.plexus.archiver.jar.ManifestException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException)

Example 7 with BuildProperties

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);
    }
}
Also used : DefaultFileSet(org.codehaus.plexus.archiver.util.DefaultFileSet) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) ArrayList(java.util.ArrayList) MavenArchiver(org.apache.maven.archiver.MavenArchiver) IOException(java.io.IOException) ManifestException(org.codehaus.plexus.archiver.jar.ManifestException) BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) BuildOutputJar(org.eclipse.tycho.core.osgitools.project.BuildOutputJar) File(java.io.File)

Example 8 with BuildProperties

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);
}
Also used : Properties(java.util.Properties) BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) BuildPropertiesImpl(org.eclipse.tycho.core.shared.BuildPropertiesImpl)

Example 9 with 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;
}
Also used : BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) Properties(java.util.Properties) BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) File(java.io.File) BuildPropertiesImpl(org.eclipse.tycho.core.shared.BuildPropertiesImpl)

Example 10 with 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();
    }
}
Also used : BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MavenArchiver(org.apache.maven.archiver.MavenArchiver) IOException(java.io.IOException) MavenArchiveConfiguration(org.apache.maven.archiver.MavenArchiveConfiguration) Feature(org.eclipse.tycho.model.Feature) ZipFile(java.util.zip.ZipFile) File(java.io.File) JarArchiver(org.codehaus.plexus.archiver.jar.JarArchiver) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Aggregations

BuildProperties (org.eclipse.tycho.core.shared.BuildProperties)10 File (java.io.File)4 Properties (java.util.Properties)4 BuildPropertiesImpl (org.eclipse.tycho.core.shared.BuildPropertiesImpl)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 ZipFile (java.util.zip.ZipFile)2 MavenArchiver (org.apache.maven.archiver.MavenArchiver)2 DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)2 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)2 JarArchiver (org.codehaus.plexus.archiver.jar.JarArchiver)2 ManifestException (org.codehaus.plexus.archiver.jar.ManifestException)2 DefaultFileSet (org.codehaus.plexus.archiver.util.DefaultFileSet)2 InputStream (java.io.InputStream)1 HashSet (java.util.HashSet)1 List (java.util.List)1 ZipEntry (java.util.zip.ZipEntry)1 MavenArchiveConfiguration (org.apache.maven.archiver.MavenArchiveConfiguration)1 Plugin (org.apache.maven.model.Plugin)1