Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve-test-dependencies fail to update classpath to use some optional transitive dependencies coming from hpi included in overrideWar #391

Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@
<!-- annotations are not needed for plugin execution, so exclude using provided scope -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-util</artifactId>
<scope>compile</scope> <!-- To work in Maven versions older than 3.9.0 -->
</dependency>
</dependencies>

<repositories>
Expand Down Expand Up @@ -344,6 +354,9 @@
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
</pomIncludes>
<setupIncludes>
<setupInclude>setup_test-dependencies-transitive-optional-dep/pom.xml</setupInclude>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really need to be done this way, or can you just do everything in one dir using a multimodule reactor?

</setupIncludes>
<postBuildHookScript>verify</postBuildHookScript>
<filterProperties>
<repository.proxy.url>${repository.proxy.url}</repository.proxy.url>
Expand Down Expand Up @@ -424,6 +437,17 @@
<profiles>
<profile>
<id>run-its</id>
<properties>
<jenkins.version.test>2.332.1</jenkins.version.test>
</properties>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-war</artifactId>
<version>${jenkins.version.test}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
Expand All @@ -435,6 +459,9 @@
<goal>install</goal>
<goal>run</goal>
</goals>
<configuration>
<extraArtifacts>org.jenkins-ci.main:jenkins-war:${jenkins.version.test}:war</extraArtifacts>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
27 changes: 27 additions & 0 deletions src/it/override-test-dependencies-useUpperBounds/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,31 @@
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<!-- because jaxen:jaxen have non reacheable dependencies -->
<!-- https://repo.maven.apache.org/maven2/jaxen/jaxen/1.1.3/jaxen-1.1.3.pom
such
<dependency>
<groupId>maven-plugins</groupId>
<artifactId>maven-cobertura-plugin</artifactId>
<version>1.3</version>
<type>plugin</type>
</dependency>

etc....
-->
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-core</artifactId>
<version>${jenkins.version}</version>
<exclusions>
<exclusion>
<groupId>jaxen</groupId>
olamy marked this conversation as resolved.
Show resolved Hide resolved
<artifactId>jaxen</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=install
53 changes: 53 additions & 0 deletions src/it/setup_test-dependencies-transitive-optional-dep/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.40</version>
<relativePath/>
</parent>
<groupId>org.jenkins-ci.tools.hpi.its</groupId>
<artifactId>test-dependencies-transitive-optional-dep</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>hpi</packaging>
<properties>
<jenkins.version>2.332.1</jenkins.version>
<hpi-plugin.version>@project.version@</hpi-plugin.version>
<skipTests>true</skipTests>
</properties>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.lib</groupId>
<artifactId>support-log-formatter</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>symbol-annotation</artifactId>
<version>1.20</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>support-core</artifactId>
<version>2.72</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?jelly escape-by-default='true'?>
<div/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals=verify
#validate hpi:resolve-test-dependencies
157 changes: 157 additions & 0 deletions src/it/test-dependencies-transitive-optional/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.40</version>
<relativePath/>
</parent>
<groupId>org.jenkins-ci.tools.hpi.its</groupId>
<artifactId>test-dependencies-transitive-optional</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>hpi</packaging>
<properties>
<!-- change it back to @jenkins.version.test@ when upgrade made in projec pom -->
<jenkins.version>2.346.1</jenkins.version>
<hpi-plugin.version>@project.version@</hpi-plugin.version>
<useUpperBounds>true</useUpperBounds>
<test>SampleTest</test>
<maven.test.redirectTestOutputToFile>false</maven.test.redirectTestOutputToFile>
<surefire.rerunFailingTestsCount>0</surefire.rerunFailingTestsCount>
<jenkins.war.directory>${project.build.directory}/war</jenkins.war.directory>
<jenkins.war.name>jenkins-${jenkins.version}.war</jenkins.war.name>
<overrideWar>${jenkins.war.directory}/${jenkins.war.name}</overrideWar>
</properties>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-jenkins-war</id>
<phase>process-resources</phase>
<goals>
<goal>copy</goal>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look anything like a real plugin POM so I am struggling to follow what bug this IT purports to reproduce.

</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-war</artifactId>
<version>${jenkins.version}</version>
<type>war</type>
<overWrite>false</overWrite>
<outputDirectory>${jenkins.war.directory}</outputDirectory>
<destFileName>${jenkins.war.name}</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2803.v1a_f77ffcc773</version>
<type>hpi</type>
<outputDirectory>${jenkins.war.directory}/WEB-INF/plugins</outputDirectory>
<destFileName>workflow-cps.hpi</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>support-core</artifactId>
<version>1206.v14049fa_b_d860</version>
<type>hpi</type>
<outputDirectory>${jenkins.war.directory}/WEB-INF/plugins</outputDirectory>
<destFileName>support-core.hpi</destFileName>
</artifactItem>

</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
<execution>
<id>get-workflow-cps</id>
<phase>generate-resources</phase>
<goals>
<goal>get</goal>
</goals>
<configuration>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2803.v1a_f77ffcc773</version>
<packaging>hpi</packaging>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>@exec-maven-plugin.version@</version>
<executions>
<execution>
<phase>process-test-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>jar</executable>
<workingDirectory>${jenkins.war.directory}</workingDirectory>
<arguments>
<argument>uvf</argument>
<argument>${jenkins.war.name}</argument>
<argument>WEB-INF/plugins</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>318.va_f3ccb_729b_71</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>symbol-annotation</artifactId>
<version>1.20</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
<!-- because old version have dependencies on xml-apis:xml-apis:2.6.2 which doesn't exists -->
olamy marked this conversation as resolved.
Show resolved Hide resolved
<version>1.7.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.92</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.tools.hpi.its</groupId>
<artifactId>test-dependencies-transitive-optional-dep</artifactId>
<version>1.0-SNAPSHOT</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?jelly escape-by-default='true'?>
<div/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package test;

import com.google.common.collect.ImmutableMap;
import hudson.remoting.Which;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.Map;
import java.util.jar.Manifest;
import com.cloudbees.jenkins.support.SupportPlugin;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.jvnet.hudson.test.JenkinsRule;

public class SampleTest {

@Rule
public JenkinsRule r = new JenkinsRule();

@Test
public void smokes() throws Exception {
Map<String, String> expectedVersions = ImmutableMap.of("support-core","1206.v14049fa_b_d860");

Enumeration<URL> manifests = SampleTest.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
while (manifests.hasMoreElements()) {
URL url = manifests.nextElement();
try (InputStream is = url.openStream()) {
Manifest mf = new Manifest(is);
String pluginName = mf.getMainAttributes().getValue("Short-Name");
String expectedVersion = expectedVersions.get(pluginName);
if (expectedVersion != null) {
assertEquals("wrong version for " + pluginName + " as classpath entry", expectedVersion, mf.getMainAttributes().getValue("Plugin-Version"));
}
}
}
for (Map.Entry<String, String> entry : expectedVersions.entrySet()) {
assertEquals("wrong version for " + entry.getKey() + " as plugin", entry.getValue(), r.jenkins.pluginManager.getPlugin(entry.getKey()).getVersion());
}
assertEquals("support-core-1206.v14049fa_b_d860.jar", Which.jarFile(SupportPlugin.class).getName());
}

}
Loading