Skip to content

Commit

Permalink
Require minimum Java 8 and Maven 3.3.9 (#50)
Browse files Browse the repository at this point in the history
Fixes #49

* Java 8 or later is required to build and run the plugin
* Java 8 or later is required to run the integration tests
* Maven 3.3.9 or later is required to run the plugin
* Updated Maven plugins and dependencies to the latest version
* Removed reflection-based workaround to support Maven 3.2 and earlier
* Cleaned up the code for Java 8
* Cleaned up CI configuration and toolchains
  • Loading branch information
sergei-ivanov authored Jan 8, 2019
1 parent 5e5b706 commit 7d9e20a
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 127 deletions.
11 changes: 0 additions & 11 deletions .appveyor/toolchains.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@
<jdkHome>C:/Program Files/Java/jdk1.8.0</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
<vendor>OpenJDK</vendor>
<id>openjdk6</id>
</provides>
<configuration>
<jdkHome>C:/Program Files/Java/jdk1.6.0</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>protobuf</type>
<provides>
Expand Down
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ dist: trusty
sudo: false

language: java
addons:
apt:
packages:
- openjdk-6-jdk
jdk: openjdk8

before_install:
Expand Down
11 changes: 0 additions & 11 deletions .travis/toolchains.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@
<jdkHome>/usr/lib/jvm/java-8-openjdk-amd64</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
<vendor>OpenJDK</vendor>
<id>openjdk6</id>
</provides>
<configuration>
<jdkHome>/usr/lib/jvm/java-6-openjdk-amd64</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>protobuf</type>
<provides>
Expand Down
52 changes: 31 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- JDK version -->
<java.sdk.version>1.6</java.sdk.version>
<java.sdk.version>1.8</java.sdk.version>
<!-- Settings for the java compiler -->
<java.compiler.compilerVersion>${java.sdk.version}</java.compiler.compilerVersion>
<java.compiler.source>${java.sdk.version}</java.compiler.source>
<java.compiler.target>${java.sdk.version}</java.compiler.target>

<mavenVersion>3.0</mavenVersion>
<mavenVersion>3.3.9</mavenVersion>
<plexusComponentVersion>1.7.1</plexusComponentVersion>
<plexusUtilsVersion>3.1.0</plexusUtilsVersion>
<pluginToolsVersion>3.5.2</pluginToolsVersion>
<plexusUtilsVersion>3.1.1</plexusUtilsVersion>
<pluginToolsVersion>3.6.0</pluginToolsVersion>

<goalPrefix>protobuf</goalPrefix>
</properties>
Expand Down Expand Up @@ -109,6 +109,12 @@
<pluginManagement>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
Expand All @@ -124,7 +130,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.5.2</version>
<version>3.6.0</version>
</plugin>

<plugin>
Expand All @@ -148,7 +154,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<version>3.0.0-M3</version>
</plugin>

<plugin>
Expand All @@ -166,7 +172,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</plugin>

<plugin>
Expand Down Expand Up @@ -200,6 +206,12 @@
<version>0.12</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
Expand All @@ -209,7 +221,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<version>3.0.0-M1</version>
</plugin>

</plugins>
Expand Down Expand Up @@ -456,7 +468,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.5.2</version>
<version>3.6.0</version>
<configuration>
<mojoDependencies />
<goalPrefix>${goalPrefix}</goalPrefix>
Expand Down Expand Up @@ -613,18 +625,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<!--
Explicitly disable updating the release metadata in the remote repository,
because otherwise that messes BinTray repository layout up.
BinTray itself takes care of metadata when the artifacts are promoted.
-->
<updateReleaseInfo>false</updateReleaseInfo>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Expand All @@ -650,6 +650,12 @@
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>${pluginToolsVersion}</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down Expand Up @@ -685,6 +691,10 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<body>

<release version="0.7.0" date="Pending" description="TBD">
<action dev="sergei-ivanov" type="update" issue="49">
Java 1.8 and Maven 3.3.9 are now minimum required versions for running the plugin.
</action>
<action dev="sergei-ivanov" type="update" issue="47" due-to="Cosmin Lehene (clehene)">
More detailed error message.
</action>
Expand Down
4 changes: 2 additions & 2 deletions src/it/dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<version>3.0.0-M3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
8 changes: 4 additions & 4 deletions src/it/setup-it-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- JDK version -->
<java.sdk.version>1.6</java.sdk.version>
<java.sdk.version>1.8</java.sdk.version>
<!-- Settings for the java compiler -->
<java.compiler.compilerVersion>${java.sdk.version}</java.compiler.compilerVersion>
<java.compiler.source>${java.sdk.version}</java.compiler.source>
<java.compiler.target>${java.sdk.version}</java.compiler.target>

<mavenVersion>3.0</mavenVersion>
<mavenVersion>3.3.9</mavenVersion>

<protobufVersion>3.6.1</protobufVersion>
</properties>
Expand Down Expand Up @@ -82,13 +82,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<version>3.0.0-M3</version>
<inherited>true</inherited>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<inherited>true</inherited>
</plugin>
<plugin>
Expand Down
4 changes: 2 additions & 2 deletions src/it/setup-protoc-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- JDK version -->
<java.sdk.version>1.6</java.sdk.version>
<java.sdk.version>1.8</java.sdk.version>
<!-- Settings for the java compiler -->
<java.compiler.compilerVersion>${java.sdk.version}</java.compiler.compilerVersion>
<java.compiler.source>${java.sdk.version}</java.compiler.source>
Expand Down Expand Up @@ -71,7 +71,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ protected List<File> getDependencyArtifactFiles() {
if (dependencyArtifacts.isEmpty()) {
return emptyList();
}
final List<File> dependencyArtifactFiles = new ArrayList<File>(dependencyArtifacts.size());
final List<File> dependencyArtifactFiles = new ArrayList<>(dependencyArtifacts.size());
for (final Artifact artifact : dependencyArtifacts) {
dependencyArtifactFiles.add(artifact.getFile());
}
Expand Down Expand Up @@ -904,7 +904,7 @@ protected List<File> makeProtoPathFromJars(
throw new MojoInitializationException("Unable to clean up temporary proto file directory", e);
}
}
final List<File> protoDirectories = new ArrayList<File>();
final List<File> protoDirectories = new ArrayList<>();
for (final File classpathElementFile : classpathElementFiles) {
// for some reason under IAM, we receive poms as dependent files
// I am excluding .xml rather than including .jar as there may be other extensions in use (sar, har, zip)
Expand Down Expand Up @@ -986,7 +986,7 @@ protected List<File> findProtoFilesInDirectories(final Iterable<File> directorie
if (directories == null) {
throw new MojoConfigurationException("'directories' is null");
}
final List<File> protoFiles = new ArrayList<File>();
final List<File> protoFiles = new ArrayList<>();
for (final File directory : directories) {
protoFiles.addAll(findProtoFilesInDirectory(directory));
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/xolstice/maven/plugin/protobuf/Protoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public int execute(final Log log) throws CommandLineException, InterruptedExcept
* @return A list consisting of the executable followed by any arguments.
*/
public List<String> buildProtocCommand() {
final List<String> command = new ArrayList<String>();
final List<String> command = new ArrayList<>();
// add the executable
for (final File protoPathElement : protoPathElements) {
command.add("--proto_path=" + protoPathElement);
Expand Down Expand Up @@ -433,7 +433,7 @@ private static String fixUnicodeOutput(final String message) {
* @return the temporary file wth the arguments
* @throws IOException
*/
private File createFileWithArguments(String[] args) throws IOException {
private File createFileWithArguments(String... args) throws IOException {
PrintWriter writer = null;
try {
final File tempFile = File.createTempFile("protoc", null, tempDirectory);
Expand Down Expand Up @@ -536,9 +536,9 @@ static final class Builder {
throw new MojoConfigurationException("'executable' is null");
}
this.executable = executable;
protoFiles = new ArrayList<File>();
protopathElements = new LinkedHashSet<File>();
plugins = new ArrayList<ProtocPlugin>();
protoFiles = new ArrayList<>();
protopathElements = new LinkedHashSet<>();
plugins = new ArrayList<>();
}

public Builder setTempDirectory(final File tempDirectory) {
Expand Down Expand Up @@ -888,7 +888,7 @@ public Protoc build() {
validateState();
return new Protoc(
executable,
new ArrayList<File>(protopathElements),
new ArrayList<>(protopathElements),
protoFiles,
javaOutputDirectory,
javaNanoOutputDirectory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
import org.codehaus.plexus.util.Os;

import java.io.File;
import java.util.Collections;
import java.util.List;

import static java.util.Collections.emptyList;

/**
* Describes a {@code protoc} plugin that is written in Java and
* assembled from resolved artifacts at runtime.
Expand Down Expand Up @@ -123,7 +124,7 @@ public String getMainClass() {
* @return a list of command-line arguments.
*/
public List<String> getArgs() {
return (args != null) ? args : Collections.<String>emptyList();
return args != null ? args : emptyList();
}

/**
Expand All @@ -132,7 +133,7 @@ public List<String> getArgs() {
* @return a list of JVM options.
*/
public List<String> getJvmArgs() {
return (jvmArgs != null) ? jvmArgs : Collections.<String>emptyList();
return jvmArgs != null ? jvmArgs : emptyList();
}

public String getJavaHome() {
Expand Down
Loading

0 comments on commit 7d9e20a

Please sign in to comment.