diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoResolver.java index 8decc5730f..92416da4dc 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoResolver.java @@ -12,9 +12,6 @@ *******************************************************************************/ package org.eclipse.tycho.core.resolver; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -70,7 +67,6 @@ public class DefaultTychoResolver implements TychoResolver { public static final String TYCHO_ENV_OSGI_WS = "tycho.env.osgi.ws"; public static final String TYCHO_ENV_OSGI_OS = "tycho.env.osgi.os"; public static final String TYCHO_ENV_OSGI_ARCH = "tycho.env.osgi.arch"; - public static final String PROPERTY_PREFIX = "pom.model.property."; @Override public void setupProject(MavenSession session, MavenProject project, ReactorProject reactorProject) { @@ -97,7 +93,6 @@ public void setupProject(MavenSession session, MavenProject project, ReactorProj reactorProject.setContextValue(TychoConstants.CTX_MERGED_PROPERTIES, properties); setTychoEnvironmentProperties(properties, project); - setBuildProperties(project); TargetPlatformConfiguration configuration = configurationReader.getTargetPlatformConfiguration(session, project); @@ -195,29 +190,4 @@ protected void setTychoEnvironmentProperties(Properties properties, MavenProject project.getProperties().put(TYCHO_ENV_OSGI_OS, os); project.getProperties().put(TYCHO_ENV_OSGI_ARCH, arch); } - - protected void setBuildProperties(MavenProject project) { - File pomfile = project.getFile(); - if (pomfile != null) { - File buildPropertiesFile = new File(pomfile.getParentFile(), "build.properties"); - if (buildPropertiesFile.isFile() && buildPropertiesFile.length() > 0) { - Properties buildProperties = new Properties(); - try { - try (FileInputStream stream = new FileInputStream(buildPropertiesFile)) { - buildProperties.load(stream); - } - Properties projectProperties = project.getProperties(); - buildProperties.stringPropertyNames().forEach(key -> { - if (key.startsWith(PROPERTY_PREFIX)) { - projectProperties.setProperty(key.substring(PROPERTY_PREFIX.length()), - buildProperties.getProperty(key)); - } - }); - } catch (IOException e) { - logger.warn("reading build.properties from project " + project.getName() + " failed", e); - } - } - } - } - } diff --git a/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java index a4573748d0..8d89a10e65 100644 --- a/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java +++ b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/AbstractTychoMapping.java @@ -280,17 +280,20 @@ public Properties getEnhancementProperties(Map options) { String location = PolyglotModelUtil.getLocation(options); File file = new File(location); try { - if (file.isDirectory()) { - return getBuildProperties(file); - } else if (file.isFile()) { - return getBuildProperties(file.getParentFile()); - } + return getEnhancementProperties(file); } catch (IOException e) { logger.warn("reading EnhancementProperties encountered a problem and was skipped for this reason", e); } return null; } + protected Properties getEnhancementProperties(File file) throws IOException { + if (file.isDirectory()) { + return getBuildProperties(file); + } + return getBuildProperties(file.getParentFile()); + } + private static void setLocation(Model model, File modelSource) { InputSource inputSource = new InputSource(); inputSource.setLocation(modelSource.toString()); diff --git a/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoBundleMapping.java b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoBundleMapping.java index 1dc232c779..50db6f3395 100644 --- a/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoBundleMapping.java +++ b/tycho-extras/tycho-pomless/src/main/java/org/eclipse/tycho/pomless/TychoBundleMapping.java @@ -113,6 +113,12 @@ protected void initModel(Model model, Reader artifactReader, File artifactFile) } + @Override + protected Properties getEnhancementProperties(File file) throws IOException { + //Look up build.properties in the project's root. The passed file points to the 'META-INF' folder. + return getBuildProperties(file.getParentFile()); + } + private static Plugin createBndPlugin(Model model) { //See https://github.com/bndtools/bnd/blob/master/maven/bnd-maven-plugin/README.md#bnd-process-goal Build build = model.getBuild(); diff --git a/tycho-its/projects/pomless-model/.mvn/extensions.xml b/tycho-its/projects/pomless-model/.mvn/extensions.xml new file mode 100644 index 0000000000..79a6c51e8d --- /dev/null +++ b/tycho-its/projects/pomless-model/.mvn/extensions.xml @@ -0,0 +1,7 @@ + + + org.eclipse.tycho + tycho-build + ${tycho-version} + + diff --git a/tycho-its/projects/pomless-model/.mvn/maven.config b/tycho-its/projects/pomless-model/.mvn/maven.config new file mode 100644 index 0000000000..afbb3f6238 --- /dev/null +++ b/tycho-its/projects/pomless-model/.mvn/maven.config @@ -0,0 +1,2 @@ +-Dtycho-version=3.0.0-SNAPSHOT +-Dtycho.pomless.aggregator.names=bundles,bundles-with-enhanced-parents diff --git a/tycho-its/projects/pomless-model/alternative-parent/pom.xml b/tycho-its/projects/pomless-model/alternative-parent/pom.xml new file mode 100644 index 0000000000..4c27d13c7f --- /dev/null +++ b/tycho-its/projects/pomless-model/alternative-parent/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + foo.bar + simple + 1.0.0 + + foo.other + another-parent + pom + Alternative Parent 2 from pomXML + + alternative-parent-from-pomXML + + diff --git a/tycho-its/projects/pomless-model/bundles-2/foo.bar.bundle-5/META-INF/MANIFEST.MF b/tycho-its/projects/pomless-model/bundles-2/foo.bar.bundle-5/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..66a5bbaac9 --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles-2/foo.bar.bundle-5/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plugin +Bundle-SymbolicName: foo.bar.bundle-5 +Bundle-Version: 1.0.0 +Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/tycho-its/projects/pomless-model/bundles-2/foo.bar.bundle-5/build.properties b/tycho-its/projects/pomless-model/bundles-2/foo.bar.bundle-5/build.properties new file mode 100644 index 0000000000..f81ccb523d --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles-2/foo.bar.bundle-5/build.properties @@ -0,0 +1,3 @@ +bin.includes = META-INF/ +pom.model.name = Bundle 5 pomless +# Inherit pom.model.property.custom.user.property from parent diff --git a/tycho-its/projects/pomless-model/bundles-2/pom.xml b/tycho-its/projects/pomless-model/bundles-2/pom.xml new file mode 100644 index 0000000000..4a2cf6e57c --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles-2/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + + foo.bar + simple + 1.0.0 + + bundles-2 + 1.1.0 + pom + Aggregator 2 from pomXML + + aggregator2-from-pomXML + + + foo.bar.bundle-5 + + diff --git a/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/build.properties b/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/build.properties new file mode 100644 index 0000000000..d340b64f23 --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/build.properties @@ -0,0 +1,4 @@ +pom.model.groupId = bundles-enhanced-pomless +pom.model.version = 1.2.0 +pom.model.name = Aggregator 3 pomless +pom.model.property.custom.user.property = aggregator3-pomless diff --git a/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-3/META-INF/MANIFEST.MF b/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-3/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..9fda384725 --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-3/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plugin +Bundle-SymbolicName: foo.bar.bundle-3 +Bundle-Version: 1.0.0 +Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-3/build.properties b/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-3/build.properties new file mode 100644 index 0000000000..16646775da --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-3/build.properties @@ -0,0 +1,4 @@ +bin.includes = META-INF/ +tycho.pomless.parent = ../../alternative-parent +pom.model.name = Bundle 3 pomless +# Inherit pom.model.property.custom.user.property from parent diff --git a/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-4/META-INF/MANIFEST.MF b/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-4/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..34c1d0b7e9 --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-4/META-INF/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plugin +Bundle-SymbolicName: foo.bar.bundle-4 +Bundle-Version: 1.0.0 +Automatic-Module-Name: foo.bar.plugin +Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-4/build.properties b/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-4/build.properties new file mode 100644 index 0000000000..a1e5f83923 --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles-with-enhanced-parents/foo.bar.bundle-4/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . +pom.model.name = Bundle 4 pomless +# Inherit pom.model.property.custom.user.property from parent diff --git a/tycho-its/projects/pomless-model/bundles/foo.bar.bundle-2/META-INF/MANIFEST.MF b/tycho-its/projects/pomless-model/bundles/foo.bar.bundle-2/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..8b3f619ce5 --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles/foo.bar.bundle-2/META-INF/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plugin +Bundle-SymbolicName: foo.bar.bundle-2 +Bundle-Version: 1.0.0 +Automatic-Module-Name: foo.bar.plugin +Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/tycho-its/projects/pomless-model/bundles/foo.bar.bundle-2/build.properties b/tycho-its/projects/pomless-model/bundles/foo.bar.bundle-2/build.properties new file mode 100644 index 0000000000..7c12bca990 --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles/foo.bar.bundle-2/build.properties @@ -0,0 +1,4 @@ +bin.includes = META-INF/ +tycho.pomless.parent = ../../alternative-parent +pom.model.name = Bundle 2 pomless +pom.model.property.custom.user.property = bundle2-pomless diff --git a/tycho-its/projects/pomless-model/bundles/foo.bar.bundle-2/pom.xml b/tycho-its/projects/pomless-model/bundles/foo.bar.bundle-2/pom.xml new file mode 100644 index 0000000000..6ac3236877 --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles/foo.bar.bundle-2/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + foo.bar + simple + 1.0.0 + ../.. + + foo.bar.bundle-2 + eclipse-plugin + Bundle 2 from pom.xml + + bundle2-from-pomXML + + diff --git a/tycho-its/projects/pomless-model/bundles/foo.bar.bundle/META-INF/MANIFEST.MF b/tycho-its/projects/pomless-model/bundles/foo.bar.bundle/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..cf1c428027 --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles/foo.bar.bundle/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plugin +Bundle-SymbolicName: foo.bar.bundle +Bundle-Version: 1.0.0 +Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/tycho-its/projects/pomless-model/bundles/foo.bar.bundle/build.properties b/tycho-its/projects/pomless-model/bundles/foo.bar.bundle/build.properties new file mode 100644 index 0000000000..bb3429e5ac --- /dev/null +++ b/tycho-its/projects/pomless-model/bundles/foo.bar.bundle/build.properties @@ -0,0 +1,3 @@ +bin.includes = META-INF/ +pom.model.name = Bundle 1 pomless +pom.model.property.custom.user.property = bundle1-pomless diff --git a/tycho-its/projects/pomless-model/foo.bar.feature-2/build.properties b/tycho-its/projects/pomless-model/foo.bar.feature-2/build.properties new file mode 100644 index 0000000000..9cd054b702 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.feature-2/build.properties @@ -0,0 +1,3 @@ +bin.includes = feature.xml +pom.model.name = Feature 2 pomless +pom.model.property.custom.user.property = feature2-pomless diff --git a/tycho-its/projects/pomless-model/foo.bar.feature-2/feature.xml b/tycho-its/projects/pomless-model/foo.bar.feature-2/feature.xml new file mode 100644 index 0000000000..dd1bb07584 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.feature-2/feature.xml @@ -0,0 +1,27 @@ + + + + + [Enter Feature Description here.] + + + + [Enter Copyright Description here.] + + + + [Enter License Description here.] + + + + + diff --git a/tycho-its/projects/pomless-model/foo.bar.feature-2/pom.xml b/tycho-its/projects/pomless-model/foo.bar.feature-2/pom.xml new file mode 100644 index 0000000000..94e2a714f3 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.feature-2/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + foo.bar + simple + 1.0.0 + + foo.bar.feature-2 + eclipse-feature + Feature 2 from pom.xml + + feature2-from-pomXML + + diff --git a/tycho-its/projects/pomless-model/foo.bar.feature/build.properties b/tycho-its/projects/pomless-model/foo.bar.feature/build.properties new file mode 100644 index 0000000000..ff0ab0bf69 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.feature/build.properties @@ -0,0 +1,3 @@ +bin.includes = feature.xml +pom.model.name = Feature 1 pomless +pom.model.property.custom.user.property = feature1-pomless diff --git a/tycho-its/projects/pomless-model/foo.bar.feature/feature.xml b/tycho-its/projects/pomless-model/foo.bar.feature/feature.xml new file mode 100644 index 0000000000..9d1d538337 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.feature/feature.xml @@ -0,0 +1,27 @@ + + + + + [Enter Feature Description here.] + + + + [Enter Copyright Description here.] + + + + [Enter License Description here.] + + + + + diff --git a/tycho-its/projects/pomless-model/foo.bar.plugin-2/META-INF/MANIFEST.MF b/tycho-its/projects/pomless-model/foo.bar.plugin-2/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..e756fd3916 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.plugin-2/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plugin +Bundle-SymbolicName: foo.bar.plugin-2 +Bundle-Version: 1.0.0 +Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/tycho-its/projects/pomless-model/foo.bar.plugin-2/build.properties b/tycho-its/projects/pomless-model/foo.bar.plugin-2/build.properties new file mode 100644 index 0000000000..c4bb19b482 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.plugin-2/build.properties @@ -0,0 +1,3 @@ +bin.includes = META-INF/ +pom.model.name = Plugin 2 pomless +pom.model.property.custom.user.property = plugin2-pomless diff --git a/tycho-its/projects/pomless-model/foo.bar.plugin-2/pom.xml b/tycho-its/projects/pomless-model/foo.bar.plugin-2/pom.xml new file mode 100644 index 0000000000..a1827a2af4 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.plugin-2/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + foo.bar + simple + 1.0.0 + + foo.bar.plugin-2 + eclipse-plugin + Plugin 2 from pom.xml + + plugin2-from-pomXML + + diff --git a/tycho-its/projects/pomless-model/foo.bar.plugin/META-INF/MANIFEST.MF b/tycho-its/projects/pomless-model/foo.bar.plugin/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..dbbb561c31 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.plugin/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plugin +Bundle-SymbolicName: foo.bar.plugin +Bundle-Version: 1.0.0 +Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/tycho-its/projects/pomless-model/foo.bar.plugin/build.properties b/tycho-its/projects/pomless-model/foo.bar.plugin/build.properties new file mode 100644 index 0000000000..89911ec3e6 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.plugin/build.properties @@ -0,0 +1,3 @@ +bin.includes = META-INF/ +pom.model.name = Plugin 1 pomless +pom.model.property.custom.user.property = plugin1-pomless diff --git a/tycho-its/projects/pomless-model/foo.bar.product-2/build.properties b/tycho-its/projects/pomless-model/foo.bar.product-2/build.properties new file mode 100644 index 0000000000..31072dc975 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.product-2/build.properties @@ -0,0 +1,2 @@ +pom.model.name = Product 2 pomless +pom.model.property.custom.user.property = product2-pomless diff --git a/tycho-its/projects/pomless-model/foo.bar.product-2/foo.bar.product b/tycho-its/projects/pomless-model/foo.bar.product-2/foo.bar.product new file mode 100644 index 0000000000..fbce3f440c --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.product-2/foo.bar.product @@ -0,0 +1,19 @@ + + + + + + + + + + -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + + + + + diff --git a/tycho-its/projects/pomless-model/foo.bar.product-2/pom.xml b/tycho-its/projects/pomless-model/foo.bar.product-2/pom.xml new file mode 100644 index 0000000000..15d861ecb8 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.product-2/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + + foo.bar + simple + 1.0.0 + + foo.bar.product-2 + eclipse-repository + Product 2 from pom.xml + + product2-from-pomXML + + + + + org.eclipse.tycho + tycho-p2-director-plugin + + + materialize-products + + materialize-products + + + + + foo.bar.product-2 + + + + + + archive-products + + archive-products + + + + + foo.bar.product-2 + + + + + + + + + diff --git a/tycho-its/projects/pomless-model/foo.bar.product/build.properties b/tycho-its/projects/pomless-model/foo.bar.product/build.properties new file mode 100644 index 0000000000..fd1e0b25ec --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.product/build.properties @@ -0,0 +1,2 @@ +pom.model.name = Product 1 pomless +pom.model.property.custom.user.property = product1-pomless diff --git a/tycho-its/projects/pomless-model/foo.bar.product/foo.bar.product b/tycho-its/projects/pomless-model/foo.bar.product/foo.bar.product new file mode 100644 index 0000000000..544fb06bc0 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.product/foo.bar.product @@ -0,0 +1,19 @@ + + + + + + + + + + -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + + + + + diff --git a/tycho-its/projects/pomless-model/foo.bar.target-2/build.properties b/tycho-its/projects/pomless-model/foo.bar.target-2/build.properties new file mode 100644 index 0000000000..18ff024dde --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.target-2/build.properties @@ -0,0 +1,2 @@ +pom.model.name = Target 2 pomless +pom.model.property.custom.user.property = target2-pomless diff --git a/tycho-its/projects/pomless-model/foo.bar.target-2/foo.bar.target b/tycho-its/projects/pomless-model/foo.bar.target-2/foo.bar.target new file mode 100644 index 0000000000..5f6b39eae3 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.target-2/foo.bar.target @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tycho-its/projects/pomless-model/foo.bar.target-2/pom.xml b/tycho-its/projects/pomless-model/foo.bar.target-2/pom.xml new file mode 100644 index 0000000000..aefe7615fc --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.target-2/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + foo.bar + simple + 1.0.0 + + foo.bar.target-2 + eclipse-target-definition + Target 2 from pom.xml + + target2-from-pomXML + + diff --git a/tycho-its/projects/pomless-model/foo.bar.target/build.properties b/tycho-its/projects/pomless-model/foo.bar.target/build.properties new file mode 100644 index 0000000000..63f78b04cd --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.target/build.properties @@ -0,0 +1,2 @@ +pom.model.name = Target 1 pomless +pom.model.property.custom.user.property = target1-pomless diff --git a/tycho-its/projects/pomless-model/foo.bar.target/foo.bar.target b/tycho-its/projects/pomless-model/foo.bar.target/foo.bar.target new file mode 100644 index 0000000000..9f75b1c4b4 --- /dev/null +++ b/tycho-its/projects/pomless-model/foo.bar.target/foo.bar.target @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tycho-its/projects/pomless-model/pom.xml b/tycho-its/projects/pomless-model/pom.xml new file mode 100644 index 0000000000..9ff4008622 --- /dev/null +++ b/tycho-its/projects/pomless-model/pom.xml @@ -0,0 +1,121 @@ + + + 4.0.0 + + foo.bar + simple + 1.0.0 + + pom + + + ${tycho-version} + UTF-8 + the-default-value + + + + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho.version} + true + + + org.eclipse.tycho + target-platform-configuration + ${tycho.version} + + + + foo.bar + foo.bar + 1.0.0 + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 3.1.0 + + + display-project-pom-model-attributes + + run + + generate-sources + + + + + + + + + + + + + + + + org.eclipse.tycho + tycho-p2-director-plugin + ${tycho.version} + + + materialize-products + + materialize-products + + none + + + archive-products + + archive-products + + none + + + default-assemble-repository + + assemble-repository + + none + + + default-archive-repository + + archive-repository + + none + + + + + + + + foo.bar.target + foo.bar.target-2 + + bundles + bundles-2 + bundles-with-enhanced-parents + + foo.bar.plugin + foo.bar.plugin-2 + foo.bar.feature + foo.bar.feature-2 + foo.bar.product + foo.bar.product-2 + + \ No newline at end of file diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/buildextension/PomlessTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/buildextension/PomlessTest.java index 3606b86dea..0c0b2eecc8 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/buildextension/PomlessTest.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/buildextension/PomlessTest.java @@ -1,9 +1,19 @@ package org.eclipse.tycho.test.buildextension; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.aMapWithSize; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Properties; import org.apache.maven.it.Verifier; import org.eclipse.tycho.test.AbstractTychoIntegrationTest; @@ -21,4 +31,116 @@ public void testBnd() throws Exception { File file = new File(verifier.getBasedir(), "bnd/target/classes/module-info.class"); assertTrue("module-info.class is not generated!", file.isFile()); } + + @Test + public void testPomlessModel() throws Exception { + // This methods tests: + // - build.properties (pom.model attributes and properties) are read for: + // -> Plug-ins, Features, Products(Repos), Targets, Aggregators + // - tycho.pomless.parent is considered + // - explicit pom.xml is always preferred + + Verifier verifier = getVerifier("pomless-model", false, true); + verifier.executeGoals(List.of("clean", "package")); + verifier.verifyErrorFreeLog(); + + Map projectData = extractPomModelProperties(Path.of(verifier.getBasedir())); + + assertProjectData("bundles/foo.bar.bundle", projectData, // + "foo.bar:foo.bar.bundle:1.0.0:eclipse-plugin", "Bundle 1 pomless", "bundle1-pomless"); + assertProjectData("bundles/foo.bar.bundle-2", projectData, // + "foo.bar:foo.bar.bundle-2:1.0.0:eclipse-plugin", "Bundle 2 from pom.xml", "bundle2-from-pomXML"); + + assertProjectData("bundles-2/foo.bar.bundle-5", projectData, // + "foo.bar:foo.bar.bundle-5:1.0.0:eclipse-plugin", "Bundle 5 pomless", "aggregator2-from-pomXML"); + + assertProjectData("bundles-with-enhanced-parents/foo.bar.bundle-3", projectData, // + "foo.other:foo.bar.bundle-3:1.0.0:eclipse-plugin", "Bundle 3 pomless", + "alternative-parent-from-pomXML"); + assertProjectData("bundles-with-enhanced-parents/foo.bar.bundle-4", projectData, // + "bundles-enhanced-pomless:foo.bar.bundle-4:1.0.0:eclipse-plugin", "Bundle 4 pomless", + "aggregator3-pomless"); + + assertProjectData("foo.bar.plugin", projectData, // + "foo.bar:foo.bar.plugin:1.0.0:eclipse-plugin", "Plugin 1 pomless", "plugin1-pomless"); + assertProjectData("foo.bar.plugin-2", projectData, // + "foo.bar:foo.bar.plugin-2:1.0.0:eclipse-plugin", "Plugin 2 from pom.xml", "plugin2-from-pomXML"); + + assertProjectData("foo.bar.feature", projectData, // + "foo.bar:foo.bar.feature:1.0.0:eclipse-feature", "Feature 1 pomless", "feature1-pomless"); + assertProjectData("foo.bar.feature-2", projectData, // + "foo.bar:foo.bar.feature-2:1.0.0:eclipse-feature", "Feature 2 from pom.xml", "feature2-from-pomXML"); + + assertProjectData("foo.bar.target", projectData, // + "foo.bar:foo.bar:1.0.0:eclipse-target-definition", "Target 1 pomless", "target1-pomless"); + assertProjectData("foo.bar.target-2", projectData, // + "foo.bar:foo.bar.target-2:1.0.0:eclipse-target-definition", "Target 2 from pom.xml", + "target2-from-pomXML"); + + assertProjectData("foo.bar.product", projectData, // + "foo.bar:foo.bar.product:1.0.0:eclipse-repository", "Product 1 pomless", "product1-pomless"); + assertProjectData("foo.bar.product-2", projectData, // + "foo.bar:foo.bar.product-2:1.0.0:eclipse-repository", "Product 2 from pom.xml", "product2-from-pomXML"); + + assertProjectData(".", projectData, // + "foo.bar:simple:1.0.0:pom", "simple", "the-default-value"); + assertProjectData("bundles", projectData, // + "foo.bar:bundles:1.0.0:pom", "[aggregator] bundles", "the-default-value"); + assertProjectData("bundles-2", projectData, // + "foo.bar:bundles-2:1.1.0:pom", "Aggregator 2 from pomXML", "aggregator2-from-pomXML"); + assertProjectData("bundles-with-enhanced-parents", projectData, // + "bundles-enhanced-pomless:bundles-with-enhanced-parents:1.2.0:pom", "Aggregator 3 pomless", + "aggregator3-pomless"); + + assertThat(projectData, is(aMapWithSize(0))); // Ensure no more projects are found + } + + private static Map extractPomModelProperties(Path buildRootDir) throws IOException { + Map projectData = new HashMap<>(); + try (var paths = Files.walk(buildRootDir).filter(Files::isRegularFile)) { + var files = paths.filter(p -> "pommodel.data".equals(p.getFileName().toString())); + for (Path file : (Iterable) files::iterator) { + ModelData data = ModelData.extract(file, buildRootDir); + projectData.put(data.path, data); + } + } + return projectData; + } + + private static void assertProjectData(String path, Map projectData, String expectedGAV, + String expectedName, String expectedProperty) { + ModelData data = projectData.remove(Path.of(path)); + assertEquals(expectedGAV, data.gav); + assertEquals(expectedName, data.name); + assertEquals(expectedProperty, data.propertyValue); + } + + private static final class ModelData { + + static ModelData extract(Path file, Path basedir) throws IOException { + assertTrue(file.endsWith(Path.of("target", "pommodel.data"))); + Path relativePath = basedir.relativize(file).getParent().getParent(); + Properties properties = new Properties(); + try (var in = Files.newInputStream(file)) { + properties.load(in); + } + assertEquals(3, properties.size(), "Unexpected number of model properties"); + String gav = properties.getProperty("GAV"); + String name = properties.getProperty("project.name"); + String propertyValue = properties.getProperty("custom.user.property"); + return new ModelData(relativePath != null ? relativePath : Path.of("."), gav, name, propertyValue); + } + + final Path path; + final String gav; + final String name; + final String propertyValue; + + public ModelData(Path path, String gav, String name, String propertyValue) { + this.path = path; + this.gav = gav; + this.name = name; + this.propertyValue = propertyValue; + } + } }