-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
139859e
commit cd2961b
Showing
21 changed files
with
944 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package se.kth.deptrim.mojo.util; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Utility class for handling files. | ||
*/ | ||
public class FileUtils { | ||
|
||
/** | ||
* Delete all empty directories in the given directory. | ||
* | ||
* @param directory the directory to delete empty directories from | ||
*/ | ||
public int deleteEmptyDirectories(File directory) { | ||
List<File> toBeDeleted = Arrays.stream(directory.listFiles()).sorted() | ||
.filter(File::isDirectory) | ||
.filter(f -> f.listFiles().length == deleteEmptyDirectories(f)) | ||
.collect(Collectors.toList()); | ||
int size = toBeDeleted.size(); | ||
toBeDeleted.forEach(t -> { | ||
final String path = t.getAbsolutePath(); | ||
final boolean delete = t.delete(); | ||
}); | ||
return size; // the number of deleted directories. | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...in/java/se/kth/deptrim/mojo/JarUtils.java → ...va/se/kth/deptrim/mojo/util/JarUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package se.kth.deptrim.mojo.util; | ||
|
||
public class PomUtils { | ||
|
||
// TODO | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package se.kth.deptrim.mojo.util; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* Utility class for handling time. | ||
*/ | ||
public class TimeUtils { | ||
|
||
/** | ||
* Convert milliseconds to a human-readable format. | ||
* | ||
* @param millis The milliseconds to be converted. | ||
* @return A string representing the time. | ||
*/ | ||
public String toHumanReadableTime(long millis) { | ||
long minutes = TimeUnit.MILLISECONDS.toMinutes(millis); | ||
long seconds = (TimeUnit.MILLISECONDS.toSeconds(millis) % 60); | ||
return String.format("%smin %ss", minutes, seconds); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package se.kth.deptrim.mojo.util; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class TimeUtilsTest { | ||
|
||
TimeUtils timeUtils; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
timeUtils = new TimeUtils(); | ||
} | ||
|
||
@Test | ||
void ifGettingTheTimeThenTimeIsCorrect() { | ||
Assertions.assertEquals("1min 40s", timeUtils.toHumanReadableTime(100000)); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.