Skip to content

Commit

Permalink
Fix build when ant.tstamp.now is not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Mar 24, 2022
1 parent 43df99e commit f7b9a00
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2879,7 +2879,7 @@ skip.installer property in build.properties" />
<taskdef name="repeatableArchive"
classname="org.apache.tomcat.buildutil.RepeatableArchive"
classpath="${tomcat.classes}" />
<repeatableArchive datetime="${ant.tstamp.now}">
<repeatableArchive datetime="${tstamp.file}" pattern="yyyy-MM-dd HH:mm:ss">
<fileset dir="${tomcat.dist}/webapps/docs">
<include name="**/*.zip"/>
</fileset>
Expand Down
23 changes: 20 additions & 3 deletions java/org/apache/tomcat/buildutil/RepeatableArchive.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.FileTime;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -48,7 +51,8 @@ public class RepeatableArchive extends Task {

private final List<FileSet> filesets = new LinkedList<>();

private long datetime;
private String datetime;
private String pattern;

/**
* Sets the files to be processed
Expand All @@ -60,16 +64,29 @@ public void addFileset(FileSet fs) {
}


public void setDatetime(long datetime) {
public void setDatetime(String datetime) {
this.datetime = datetime;
}


public void setPattern(String pattern) {
this.pattern = pattern;
}


@Override
public void execute() throws BuildException {

SimpleDateFormat sdf = new SimpleDateFormat(pattern);
Date date;
try {
date = sdf.parse(datetime);
} catch (ParseException e) {
throw new BuildException(e);
}

byte[] buf = new byte[8192];
FileTime lastModified = FileTime.fromMillis(datetime);
FileTime lastModified = FileTime.fromMillis(date.getTime());

for (FileSet fs : filesets) {
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
Expand Down

0 comments on commit f7b9a00

Please sign in to comment.