This is an automated email from the ASF dual-hosted git repository. rfscholte pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-dist-tool.git
The following commit(s) were added to refs/heads/master by this push: new fe1735b Use https URLs Use DateTime API fe1735b is described below commit fe1735b3531acb721bfeb1af390d9e9bc37ceacd Author: rfscholte <rfscho...@apache.org> AuthorDate: Sat Nov 23 21:06:23 2019 +0100 Use https URLs Use DateTime API --- .../maven/dist/tools/ConfigurationLineInfo.java | 21 ++++---------- .../dist/tools/index/DistCheckIndexPageMojo.java | 33 ++++++++-------------- .../dist/tools/prerequisites/GetPrerequisites.java | 2 +- 3 files changed, 18 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java b/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java index 5c02af4..663487a 100644 --- a/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java +++ b/src/main/java/org/apache/maven/dist/tools/ConfigurationLineInfo.java @@ -19,9 +19,8 @@ package org.apache.maven.dist.tools; * under the License. */ -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAccessor; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -151,19 +150,11 @@ public class ConfigurationLineInfo public String getReleaseDateFromMetadata() { - try - { - SimpleDateFormat dateFormatter = new SimpleDateFormat( "yyyyMMddkkmmss" ); - Date f = dateFormatter.parse( metadata.getVersioning().getLastUpdated() ); - // inverted for index page check - SimpleDateFormat dateFormattertarget = new SimpleDateFormat( "yyyy-MM-dd" ); - return dateFormattertarget.format( f ); - } - catch ( ParseException ex ) - { - return "Cannot parse"; - } + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern( "yyyyMMddkkmmss" ); + TemporalAccessor ta = dateFormatter.parse( metadata.getVersioning().getLastUpdated() ); + // inverted for index page check + return DateTimeFormatter.ISO_LOCAL_DATE.format( ta ); } public String getSourceReleaseFilename( String version, boolean dist ) diff --git a/src/main/java/org/apache/maven/dist/tools/index/DistCheckIndexPageMojo.java b/src/main/java/org/apache/maven/dist/tools/index/DistCheckIndexPageMojo.java index b83aebd..52edb4b 100644 --- a/src/main/java/org/apache/maven/dist/tools/index/DistCheckIndexPageMojo.java +++ b/src/main/java/org/apache/maven/dist/tools/index/DistCheckIndexPageMojo.java @@ -20,11 +20,9 @@ package org.apache.maven.dist.tools.index; */ import java.io.IOException; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.Period; import java.util.Collections; -import java.util.Date; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -55,12 +53,12 @@ public class DistCheckIndexPageMojo { public static final String FAILURES_FILENAME = "check-index-page.log"; - public static final String POMS_INDEX_URL = "http://maven.apache.org/pom/"; + public static final String POMS_INDEX_URL = "https://maven.apache.org/pom/"; private static final IndexPage[] INDEX_PAGES = new IndexPage[] { - new IndexPage( "http://maven.apache.org/plugins/", "Plugins", 3, true ), - new IndexPage( "http://maven.apache.org/shared/", "Shared", 2, true ), - new IndexPage( "http://maven.apache.org/skins/", "Skins", 2, false ), + new IndexPage( "https://maven.apache.org/plugins/", "Plugins", 3, true ), + new IndexPage( "https://maven.apache.org/shared/", "Shared", 2, true ), + new IndexPage( "https://maven.apache.org/skins/", "Skins", 2, false ), new IndexPage( POMS_INDEX_URL, "Poms", 2, true ) }; private static final Map<String, IndexPage> INDEX_PAGES_REF; @@ -186,20 +184,11 @@ public class DistCheckIndexPageMojo private boolean isDateSimilar( String date1, String date2 ) { - try - { - DateFormat df = new SimpleDateFormat( "yyyy-MM-dd" ); - Date d1 = df.parse( date1 ); - Date d2 = df.parse( date2 ); + LocalDate d1 = LocalDate.parse( date1 ); + LocalDate d2 = LocalDate.parse( date2 ); - @SuppressWarnings( "checkstyle:magicnumber" ) - long daysDifference = ( d1.getTime() - d2.getTime() ) / ( 24 * 60 * 60 * 1000 ); - return Math.abs( daysDifference ) < 7; // ok for 7 days difference - } - catch ( ParseException e ) - { - return false; - } + long daysDifference = Period.between( d1, d2 ).getDays(); + return Math.abs( daysDifference ) < 7; // ok for 7 days difference } @Override @@ -292,7 +281,7 @@ public class DistCheckIndexPageMojo indexPage.document = doc; } - // Maven parent POM is now a special case in http://maven.apache.org/pom/ + // Maven parent POM is now a special case in https://maven.apache.org/pom/ boolean isMavenParentPoms = ( "maven-parent".equals( cli.getArtifactId() ) ); Elements a = isMavenParentPoms ? doc.select( "tr > th > b" ) diff --git a/src/main/java/org/apache/maven/dist/tools/prerequisites/GetPrerequisites.java b/src/main/java/org/apache/maven/dist/tools/prerequisites/GetPrerequisites.java index d59d8e6..e38ee67 100644 --- a/src/main/java/org/apache/maven/dist/tools/prerequisites/GetPrerequisites.java +++ b/src/main/java/org/apache/maven/dist/tools/prerequisites/GetPrerequisites.java @@ -92,7 +92,7 @@ public class GetPrerequisites "maven-war-plugin", }; - private static final String BASEURL = "http://maven.apache.org/plugins/"; + private static final String BASEURL = "https://maven.apache.org/plugins/"; public String getPluginInfoUrl( String pluginName ) {