Search in sources :

Example 6 with BuildPropertiesImpl

use of org.eclipse.tycho.core.shared.BuildPropertiesImpl 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)

Example 7 with BuildPropertiesImpl

use of org.eclipse.tycho.core.shared.BuildPropertiesImpl 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 8 with BuildPropertiesImpl

use of org.eclipse.tycho.core.shared.BuildPropertiesImpl 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 9 with BuildPropertiesImpl

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

the class IncludeValidationHelperTest method createBuildProperties.

private BuildPropertiesImpl createBuildProperties(String key, String value) {
    Properties properties = new Properties();
    properties.setProperty(key, value);
    BuildPropertiesImpl buildProperties = new BuildPropertiesImpl(properties);
    return buildProperties;
}
Also used : Properties(java.util.Properties) BuildPropertiesImpl(org.eclipse.tycho.core.shared.BuildPropertiesImpl)

Example 10 with BuildPropertiesImpl

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

the class IncludeValidationHelperTest method testCheckBinIncludesNotSpecified.

@Test
public void testCheckBinIncludesNotSpecified() throws Exception {
    BuildPropertiesImpl buildProperties = createBuildProperties("no.bin.includes", "bin.includes is not specified");
    try {
        subject.checkBinIncludesExist(createMockProject(), buildProperties, true);
        fail();
    } catch (MojoExecutionException e) {
        assertStringContains("bin.includes value(s) must be specified", e.getMessage());
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) BuildPropertiesImpl(org.eclipse.tycho.core.shared.BuildPropertiesImpl) Test(org.junit.Test)

Aggregations

BuildPropertiesImpl (org.eclipse.tycho.core.shared.BuildPropertiesImpl)12 Test (org.junit.Test)7 Properties (java.util.Properties)5 BuildProperties (org.eclipse.tycho.core.shared.BuildProperties)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 File (java.io.File)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ZipEntry (java.util.zip.ZipEntry)1 ZipFile (java.util.zip.ZipFile)1 MavenProject (org.apache.maven.project.MavenProject)1 DefaultArchivedFileSet (org.codehaus.plexus.archiver.util.DefaultArchivedFileSet)1 AbstractLogger (org.codehaus.plexus.logging.AbstractLogger)1 Logger (org.codehaus.plexus.logging.Logger)1