diff --git a/lib/src/main/java/rife/bld/operations/UpgradeOperation.java b/lib/src/main/java/rife/bld/operations/UpgradeOperation.java index 21b7177e..df19527c 100644 --- a/lib/src/main/java/rife/bld/operations/UpgradeOperation.java +++ b/lib/src/main/java/rife/bld/operations/UpgradeOperation.java @@ -3,6 +3,7 @@ package rife.bld.operations; import rife.Version; import rife.bld.wrapper.Wrapper; +import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.util.List; @@ -34,8 +35,8 @@ public class UpgradeOperation extends AbstractOperation { */ public void execute() throws IOException { - // create the wrapper files new Wrapper().createWrapperFiles(Path.of("lib", "bld").toFile(), Version.getVersion()); + new Wrapper().upgradeIdeaBldLibrary(new File(".idea"), Version.getVersion()); if (!silent()) { System.out.println("The wrapper was successfully upgraded."); } diff --git a/lib/src/main/java/rife/bld/wrapper/Wrapper.java b/lib/src/main/java/rife/bld/wrapper/Wrapper.java index 61acc3af..b4da2a8b 100644 --- a/lib/src/main/java/rife/bld/wrapper/Wrapper.java +++ b/lib/src/main/java/rife/bld/wrapper/Wrapper.java @@ -68,6 +68,28 @@ public class Wrapper { createWrapperJar(destinationDirectory); } + /** + * Upgraded the IDEA bld files that were generated with a preview version. + * + * @param destinationDirectory the directory with the IDEA files + * @param version the RIFE2 version they should be using + * @throws IOException when an error occurred during the upgrade of the IDEA files + * @since 1.5.2 + */ + public void upgradeIdeaBldLibrary(File destinationDirectory, String version) + throws IOException { + var file = new File(destinationDirectory, Path.of("libraries", "bld.xml").toString()); + if (file.exists()) { + try { + var content = FileUtils.readString(file); + content = content.replaceAll("rife2-[^\"/!]+\\.jar", "rife2-" + version + ".jar"); + FileUtils.writeString(content, file); + } catch (FileUtilsErrorException e) { + throw new IOException(e); + } + } + } + private void createWrapperProperties(File destinationDirectory, String version) throws IOException { var file = new File(destinationDirectory, WRAPPER_PROPERTIES);