jira-importer commented on issue #304: URL: https://github.com/apache/maven-jar-plugin/issues/304#issuecomment-2956696178
**[Rakhunathan](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=mrakhunathan)** commented Not really sure why the problem occurs, but found out the solution. The error occurs because, one or more file that you are trying to build, has a negative time.(file.getLastModified() returns a negative value). If its a huge project, might be hard to track which of them has gone wrong. Below code might help package com.example; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Date; import java.util.List; public class ModifyAll { public static void main(String[] args) throws IOException { List\<File> folderList = new ArrayList<>(); List\<File> fileList = new ArrayList<>(); File folder = new File("D:/Rakhu/Copy/projectfolder/src"); FileVO baseFileVO = segregateFiles(folder); fileList.addAll(baseFileVO.getFileList()); folderList.addAll(baseFileVO.getFolderList()); for (int i = 0; i < folderList.size(); i++) { FileVO thisVO = segregateFiles(folderList.get(i)); fileList.addAll(thisVO.getFileList()); folderList.addAll(thisVO.getFolderList()); } for (int i = 0; i < fileList.size(); i++) { Date dte = new Date(); long milliSeconds = dte.getTime(); System.out.println("Setting Time For " + fileList.get(i) + " as " + milliSeconds); fileList.get(i).setLastModified(milliSeconds); } System.out.println("Succesfully Modified..!!!"); } public static FileVO segregateFiles(File folder) { List<File> folderList = new ArrayList<>(); List<File> fileList = new ArrayList<>(); File[] listOfFiles = folder.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { fileList.add(listOfFiles[i]); } else { folderList.add(listOfFiles[i]); } System.out.println(listOfFiles[i]); } return new FileVO(fileList, folderList); } } FileVO.java package com.example; import java.io.File; import java.util.ArrayList; import java.util.List; public class FileVO { List\<File> fileList = new ArrayList<>(); List\<File> folderList = new ArrayList<>(); public FileVO(List<File> fileList, List<File> folderList) { this.fileList = fileList; this.folderList = folderList; } public List<File> getFileList() { return fileList; } public void setFileList(List<File> fileList) { this.fileList = fileList; } public List<File> getFolderList() { return folderList; } public void setFolderList(List<File> folderList) { this.folderList = folderList; } } -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
