@Test void noExistingFile_community() throws Exception { Path intelliJFolder = Files.createDirectories(testUserHome.resolve(".IdeaIC2019.1")); task.exec(); assertNoExistingConfig(intelliJFolder); testTemplate("update-intellij-jdks-task-test-tables/only-curio-openjdk.template.xml"); }
@TaskAction public void exec() throws IOException { Path userHome = Paths.get(System.getProperty("user.home")); final List<Path> intelliJFolders; try (var files = Files.list(userHome)) { intelliJFolders = files .filter( path -> Files.isDirectory(path) && (path.getFileName().toString().startsWith(".IntelliJIdea") || path.getFileName().toString().startsWith(".IdeaIC"))) .sorted() .collect(toImmutableList()); } final Path intelliJFolder; if (!intelliJFolders.isEmpty()) { intelliJFolder = Iterables.getLast(intelliJFolders); } else { getProject() .getLogger() .info("No IntelliJ config folder found, writing to default location."); intelliJFolder = userHome.resolve(LATEST_INTELLIJ_CONFIG_FOLDER); } getProject() .getLogger() .info("Updating IntelliJ folder {}, found folders {}", intelliJFolder, intelliJFolders); String javaVersion = ToolDependencies.getOpenJdkVersion(getProject()); String majorVersion = javaVersion.startsWith("zulu") ? JavaVersion.toVersion(javaVersion.substring("zulu".length())).getMajorVersion() : JavaVersion.toVersion(javaVersion).getMajorVersion(); String java8Version = ToolDependencies.getOpenJdk8Version(getProject()); final String jdk8FolderSuffix; switch (new PlatformHelper().getOs()) { case WINDOWS: jdk8FolderSuffix = "win_x64"; break; case MAC_OSX: jdk8FolderSuffix = "macosx_x64"; break; case LINUX: jdk8FolderSuffix = "linux_x64"; break; default: throw new IllegalStateException("Unknown OS"); } String jdk8FolderName = java8Version + "/" + java8Version + "-" + jdk8FolderSuffix; var jdkTable = Files.createDirectories(intelliJFolder.resolve("config/options")).resolve("jdk.table.xml"); updateConfig( jdkTable, "jdk-" + javaVersion, majorVersion, "curiostack/openjdk-intellij-table-snippet.template.xml", ImmutableMap.of( "javaVersion", javaVersion, "javaModules", JAVA_MODULES, "majorVersion", majorVersion), getProject()); updateConfig( jdkTable, jdk8FolderName, "1.8", "curiostack/openjdk-8-intellij-table-snippet.template.xml", ImmutableMap.of("javaVersion", java8Version, "javaModules", JAVA_8_JARS), getProject()); updateGoSdk(intelliJFolder, getProject()); updateGoPath(intelliJFolder, getProject()); }
UpdateIntelliJSdksTask extends DefaultTask { @TaskAction public void exec() throws IOException { Path userHome = Paths.get(System.getProperty("user.home")); final List<Path> intelliJFolders; try (var files = Files.list(userHome)) { intelliJFolders = files .filter( path -> Files.isDirectory(path) && (path.getFileName().toString().startsWith(".IntelliJIdea") || path.getFileName().toString().startsWith(".IdeaIC"))) .sorted() .collect(toImmutableList()); } final Path intelliJFolder; if (!intelliJFolders.isEmpty()) { intelliJFolder = Iterables.getLast(intelliJFolders); } else { getProject() .getLogger() .info("No IntelliJ config folder found, writing to default location."); intelliJFolder = userHome.resolve(LATEST_INTELLIJ_CONFIG_FOLDER); } getProject() .getLogger() .info("Updating IntelliJ folder {}, found folders {}", intelliJFolder, intelliJFolders); String javaVersion = ToolDependencies.getOpenJdkVersion(getProject()); String majorVersion = javaVersion.startsWith("zulu") ? JavaVersion.toVersion(javaVersion.substring("zulu".length())).getMajorVersion() : JavaVersion.toVersion(javaVersion).getMajorVersion(); String java8Version = ToolDependencies.getOpenJdk8Version(getProject()); final String jdk8FolderSuffix; switch (new PlatformHelper().getOs()) { case WINDOWS: jdk8FolderSuffix = "win_x64"; break; case MAC_OSX: jdk8FolderSuffix = "macosx_x64"; break; case LINUX: jdk8FolderSuffix = "linux_x64"; break; default: throw new IllegalStateException("Unknown OS"); } String jdk8FolderName = java8Version + "/" + java8Version + "-" + jdk8FolderSuffix; var jdkTable = Files.createDirectories(intelliJFolder.resolve("config/options")).resolve("jdk.table.xml"); updateConfig( jdkTable, "jdk-" + javaVersion, majorVersion, "curiostack/openjdk-intellij-table-snippet.template.xml", ImmutableMap.of( "javaVersion", javaVersion, "javaModules", JAVA_MODULES, "majorVersion", majorVersion), getProject()); updateConfig( jdkTable, jdk8FolderName, "1.8", "curiostack/openjdk-8-intellij-table-snippet.template.xml", ImmutableMap.of("javaVersion", java8Version, "javaModules", JAVA_8_JARS), getProject()); updateGoSdk(intelliJFolder, getProject()); updateGoPath(intelliJFolder, getProject()); } }
UpdateIntelliJSdksTask extends DefaultTask { @TaskAction public void exec() throws IOException { Path userHome = Paths.get(System.getProperty("user.home")); final List<Path> intelliJFolders; try (var files = Files.list(userHome)) { intelliJFolders = files .filter( path -> Files.isDirectory(path) && (path.getFileName().toString().startsWith(".IntelliJIdea") || path.getFileName().toString().startsWith(".IdeaIC"))) .sorted() .collect(toImmutableList()); } final Path intelliJFolder; if (!intelliJFolders.isEmpty()) { intelliJFolder = Iterables.getLast(intelliJFolders); } else { getProject() .getLogger() .info("No IntelliJ config folder found, writing to default location."); intelliJFolder = userHome.resolve(LATEST_INTELLIJ_CONFIG_FOLDER); } getProject() .getLogger() .info("Updating IntelliJ folder {}, found folders {}", intelliJFolder, intelliJFolders); String javaVersion = ToolDependencies.getOpenJdkVersion(getProject()); String majorVersion = javaVersion.startsWith("zulu") ? JavaVersion.toVersion(javaVersion.substring("zulu".length())).getMajorVersion() : JavaVersion.toVersion(javaVersion).getMajorVersion(); String java8Version = ToolDependencies.getOpenJdk8Version(getProject()); final String jdk8FolderSuffix; switch (new PlatformHelper().getOs()) { case WINDOWS: jdk8FolderSuffix = "win_x64"; break; case MAC_OSX: jdk8FolderSuffix = "macosx_x64"; break; case LINUX: jdk8FolderSuffix = "linux_x64"; break; default: throw new IllegalStateException("Unknown OS"); } String jdk8FolderName = java8Version + "/" + java8Version + "-" + jdk8FolderSuffix; var jdkTable = Files.createDirectories(intelliJFolder.resolve("config/options")).resolve("jdk.table.xml"); updateConfig( jdkTable, "jdk-" + javaVersion, majorVersion, "curiostack/openjdk-intellij-table-snippet.template.xml", ImmutableMap.of( "javaVersion", javaVersion, "javaModules", JAVA_MODULES, "majorVersion", majorVersion), getProject()); updateConfig( jdkTable, jdk8FolderName, "1.8", "curiostack/openjdk-8-intellij-table-snippet.template.xml", ImmutableMap.of("javaVersion", java8Version, "javaModules", JAVA_8_JARS), getProject()); updateGoSdk(intelliJFolder, getProject()); updateGoPath(intelliJFolder, getProject()); }  }
UpdateIntelliJSdksTask extends DefaultTask { @TaskAction public void exec() throws IOException { Path userHome = Paths.get(System.getProperty("user.home")); final List<Path> intelliJFolders; try (var files = Files.list(userHome)) { intelliJFolders = files .filter( path -> Files.isDirectory(path) && (path.getFileName().toString().startsWith(".IntelliJIdea") || path.getFileName().toString().startsWith(".IdeaIC"))) .sorted() .collect(toImmutableList()); } final Path intelliJFolder; if (!intelliJFolders.isEmpty()) { intelliJFolder = Iterables.getLast(intelliJFolders); } else { getProject() .getLogger() .info("No IntelliJ config folder found, writing to default location."); intelliJFolder = userHome.resolve(LATEST_INTELLIJ_CONFIG_FOLDER); } getProject() .getLogger() .info("Updating IntelliJ folder {}, found folders {}", intelliJFolder, intelliJFolders); String javaVersion = ToolDependencies.getOpenJdkVersion(getProject()); String majorVersion = javaVersion.startsWith("zulu") ? JavaVersion.toVersion(javaVersion.substring("zulu".length())).getMajorVersion() : JavaVersion.toVersion(javaVersion).getMajorVersion(); String java8Version = ToolDependencies.getOpenJdk8Version(getProject()); final String jdk8FolderSuffix; switch (new PlatformHelper().getOs()) { case WINDOWS: jdk8FolderSuffix = "win_x64"; break; case MAC_OSX: jdk8FolderSuffix = "macosx_x64"; break; case LINUX: jdk8FolderSuffix = "linux_x64"; break; default: throw new IllegalStateException("Unknown OS"); } String jdk8FolderName = java8Version + "/" + java8Version + "-" + jdk8FolderSuffix; var jdkTable = Files.createDirectories(intelliJFolder.resolve("config/options")).resolve("jdk.table.xml"); updateConfig( jdkTable, "jdk-" + javaVersion, majorVersion, "curiostack/openjdk-intellij-table-snippet.template.xml", ImmutableMap.of( "javaVersion", javaVersion, "javaModules", JAVA_MODULES, "majorVersion", majorVersion), getProject()); updateConfig( jdkTable, jdk8FolderName, "1.8", "curiostack/openjdk-8-intellij-table-snippet.template.xml", ImmutableMap.of("javaVersion", java8Version, "javaModules", JAVA_8_JARS), getProject()); updateGoSdk(intelliJFolder, getProject()); updateGoPath(intelliJFolder, getProject()); }  @TaskAction void exec(); }
UpdateIntelliJSdksTask extends DefaultTask { @TaskAction public void exec() throws IOException { Path userHome = Paths.get(System.getProperty("user.home")); final List<Path> intelliJFolders; try (var files = Files.list(userHome)) { intelliJFolders = files .filter( path -> Files.isDirectory(path) && (path.getFileName().toString().startsWith(".IntelliJIdea") || path.getFileName().toString().startsWith(".IdeaIC"))) .sorted() .collect(toImmutableList()); } final Path intelliJFolder; if (!intelliJFolders.isEmpty()) { intelliJFolder = Iterables.getLast(intelliJFolders); } else { getProject() .getLogger() .info("No IntelliJ config folder found, writing to default location."); intelliJFolder = userHome.resolve(LATEST_INTELLIJ_CONFIG_FOLDER); } getProject() .getLogger() .info("Updating IntelliJ folder {}, found folders {}", intelliJFolder, intelliJFolders); String javaVersion = ToolDependencies.getOpenJdkVersion(getProject()); String majorVersion = javaVersion.startsWith("zulu") ? JavaVersion.toVersion(javaVersion.substring("zulu".length())).getMajorVersion() : JavaVersion.toVersion(javaVersion).getMajorVersion(); String java8Version = ToolDependencies.getOpenJdk8Version(getProject()); final String jdk8FolderSuffix; switch (new PlatformHelper().getOs()) { case WINDOWS: jdk8FolderSuffix = "win_x64"; break; case MAC_OSX: jdk8FolderSuffix = "macosx_x64"; break; case LINUX: jdk8FolderSuffix = "linux_x64"; break; default: throw new IllegalStateException("Unknown OS"); } String jdk8FolderName = java8Version + "/" + java8Version + "-" + jdk8FolderSuffix; var jdkTable = Files.createDirectories(intelliJFolder.resolve("config/options")).resolve("jdk.table.xml"); updateConfig( jdkTable, "jdk-" + javaVersion, majorVersion, "curiostack/openjdk-intellij-table-snippet.template.xml", ImmutableMap.of( "javaVersion", javaVersion, "javaModules", JAVA_MODULES, "majorVersion", majorVersion), getProject()); updateConfig( jdkTable, jdk8FolderName, "1.8", "curiostack/openjdk-8-intellij-table-snippet.template.xml", ImmutableMap.of("javaVersion", java8Version, "javaModules", JAVA_8_JARS), getProject()); updateGoSdk(intelliJFolder, getProject()); updateGoPath(intelliJFolder, getProject()); }  @TaskAction void exec(); static final String NAME; }