From 5187ee4faff3675619d590575b02e7c2c9d13523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 13 Jul 2022 14:39:16 +0200 Subject: [PATCH] Updates of dependencies - excluded Velocity and Struts (not used, reported security issues) - tests use JUnit5 now --- README.md | 13 +++-- pom.xml | 51 +++++++++++++------ .../mojo/AbstractNative2AsciiMojo.java | 29 ++++++----- .../native2ascii/mojo/Native2AsciiMojo.java | 3 +- src/site/apt/index.apt | 2 +- .../mojo/native2ascii/Native2AsciiTest.java | 17 ++++--- .../mojo/Native2AsciiMojoTest.java | 11 ++-- 7 files changed, 77 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index ab95aef..0c6a08b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,13 @@ # Native2ascii Maven Plugin -[![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/mojohaus/native2ascii.svg?label=License)](http://www.apache.org/licenses/) -[![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.mojo/native2ascii-maven-plugin.svg?label=Maven%20Central)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.codehaus.mojo%22%20AND%20a%3A%22native2ascii-maven-plugin%22) -[![Build Status](https://travis-ci.org/mojohaus/native2ascii-maven-plugin.svg?branch=master)](https://travis-ci.org/mojohaus/native2ascii-maven-plugin) +[![License: MIT](https://img.shields.io/github/license/mojohaus/native2ascii-maven-plugin)]( +https://opensource.org/licenses/MIT) +[![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.mojo/native2ascii-maven-plugin.svg?label=Maven%20Central)]( +http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.codehaus.mojo%22%20AND%20a%3A%22native2ascii-maven-plugin%22) +[![JDK Compatibility](https://github.com/mojohaus/native2ascii-maven-plugin/actions/workflows/linux-jdks-with-current-maven-ci.yml/badge.svg)]( +https://github.com/mojohaus/native2ascii-maven-plugin/actions/workflows/linux-jdks-with-current-maven-ci.yml) +[![CodeQL Analysis](https://github.com/mojohaus/native2ascii-maven-plugin/actions/workflows/codeql-analysis.yml/badge.svg)]( +https://github.com/mojohaus/native2ascii-maven-plugin/actions/workflows/codeql-analysis.yml) Target: Better version than 1.0-alpha-1 and 1.0-beta-1, both are incompatible and poorly documented @@ -10,4 +15,4 @@ Target: Better version than 1.0-alpha-1 and 1.0-beta-1, both are incompatible an Look here for the usage: https://github.com/mojohaus/native2ascii/wiki/_pages -Also note this issue: https://bugs.openjdk.java.net/browse/JDK-8074431 - this plugin is not affected and works even with JDK9. +Also note this issue: https://bugs.openjdk.java.net/browse/JDK-8074431 - this plugin is not affected and works even with JDK18. diff --git a/pom.xml b/pom.xml index a630305..a8f6af2 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.codehaus.mojo native2ascii-maven-plugin - 2.0.2-SNAPSHOT + 2.1.0-SNAPSHOT maven-plugin Native2Ascii Maven Plugin @@ -15,7 +15,7 @@ org.codehaus.mojo mojo-parent - 40 + 69 https://github.com/mojohaus/native2ascii-maven-plugin/wiki @@ -32,7 +32,7 @@ dmatej David Matějček - dmatej79@gmail.com + dmatej@seznam.cz +1 Developer @@ -73,7 +73,7 @@ HEAD - JIRA + GitHub https://github.com/mojohaus/native2ascii/issues @@ -87,38 +87,59 @@ - TravisCI - https://travis-ci.org/mojohaus/native2ascii-maven-plugin + GitHub + https://github.com/mojohaus/native2ascii-maven-plugin/actions org.apache.maven maven-plugin-api - 3.5.0 + 3.8.6 + provided org.apache.maven.plugins maven-plugin-plugin - 3.5 + 3.6.4 + provided + + + org.codehaus.plexus + * + + + org.apache.velocity + * + + + + + org.apache.commons + commons-text + 1.9 org.apache.commons commons-lang3 - 3.5 + 3.12.0 + + + org.junit.jupiter + junit-jupiter-api + test - junit - junit - 4.13.1 + org.junit.jupiter + junit-jupiter-engine test UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 @@ -126,7 +147,6 @@ org.apache.maven.plugins maven-plugin-plugin - 3.5 true @@ -143,7 +163,6 @@ org.apache.maven.plugins maven-invoker-plugin - 3.0.1 false src/it diff --git a/src/main/java/org/codehaus/mojo/native2ascii/mojo/AbstractNative2AsciiMojo.java b/src/main/java/org/codehaus/mojo/native2ascii/mojo/AbstractNative2AsciiMojo.java index e524fd7..7648171 100644 --- a/src/main/java/org/codehaus/mojo/native2ascii/mojo/AbstractNative2AsciiMojo.java +++ b/src/main/java/org/codehaus/mojo/native2ascii/mojo/AbstractNative2AsciiMojo.java @@ -1,5 +1,6 @@ /* * The MIT License + * Copyright (c) 2014-2022 MojoHaus * Copyright (c) 2007 The Codehaus * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -18,6 +19,7 @@ import java.io.File; import java.io.IOException; +import java.util.Arrays; import java.util.Iterator; import org.apache.commons.lang3.StringUtils; @@ -27,7 +29,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.plexus.util.FileUtils; -import edu.emory.mathcs.backport.java.util.Arrays; /** * @author David Matějček @@ -53,6 +54,7 @@ public abstract class AbstractNative2AsciiMojo extends AbstractMojo { public String[] excludes; + @Override public final void execute() throws MojoExecutionException, MojoFailureException { if (!checkParameters()) { return; @@ -87,15 +89,15 @@ protected boolean checkParameters() { getLog().warn("Source directory does not exist: " + getSourceDirectory().getAbsolutePath()); return false; } - if (includes == null) { - includes = new String[] {"**/*.properties"}; + if (this.includes == null) { + this.includes = new String[] {"**/*.properties"}; } - if (excludes == null) { - excludes = new String[0]; + if (this.excludes == null) { + this.excludes = new String[0]; } - if (StringUtils.isEmpty(encoding)) { - encoding = System.getProperty("file.encoding"); - getLog().warn("Using platform encoding (" + encoding + " actually) to convert resources!"); + if (StringUtils.isEmpty(this.encoding)) { + this.encoding = System.getProperty("file.encoding"); + getLog().warn("Using platform encoding (" + this.encoding + " actually) to convert resources!"); } return true; } @@ -104,15 +106,14 @@ protected boolean checkParameters() { private Iterator findFiles() throws MojoExecutionException { try { if (getLog().isInfoEnabled()) { - getLog().info("Includes: " + Arrays.asList(includes)); - getLog().info("Excludes: " + Arrays.asList(excludes)); + getLog().info("Includes: " + Arrays.asList(this.includes)); + getLog().info("Excludes: " + Arrays.asList(this.excludes)); } - String incl = StringUtils.join(includes, ","); - String excl = StringUtils.join(excludes, ","); - @SuppressWarnings("unchecked") + final String incl = StringUtils.join(this.includes, ","); + final String excl = StringUtils.join(this.excludes, ","); final Iterator files = FileUtils.getFiles(getSourceDirectory(), incl, excl).iterator(); return files; - } catch (IOException e) { + } catch (final IOException e) { throw new MojoExecutionException("Unable to get list of files"); } } diff --git a/src/main/java/org/codehaus/mojo/native2ascii/mojo/Native2AsciiMojo.java b/src/main/java/org/codehaus/mojo/native2ascii/mojo/Native2AsciiMojo.java index ccc8634..d32c06b 100644 --- a/src/main/java/org/codehaus/mojo/native2ascii/mojo/Native2AsciiMojo.java +++ b/src/main/java/org/codehaus/mojo/native2ascii/mojo/Native2AsciiMojo.java @@ -1,5 +1,6 @@ /* * The MIT License + * Copyright (c) 2014-2022 MojoHaus * Copyright (c) 2007 The Codehaus * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -20,11 +21,11 @@ import java.io.IOException; import java.util.Iterator; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.shared.utils.StringUtils; import org.codehaus.mojo.native2ascii.Native2Ascii; /** diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt index c841c33..649a9ab 100644 --- a/src/site/apt/index.apt +++ b/src/site/apt/index.apt @@ -2,7 +2,7 @@ Introduction ------ David Matejcek - + ------ 2017-12-23 ------ diff --git a/src/test/java/org/codehaus/mojo/native2ascii/Native2AsciiTest.java b/src/test/java/org/codehaus/mojo/native2ascii/Native2AsciiTest.java index 3aaeed1..e8f097e 100644 --- a/src/test/java/org/codehaus/mojo/native2ascii/Native2AsciiTest.java +++ b/src/test/java/org/codehaus/mojo/native2ascii/Native2AsciiTest.java @@ -1,5 +1,6 @@ /* * The MIT License + * Copyright (c) 2014-2022 MojoHaus * Copyright (c) 2007 The Codehaus * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -16,25 +17,25 @@ */ package org.codehaus.mojo.native2ascii; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.maven.plugin.logging.SystemStreamLog; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Native2AsciiTest { - final Native2Ascii native2Ascii = new Native2Ascii(new SystemStreamLog()); + private final Native2Ascii native2Ascii = new Native2Ascii(new SystemStreamLog()); @Test public void test() { - assertEquals(null, native2Ascii.nativeToAscii(null)); - assertEquals("~", native2Ascii.nativeToAscii("~")); - assertEquals("\\u007F", native2Ascii.nativeToAscii("")); + assertEquals(null, this.native2Ascii.nativeToAscii(null)); + assertEquals("~", this.native2Ascii.nativeToAscii("~")); + assertEquals("\\u007F", this.native2Ascii.nativeToAscii("")); // chinese character is random since I don't understand it - assertEquals("\\u7C97", native2Ascii.nativeToAscii("粗")); + assertEquals("\\u7C97", this.native2Ascii.nativeToAscii("粗")); assertEquals("\\u0158\\u00EDze\\u010Dek ut\\u00EDk\\u00E1 a \\u0159e\\u017Ee zat\\u00E1\\u010Dky! \\u00A7", - native2Ascii.nativeToAscii("Řízeček utíká a řeže zatáčky! §")); + this.native2Ascii.nativeToAscii("Řízeček utíká a řeže zatáčky! §")); } } diff --git a/src/test/java/org/codehaus/mojo/native2ascii/mojo/Native2AsciiMojoTest.java b/src/test/java/org/codehaus/mojo/native2ascii/mojo/Native2AsciiMojoTest.java index 8ec9e97..d2f98dd 100644 --- a/src/test/java/org/codehaus/mojo/native2ascii/mojo/Native2AsciiMojoTest.java +++ b/src/test/java/org/codehaus/mojo/native2ascii/mojo/Native2AsciiMojoTest.java @@ -1,5 +1,6 @@ /* * The MIT License + * Copyright (c) 2014-2022 MojoHaus * Copyright (c) 2007 The Codehaus * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -16,9 +17,9 @@ */ package org.codehaus.mojo.native2ascii.mojo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.FileInputStream; @@ -26,7 +27,7 @@ import java.net.URISyntaxException; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author David Matějček @@ -65,7 +66,7 @@ public void testSubdirectories() throws Exception { mojo.execute(); final File file = new File(mojo.targetDir.getCanonicalPath() + File.separator + "subdirs/x2/x3/sub.properties"); - assertTrue("file does not exist: " + file, file.exists()); + assertTrue(file.exists(), "file does not exist: " + file); final Properties properties = loadFile(file); assertEquals("šílené!", properties.get("crazy")); }