mirror of
https://github.com/chylex/IntelliJ-Colored-Icons.git
synced 2025-05-01 10:34:06 +02:00
Add task to delete finished icons from the extracted folder
This commit is contained in:
parent
735e38f6b5
commit
cc5a82eead
24
.idea/runConfigurations/Delete_Finished_Icons.xml
Normal file
24
.idea/runConfigurations/Delete_Finished_Icons.xml
Normal 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>
|
@ -81,6 +81,7 @@ fun getClassPathFolders(configuration: Configuration): List<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createHelperTask("fixSVGs", main = "FixSVGs")
|
createHelperTask("fixSVGs", main = "FixSVGs")
|
||||||
|
createHelperTask("deleteFinishedIcons", main = "DeleteFinishedIcons")
|
||||||
createHelperTask("grabIconsFromInstalledIDEs", main = "GrabIcons\$FromInstalledIDEs")
|
createHelperTask("grabIconsFromInstalledIDEs", main = "GrabIcons\$FromInstalledIDEs")
|
||||||
createHelperTask("grabIconsFromGradle", main = "GrabIcons\$FromArgumentPaths") { task ->
|
createHelperTask("grabIconsFromGradle", main = "GrabIcons\$FromArgumentPaths") { task ->
|
||||||
val ideLibraries = getClassPathFolders(project.configurations.getByName("ides"))
|
val ideLibraries = getClassPathFolders(project.configurations.getByName("ides"))
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user