This is an automated email from the ASF dual-hosted git repository. mwalch pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/accumulo-maven-plugin.git
The following commit(s) were added to refs/heads/master by this push: new cc3c8f8 Fix #2 - Maven plugin uses non public Accumulo API (#3) cc3c8f8 is described below commit cc3c8f83c49a8308d29f47056124243c46ffef13 Author: Mike Walch <mwa...@apache.org> AuthorDate: Sun Feb 17 11:19:23 2019 -0500 Fix #2 - Maven plugin uses non public Accumulo API (#3) --- contrib/import-control.xml | 29 ++++++++++++++++++++++ pom.xml | 6 ++++- .../maven/plugin/AbstractAccumuloMojo.java | 13 +++------- .../apache/accumulo/maven/plugin/StartMojo.java | 14 ++++------- .../org/apache/accumulo/maven/plugin/StopMojo.java | 3 +-- 5 files changed, 44 insertions(+), 21 deletions(-) diff --git a/contrib/import-control.xml b/contrib/import-control.xml new file mode 100644 index 0000000..5cfd06c --- /dev/null +++ b/contrib/import-control.xml @@ -0,0 +1,29 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!DOCTYPE import-control PUBLIC + "-//Checkstyle//DTD ImportControl Configuration 1.4//EN" + "https://checkstyle.org/dtds/import_control_1_4.dtd"> + +<!-- This checkstyle rule is configured to ensure only use of Accumulo API --> +<import-control pkg="org.apache.accumulo.maven.plugin" strategyOnMismatch="allowed"> + <!-- allow this package --> + <allow pkg="org.apache.accumulo.maven.plugin"/> + <!-- allow accumulo public API packages. only packages that are used are included below --> + <allow pkg="org.apache.accumulo.minicluster"/> + + <!-- disallow everything else coming from accumulo --> + <disallow pkg="org.apache.accumulo"/> +</import-control> diff --git a/pom.xml b/pom.xml index 5c14f61..4d48065 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ <url>https://travis-ci.org/apache/accumulo-maven-plugin</url> </ciManagement> <properties> - <accumulo.version>2.0.0-alpha-2</accumulo.version> + <accumulo.version>2.0.0-SNAPSHOT</accumulo.version> <eclipseFormatterStyle>contrib/Eclipse-Accumulo-Codestyle.xml</eclipseFormatterStyle> <!-- extra release args for testing --> <extraReleaseArguments /> @@ -395,6 +395,10 @@ <module name="SingleLineJavadoc" /> <module name="MissingOverrideCheck" /> <module name="AnnotationLocation" /> + <!--check that only Accumulo public APIs are imported--> + <module name="ImportControl"> + <property name="file" value="contrib/import-control.xml" /> + </module> </module> </module> </checkstyleRules> diff --git a/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java b/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java index 5e192a7..c5f140b 100644 --- a/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java +++ b/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java @@ -16,12 +16,10 @@ */ package org.apache.accumulo.maven.plugin; -import java.io.File; import java.net.MalformedURLException; import java.util.ArrayList; -import java.util.Arrays; -import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; +import org.apache.accumulo.minicluster.MiniAccumuloConfig; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugins.annotations.Parameter; @@ -42,17 +40,14 @@ public abstract class AbstractAccumuloMojo extends AbstractMojo { return skip; } - void configureMiniClasspath(MiniAccumuloConfigImpl macConfig, String miniClasspath) - throws MalformedURLException { + void configureMiniClasspath(MiniAccumuloConfig macConfig) throws MalformedURLException { ArrayList<String> classpathItems = new ArrayList<>(); - if (miniClasspath == null && project != null) { + if (project != null) { classpathItems.add(project.getBuild().getOutputDirectory()); classpathItems.add(project.getBuild().getTestOutputDirectory()); for (Artifact artifact : project.getArtifacts()) { classpathItems.add(artifact.getFile().toURI().toURL().toString()); } - } else if (miniClasspath != null && !miniClasspath.isEmpty()) { - classpathItems.addAll(Arrays.asList(miniClasspath.split(File.pathSeparator))); } // Hack to prevent sisu-guava, a maven 3.0.4 dependency, from effecting normal accumulo @@ -65,6 +60,6 @@ public abstract class AbstractAccumuloMojo extends AbstractMojo { if (sisuGuava != null) classpathItems.remove(sisuGuava); - macConfig.setClasspathItems(classpathItems.toArray(new String[classpathItems.size()])); + macConfig.setClasspath(classpathItems.toArray(new String[classpathItems.size()])); } } diff --git a/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java b/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java index 56d8ddf..c8e872d 100644 --- a/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java +++ b/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java @@ -23,8 +23,7 @@ import java.util.HashSet; import java.util.Set; import org.apache.accumulo.minicluster.MiniAccumuloCluster; -import org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl; -import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; +import org.apache.accumulo.minicluster.MiniAccumuloConfig; import org.apache.commons.io.FileUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -57,8 +56,7 @@ public class StartMojo extends AbstractAccumuloMojo { required = true) private int zooKeeperPort; - static Set<MiniAccumuloClusterImpl> runningClusters = Collections - .synchronizedSet(new HashSet<>()); + static Set<MiniAccumuloCluster> runningClusters = Collections.synchronizedSet(new HashSet<>()); @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "could restrict outputDirectory to target/ in future") @@ -79,11 +77,11 @@ public class StartMojo extends AbstractAccumuloMojo { FileUtils.forceDelete(subdir); if (!subdir.mkdirs() && !subdir.isDirectory()) throw new MojoExecutionException(subdir + " cannot be created as a directory"); - MiniAccumuloConfigImpl cfg = new MiniAccumuloConfigImpl(subdir, rootPassword); + MiniAccumuloConfig cfg = new MiniAccumuloConfig(subdir, rootPassword); cfg.setInstanceName(instanceName); cfg.setZooKeeperPort(zooKeeperPort); - configureMiniClasspath(cfg, null); - MiniAccumuloClusterImpl mac = new MiniAccumuloClusterImpl(cfg); + configureMiniClasspath(cfg); + MiniAccumuloCluster mac = new MiniAccumuloCluster(cfg); getLog().info("Starting MiniAccumuloCluster: " + mac.getInstanceName() + " in " + mac.getConfig().getDir()); mac.start(); @@ -92,7 +90,5 @@ public class StartMojo extends AbstractAccumuloMojo { throw new MojoExecutionException( "Unable to start " + MiniAccumuloCluster.class.getSimpleName(), e); } - } - } diff --git a/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java b/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java index 2025836..00c4fdc 100644 --- a/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java +++ b/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java @@ -17,7 +17,6 @@ package org.apache.accumulo.maven.plugin; import org.apache.accumulo.minicluster.MiniAccumuloCluster; -import org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -36,7 +35,7 @@ public class StopMojo extends AbstractAccumuloMojo { return; } - for (MiniAccumuloClusterImpl mac : StartMojo.runningClusters) { + for (MiniAccumuloCluster mac : StartMojo.runningClusters) { getLog().info("Stopping MiniAccumuloCluster: " + mac.getInstanceName()); try { mac.stop();