1
0
mirror of https://github.com/chylex/IntelliJ-Colored-Icons.git synced 2025-04-11 05:15:48 +02:00

Add task to delete finished icons from the extracted folder

This commit is contained in:
chylex 2023-12-11 13:32:58 +01:00
parent 735e38f6b5
commit cc5a82eead
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
3 changed files with 75 additions and 0 deletions
.idea/runConfigurations
build.gradle.kts
helpers/com/chylex/intellij/coloredicons

View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Delete Finished Icons" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="deleteFinishedIcons" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>

View File

@ -81,6 +81,7 @@ fun getClassPathFolders(configuration: Configuration): List<String> {
}
createHelperTask("fixSVGs", main = "FixSVGs")
createHelperTask("deleteFinishedIcons", main = "DeleteFinishedIcons")
createHelperTask("grabIconsFromInstalledIDEs", main = "GrabIcons\$FromInstalledIDEs")
createHelperTask("grabIconsFromGradle", main = "GrabIcons\$FromArgumentPaths") { task ->
val ideLibraries = getClassPathFolders(project.configurations.getByName("ides"))

View File

@ -0,0 +1,50 @@
package com.chylex.intellij.coloredicons;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Set;
import static java.util.stream.Collectors.toSet;
public final class DeleteFinishedIcons {
@SuppressWarnings("ResultOfMethodCallIgnored")
public static void main(final String[] args) {
final Path extractedRootPath = Path.of("./extracted");
final Path finishedRootPath = Path.of("./resources/icons");
final Collection<File> extractedFiles = FileUtils.listFiles(extractedRootPath.toFile(), null, true);
final Collection<File> finishedFiles = FileUtils.listFiles(finishedRootPath.toFile(), null, true);
System.out.println("Extracted files: " + extractedFiles.size());
System.out.println("Finished files: " + finishedFiles.size());
final Set<String> finishedRelativePaths = finishedFiles.stream()
.map(file -> relativize(finishedRootPath, file))
.collect(toSet());
int deleted = 0;
for (final File extractedFile : extractedFiles) {
if (finishedRelativePaths.remove(relativize(extractedRootPath, extractedFile))) {
++deleted;
extractedFile.delete();
}
}
System.out.println("Deleted files: " + deleted);
if (!finishedRelativePaths.isEmpty()) {
System.out.println("Undeleted files: " + finishedRelativePaths.size());
System.out.println();
finishedRelativePaths.stream()
.sorted()
.forEachOrdered(undeletedPath -> System.out.println("Undeleted file: " + undeletedPath));
}
}
private static String relativize(final Path basePath, final File file) {
return basePath.relativize(file.toPath()).toString();
}
}