Skip to content

Commit

Permalink
Merge pull request #10 from mojohaus/updates
Browse files Browse the repository at this point in the history
Updates of dependencies
  • Loading branch information
dmatej authored Jul 13, 2022
2 parents 3a36216 + 5187ee4 commit 76be97b
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 49 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# 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

# Howto

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.
51 changes: 35 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Native2Ascii Maven Plugin</name>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mojo-parent</artifactId>
<version>40</version>
<version>69</version>
</parent>

<url>https://github.com/mojohaus/native2ascii-maven-plugin/wiki</url>
Expand All @@ -32,7 +32,7 @@
<developer>
<id>dmatej</id>
<name>David Matějček</name>
<email>[email protected]</email>
<email>[email protected]</email>
<timezone>+1</timezone>
<roles>
<role>Developer</role>
Expand Down Expand Up @@ -73,7 +73,7 @@
<tag>HEAD</tag>
</scm>
<issueManagement>
<system>JIRA</system>
<system>GitHub</system>
<url>https://github.com/mojohaus/native2ascii/issues</url>
</issueManagement>
<distributionManagement>
Expand All @@ -87,46 +87,66 @@
</snapshotRepository>
</distributionManagement>
<ciManagement>
<system>TravisCI</system>
<url>https://travis-ci.org/mojohaus/native2ascii-maven-plugin</url>
<system>GitHub</system>
<url>https://github.com/mojohaus/native2ascii-maven-plugin/actions</url>
</ciManagement>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.5.0</version>
<version>3.8.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.5</version>
<version>3.6.4</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.velocity</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.5</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
Expand All @@ -143,7 +163,6 @@
<!-- To run with different Maven versions use -Dinvoker.mavenHome -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<debug>false</debug>
<projectsDirectory>src/it</projectsDirectory>
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -53,6 +54,7 @@ public abstract class AbstractNative2AsciiMojo extends AbstractMojo {
public String[] excludes;


@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
if (!checkParameters()) {
return;
Expand Down Expand Up @@ -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;
}
Expand All @@ -104,15 +106,14 @@ protected boolean checkParameters() {
private Iterator<File> 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<File> 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");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/site/apt/index.apt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Introduction
------
David Matejcek
<[email protected]>
<[email protected]>
------
2017-12-23
------
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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! §"));
}

}
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -16,17 +17,17 @@
*/
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;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Properties;

import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* @author David Matějček
Expand Down Expand Up @@ -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"));
}
Expand Down

0 comments on commit 76be97b

Please sign in to comment.