Skip to content
Permalink
Browse files
FLUME-3280 Improve maven build to help code reviews by adding static …
…code analyzer

Adding spotbugs, pmd to the build.
moving flume-checkstyle to a new build-support module that contains
any future build tool configuration.

Fixed some trivial checkstyle issues.

Updated apache parent version and maven plugin versions.
Added maxAllowedViolations so this commit could contain only the new checks
and not any code change.

Did some cleanup in the pom files.

This closes #232

Reviewers: Peter Turcsanyi, Endre Major

(Ferenc Szabo via Ferenc Szabo)
  • Loading branch information
szaboferee committed Nov 8, 2018
1 parent 493b53b commit fb16ffc076de9917be7585e5583344bf3fd1c62a
Showing 101 changed files with 1,030 additions and 579 deletions.
@@ -18,3 +18,4 @@ derby.log
*.iml
nb-configuration.xml
.DS_Store
/.mvn/wrapper/maven-wrapper.jar
@@ -0,0 +1,110 @@
/*
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.
*/

import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
@@ -0,0 +1 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
@@ -23,4 +23,4 @@ before_install:
install:
- # Skip mvn install. See https://docs.travis-ci.com/user/languages/java/
script:
- MAVEN_OPTS="-Xms512m -Xmx1024m" mvn clean install -DskipTests -B
- MAVEN_OPTS="-Xms512m -Xmx1024m" ./mvnw clean install -DskipTests -B -fae
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.flume</groupId>
<artifactId>build-support</artifactId>
<version>1.9.0-SNAPSHOT</version>
<name>Build Support</name>
<description>Build tools and Configuration</description>
<properties>
<maven.site.skip>true</maven.site.skip>
</properties>
</project>
@@ -19,8 +19,8 @@ under the License.
-->

<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
@@ -45,6 +45,11 @@ under the License.
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<!-- Suppress generated sources -->
<module name="SuppressionFilter">
<property name="file" value="${checkstyle.suppressions.file}"/>
<property name="optional" value="false"/>
</module>

<module name="TreeWalker">
<module name="OuterTypeFilename"/>
@@ -74,13 +79,10 @@ under the License.
<module name="NeedBraces">
<property name="allowSingleLineStatement" value="true"/>
</module>
<module name="LeftCurly">
<property name="maxLineLength" value="100"/>
</module>
<module name="RightCurly"/>
<module name="LeftCurly"/>
<module name="RightCurly">
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
@@ -192,5 +194,7 @@ under the License.
<module name="CommentsIndentation">
<property name="tokens" value="BLOCK_COMMENT_BEGIN"/>
</module>
<module name="UnusedImports"/>
<module name="RedundantImport"/>
</module>
</module>

This file was deleted.

@@ -28,20 +28,11 @@ limitations under the License.
<name>Flume Auth</name>
<description>Flume Authentication</description>

<build>
<plugins>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<inherited>true</inherited>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<properties>
<!-- TODO fix spotbugs/pmd violations -->
<spotbugs.maxAllowedViolations>1</spotbugs.maxAllowedViolations>
<pmd.maxAllowedViolations>7</pmd.maxAllowedViolations>
</properties>

<dependencies>

@@ -90,18 +81,13 @@ limitations under the License.
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-minikdc</artifactId>
<version>${hadoop2.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- add this to satisfy the dependency requirement of apacheds-jdbm1 in minikdc-->
<groupId>org.apache.directory.jdbm</groupId>
<artifactId>apacheds-jdbm1</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
@@ -31,14 +31,11 @@
<artifactId>flume-file-channel</artifactId>
<name>Flume NG file-based channel</name>

<build>
<plugins>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
</plugin>
</plugins>
</build>
<properties>
<!-- TODO fix spotbugs violations -->
<spotbugs.maxAllowedViolations>86</spotbugs.maxAllowedViolations>
<pmd.maxAllowedViolations>486</pmd.maxAllowedViolations>
</properties>

<dependencies>

@@ -640,7 +640,7 @@ FlumeEvent get(FlumeEventPointer pointer) throws IOException,
*
* @param transactionID
* @param event
* @return
* @return FlumeEventPointer
* @throws IOException
*/
FlumeEventPointer put(long transactionID, Event event)
@@ -97,7 +97,7 @@ static class Writer extends LogFile.Writer {
long usableSpaceRefreshInterval)
throws IOException {
super(file, logFileID, maxFileSize, null, usableSpaceRefreshInterval,
true, 0);
true, 0);
RandomAccessFile writeFileHandle = getFileHandle();
writeFileHandle.writeInt(getVersion());
writeFileHandle.writeInt(logFileID);
@@ -18,7 +18,6 @@
*/
package org.apache.flume.channel.file.instrumentation;

import org.apache.flume.Event;
import org.apache.flume.instrumentation.ChannelCounterMBean;

public interface FileChannelCounterMBean extends ChannelCounterMBean {
@@ -45,7 +44,8 @@ public interface FileChannelCounterMBean extends ChannelCounterMBean {

/**
* A count of the number of IOExceptions encountered while trying to put() onto the channel.
* @see org.apache.flume.channel.file.FileChannel.FileBackedTransaction#doPut(Event)
* @see org.apache.flume.channel.file.FileChannel.FileBackedTransaction
#doPut(org.apache.flume.Event)
*/
long getEventPutErrorCount();

@@ -30,21 +30,11 @@ limitations under the License.
<artifactId>flume-jdbc-channel</artifactId>
<name>Flume NG JDBC channel</name>

<build>
<plugins>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<!-- TODO fix spotbugs/pmd violations -->
<spotbugs.maxAllowedViolations>31</spotbugs.maxAllowedViolations>
<pmd.maxAllowedViolations>16</pmd.maxAllowedViolations>
</properties>

<dependencies>
<dependency>
@@ -28,6 +28,12 @@ limitations under the License.
<groupId>org.apache.flume.flume-ng-channels</groupId>
<artifactId>flume-kafka-channel</artifactId>

<properties>
<!-- TODO fix spotbugs/pmd violations -->
<spotbugs.maxAllowedViolations>13</spotbugs.maxAllowedViolations>
<pmd.maxAllowedViolations>13</pmd.maxAllowedViolations>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.flume</groupId>

0 comments on commit fb16ffc

Please sign in to comment.