Skip to content

Commit

Permalink
Merge pull request #765 from jonesbusy/bugfix/754
Browse files Browse the repository at this point in the history
Fix incompatibility for OpenRewrite and jackson-dataformat-yaml
  • Loading branch information
jonesbusy authored Feb 4, 2025
2 parents 1521d48 + 0abfc9b commit bd2776d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,47 @@ public void testRecipeOnLocalPlugin(WireMockRuntimeInfo wmRuntimeInfo) throws Ex
}
}

@Test
@Tag("Slow")
public void testComplexRecipeOnLocalPlugin(WireMockRuntimeInfo wmRuntimeInfo) throws Exception {

Path logFile = setupLogs("testRecipeOnLocalPlugin");

// Copy empty plugin to cache and use as local plugin
final String plugin = "empty";
final Path pluginPath = Path.of("src/test/resources").resolve(plugin);
Path targetPath = cachePath
.resolve("jenkins-plugin-modernizer-cli")
.resolve(plugin)
.resolve("sources");
FileUtils.copyDirectory(pluginPath.toFile(), targetPath.toFile());
Git.init().setDirectory(targetPath.toFile()).call().close();

final String recipe = "UpgradeNextMajorParentVersion";

try (GitHubServerContainer gitRemote = new GitHubServerContainer(wmRuntimeInfo, keysPath, plugin, "main")) {

gitRemote.start();

// Junit attachment with logs file for the plugin build
System.out.printf("[[ATTACHMENT|%s]]%n", getMavenInvokerLog(plugin));
System.out.printf("[[ATTACHMENT|%s]]%n", logFile.toAbsolutePath());

Invoker invoker = buildInvoker();
InvocationRequest request = buildRequest(
"dry-run --recipe %s %s"
.formatted(recipe, getRunArgs(wmRuntimeInfo, Plugin.build(plugin, targetPath))),
logFile);
InvocationResult result = invoker.execute(request);

// Assert output
assertAll(
() -> assertEquals(0, result.getExitCode()),
() -> assertTrue(Files.readAllLines(logFile).stream()
.anyMatch(line -> line.matches("(.*)Dry run mode. Changes were made on (.*)"))));
}
}

@Test
@Tag("Slow")
public void testRecipeOnLocalPluginWithRunMode(WireMockRuntimeInfo wmRuntimeInfo) throws Exception {
Expand Down
2 changes: 2 additions & 0 deletions plugin-modernizer-cli/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<logger name="io.jenkins.tools.pluginmodernizer" level="TRACE" />
<logger name="io.jenkins.tools.pluginmodernizer.cli.utils" level="INFO" />
<logger name="org.apache.sshd.common.util" level="WARN" />
<logger name="org.eclipse.jgit.internal" level="INFO" />
<logger name="org.eclipse.jgit.util" level="INFO" />
<logger name="org.testcontainers" level="INFO" />
<logger name="com.github.sparsick.testcontainers" level="INFO" />
<logger name="tc.rockstorm/git-server:2.47" level="WARN" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.jenkins.tools.pluginmodernizer.core.extractor;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.jenkins.tools.pluginmodernizer.core.impl.CacheManager;
import io.jenkins.tools.pluginmodernizer.core.model.CacheEntry;
import io.jenkins.tools.pluginmodernizer.core.model.JDK;
Expand Down Expand Up @@ -105,7 +107,8 @@ public PluginMetadata() {
* Create a new plugin metadata with the given key
* @param key The key
*/
public PluginMetadata(String key) {
@JsonCreator
public PluginMetadata(@JsonProperty("key") String key) {
super(new CacheManager(Path.of("target")), PluginMetadata.class, key, Path.of("."));
}

Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<common.text.version>1.13.0</common.text.version>
<asm.version>9.7.1</asm.version>
<gson.version>2.12.1</gson.version>
<jackson.version>2.18.2</jackson.version>
<jackson.version>2.17.2</jackson.version>
<maven.version>3.9.9</maven.version>
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
<jgit.version>7.1.0.202411261347-r</jgit.version>
Expand Down Expand Up @@ -249,6 +249,12 @@
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>${github-api.version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
Expand Down

0 comments on commit bd2776d

Please sign in to comment.