Skip to content

Commit

Permalink
Fail on missing plugin product requirement
Browse files Browse the repository at this point in the history
Currently Tycho does not fail if a requirement of a product can't be
found in the resolve phase but only if the product is materialized. Even
then it fails with an obscure error that claims the products bundle is
not found where actually the dependency can't be found.
  • Loading branch information
laeubi committed Jan 20, 2024
1 parent 6b9cefe commit c2370ee
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
###############################################################################
# Copyright (c) 2010, 2011 SAP AG and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# SAP AG - initial API and implementation
###############################################################################
bin.includes = feature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="org.osgi.service.jaxrs.feature"
label="Example Feature"
version="1.0.0.qualifier">

<description url="http://www.example.com/description">
A description of an example feature
</description>

<copyright url="http://www.example.com/copyright">
[Enter Copyright Description here.]
</copyright>

<license url="http://www.example.com/license">
[Enter License Description here.]
</license>

<!-- this should not lead to an NPE in the dependency-only publisher (TYCHO-556) -->
<url>
<discovery label="New discovery site" url="http://newsite"/>
</url>

<plugin
id="org.osgi.service.jaxrs"
download-size="0"
install-size="0"
version="0.0.0"/>

</feature>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>tycho-its</groupId>
<artifactId>missing.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>org.osgi.service.jaxrs.feature</artifactId>
<packaging>eclipse-feature</packaging>
<name>Example Feature</name>

<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.jaxrs</artifactId>
<version>1.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.aries.spec</groupId>
<artifactId>org.apache.aries.javax.jax.rs-api</artifactId>
<version>1.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>1.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.18.600</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>tycho-its</groupId>
<artifactId>missing.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<modules>
<module>feature</module>
<module>product</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product uid="plugin.product" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="false" autoIncludeRequirements="false">

<features>
<feature id="org.osgi.service.jaxrs.feature" />
</features>

</product>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>tycho-its</groupId>
<artifactId>missing.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>feature.product</artifactId>
<packaging>eclipse-repository</packaging>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>materialize-products</id>
<goals>
<goal>materialize-products</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.jaxrs</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product uid="plugin.product" version="1.0.0.qualifier" useFeatures="false" includeLaunchers="false" autoIncludeRequirements="false">
<plugins>
<plugin id="org.osgi.service.jaxrs"/>
</plugins>
</product>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>
<groupId>tycho-its</groupId>
<artifactId>plugin.product</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-repository</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>materialize-products</id>
<goals>
<goal>materialize-products</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.jaxrs</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static org.hamcrest.Matchers.hasItem;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.io.File;
import java.io.IOException;
Expand All @@ -24,6 +25,7 @@
import java.util.Optional;
import java.util.stream.Collectors;

import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
import org.eclipse.tycho.TargetEnvironment;
import org.eclipse.tycho.TychoConstants;
Expand All @@ -39,6 +41,22 @@ public class ProductBuildTest extends AbstractTychoIntegrationTest {
private static final List<String> REQUIRED_PGP_PROPERTIES = List.of(TychoConstants.PROP_PGP_SIGNATURES,
TychoConstants.PROP_PGP_KEYS);

@Test
public void testPluginProjectFailsOnMissingDependencies() throws Exception {
Verifier verifier = getVerifier("tycho-p2-director-plugin/missing-requirements-plugins", false, true);
assertThrows(VerificationException.class, () -> verifier.executeGoals(Arrays.asList("clean", "package")));
verifier.verifyTextInLog(
"Cannot resolve dependencies of project tycho-its:plugin.product:eclipse-repository:1.0.0-SNAPSHOT");
}

@Test
public void testFeatureProjectFailsOnMissingDependencies() throws Exception {
Verifier verifier = getVerifier("tycho-p2-director-plugin/missing-requirements-feature", false, true);
assertThrows(VerificationException.class, () -> verifier.executeGoals(Arrays.asList("clean", "package")));
verifier.verifyTextInLog(
"Cannot resolve dependencies of project tycho-its:feature.product:eclipse-repository:1.0.0-SNAPSHOT");
}

@Test
public void testMavenDepedencyInTarget() throws Exception {
Verifier verifier = getVerifier("product.mavenLocation", false);
Expand Down

0 comments on commit c2370ee

Please sign in to comment.