Search in sources :

Example 1 with BuildProperties

use of org.eclipse.tycho.core.shared.BuildProperties in project tycho by eclipse.

the class BuildPropertiesParserForTesting method parse.

@Override
public BuildProperties parse(File baseDir) {
    Properties props = new Properties();
    readBuildProperties(baseDir, props);
    return new BuildPropertiesImpl(props);
}
Also used : BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) Properties(java.util.Properties) BuildPropertiesImpl(org.eclipse.tycho.core.shared.BuildPropertiesImpl)

Example 2 with BuildProperties

use of org.eclipse.tycho.core.shared.BuildProperties in project tycho by eclipse.

the class OsgiSourceMojo method isRelevantProjectImpl.

protected static boolean isRelevantProjectImpl(MavenProject project, BuildPropertiesParser buildPropertiesParser) {
    String packaging = project.getPackaging();
    boolean relevant = PackagingType.TYPE_ECLIPSE_PLUGIN.equals(packaging) || PackagingType.TYPE_ECLIPSE_TEST_PLUGIN.equals(packaging);
    if (!relevant) {
        return false;
    }
    // this assumes that sources generation has to be explicitly enabled in pom.xml
    Plugin plugin = project.getPlugin("org.eclipse.tycho:tycho-source-plugin");
    if (plugin == null) {
        return false;
    }
    for (PluginExecution execution : plugin.getExecutions()) {
        if (execution.getGoals().contains(GOAL)) {
            boolean requireSourceRoots = Boolean.parseBoolean(getParameterValue(execution, "requireSourceRoots", "false"));
            if (requireSourceRoots) {
                return true;
            }
            boolean hasAdditionalFilesets = getConfigurationElement((Xpp3Dom) execution.getConfiguration(), "additionalFileSets") != null;
            if (hasAdditionalFilesets) {
                return true;
            }
            BuildProperties buildProperties = buildPropertiesParser.parse(project.getBasedir());
            if (buildProperties.getJarToSourceFolderMap().size() > 0 || buildProperties.getSourceIncludes().size() > 0) {
                return true;
            }
        }
    }
    return false;
}
Also used : PluginExecution(org.apache.maven.model.PluginExecution) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) Plugin(org.apache.maven.model.Plugin)

Example 3 with BuildProperties

use of org.eclipse.tycho.core.shared.BuildProperties in project tycho by eclipse.

the class OsgiSourceMojo method getResources.

/**
 * {@inheritDoc}
 */
@Override
protected List<Resource> getResources(MavenProject p) throws MojoExecutionException {
    if (excludeResources) {
        return Collections.emptyList();
    }
    BuildProperties buildProperties = buildPropertiesParser.parse(p.getBasedir());
    List<String> srcIncludesList = buildProperties.getSourceIncludes();
    List<Resource> resources = new ArrayList<>();
    if (!srcIncludesList.isEmpty()) {
        includeValidationHelper.checkSourceIncludesExist(p, buildProperties, strictSrcIncludes);
        resources.add(createResource(project.getBasedir().getAbsolutePath(), srcIncludesList, buildProperties.getSourceExcludes()));
    }
    if (additionalFileSets != null) {
        for (DefaultFileSet fileSet : additionalFileSets) {
            if (fileSet.getIncludes() != null && fileSet.getIncludes().length > 0) {
                resources.add(createResource(fileSet.getDirectory().getAbsolutePath(), asList(fileSet.getIncludes()), asList(fileSet.getExcludes())));
            }
        }
    }
    if (!srcIncludesList.contains(MANIFEST_BUNDLE_LOCALIZATION_FILENAME)) {
        resources.add(generateL10nFile());
    }
    return resources;
}
Also used : DefaultFileSet(org.codehaus.plexus.archiver.util.DefaultFileSet) BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) Resource(org.apache.maven.model.Resource) ArrayList(java.util.ArrayList)

Example 4 with BuildProperties

use of org.eclipse.tycho.core.shared.BuildProperties in project tycho by eclipse.

the class AbstractMetadataGenerator method extractExtraEntriesAsIURequirement.

private IRequirement[] extractExtraEntriesAsIURequirement(File location) {
    BuildProperties buildProps = buildPropertiesParser.parse(location);
    ArrayList<IRequirement> result = new ArrayList<>();
    for (Entry<String, List<String>> entry : buildProps.getJarToExtraClasspathMap().entrySet()) {
        createRequirementFromExtraClasspathProperty(result, entry.getValue());
    }
    createRequirementFromExtraClasspathProperty(result, buildProps.getJarsExtraClasspath());
    if (result.isEmpty())
        return null;
    return result.toArray(new IRequirement[result.size()]);
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with BuildProperties

use of org.eclipse.tycho.core.shared.BuildProperties in project tycho by eclipse.

the class LicenseFeatureHelper method getLicenseFeatureFileSet.

/**
 * Get all files included in license feature jar (via build.properties
 * bin.includes/bin.excludes) exept for feature.xml, feature.properties and build.properties as
 * an archived fileset so they can be added to another feature jar.
 *
 * @param licenseFeature
 *            license feature jar
 */
public ArchivedFileSet getLicenseFeatureFileSet(File licenseFeature) throws IOException {
    // copy all files from license feature's build.properties file except
    // feature.properties, feature.xml and build.properties itself
    BuildProperties buildProperties;
    ZipFile zip = new ZipFile(licenseFeature);
    try {
        ZipEntry entry = zip.getEntry(BuildPropertiesParser.BUILD_PROPERTIES);
        if (entry != null) {
            InputStream is = zip.getInputStream(entry);
            Properties p = new Properties();
            p.load(is);
            buildProperties = new BuildPropertiesImpl(p);
        } else {
            throw new IllegalArgumentException("license feature must include build.properties file");
        }
    } finally {
        zip.close();
    }
    List<String> includes = buildProperties.getBinIncludes();
    Set<String> excludes = new HashSet<>(buildProperties.getBinExcludes());
    excludes.add(Feature.FEATURE_XML);
    excludes.add("feature.properties");
    excludes.add(BuildPropertiesParser.BUILD_PROPERTIES);
    // mavenArchiver ignores license feature files that are also present in 'this' feature
    // i.e. if there is a conflict, files from 'this' feature win
    DefaultArchivedFileSet result = new DefaultArchivedFileSet(licenseFeature);
    result.setIncludes(includes.toArray(new String[includes.size()]));
    result.setExcludes(excludes.toArray(new String[excludes.size()]));
    return result;
}
Also used : BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) ZipFile(java.util.zip.ZipFile) DefaultArchivedFileSet(org.codehaus.plexus.archiver.util.DefaultArchivedFileSet) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) Properties(java.util.Properties) BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) BuildPropertiesImpl(org.eclipse.tycho.core.shared.BuildPropertiesImpl) HashSet(java.util.HashSet)

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