diff --git a/.editorconfig b/.editorconfig index c612eb61..3cd30306 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,3 +11,6 @@ charset = utf-8 indent_style = space indent_size = 4 max_line_length=120 + +[*.gradle] +indent_size = 2 diff --git a/.gitignore b/.gitignore index 44342e67..293e99e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +/build +*/build/ /target/ /parser/target/ /benchmarking/target/ @@ -31,7 +33,6 @@ broker/runner .mtj.tmp/ # Package Files # -*.jar *.war *.ear @@ -43,3 +44,4 @@ broker/nb-configuration.xml broker/nbactions-Server.xml maven-metadata.xml +/.gradle/ diff --git a/.travis.yml b/.travis.yml index 9bcf9994..49d4be0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,13 @@ language: java jdk: - oraclejdk8 +before_cache: + - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock + - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ +cache: + directories: + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ + +script: + - ./gradlew install test diff --git a/README.md b/README.md index 151b0030..aa3ee94a 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Include dependency in your project: ## Build from sources -After a git clone of the repository, cd into the cloned sources and: `mvn clean package`. -In distribution/target directory will be produced the selfcontained tar for the broker with all dependencies and a running script. +After a git clone of the repository, cd into the cloned sources and: `./gradlew clean distribution:distMoquetteTar` or +`./gradlew clean distribution:distMoquetteZip`. +In distribution/build directory will be produced the selfcontained file for the broker with all dependencies and a running script. diff --git a/broker/build.gradle b/broker/build.gradle new file mode 100644 index 00000000..b3abbff5 --- /dev/null +++ b/broker/build.gradle @@ -0,0 +1,51 @@ + +description = 'Moquette - broker' + +apply plugin: 'osgi' +apply plugin: 'maven' + +dependencies { + compile group: 'io.netty', name: 'netty-common', version: nettyVersion + compile group: 'io.netty', name: 'netty-buffer', version: nettyVersion + compile group: 'io.netty', name: 'netty-transport', version: nettyVersion + compile group: 'io.netty', name: 'netty-handler', version: nettyVersion + compile group: 'io.netty', name: 'netty-codec', version: nettyVersion + compile group: 'io.netty', name: 'netty-codec-http', version: nettyVersion + compile group: 'io.netty', name: 'netty-codec-mqtt', version: nettyVersion + + compile group: 'io.netty', name: 'netty-transport-native-epoll', version: nettyVersion, classifier: 'linux-x86_64' + // ${os.detected.name}-${os.detected.arch} + + compile group: 'io.dropwizard.metrics', name: 'metrics-core', version:'3.2.2' + compile group: 'io.dropwizard.metrics', name: 'metrics-jvm', version:'3.2.2' + + compile group: 'com.librato.metrics', name: 'metrics-librato', version:'5.1.0' + compile group: 'com.librato.metrics', name: 'librato-java' , version:'2.1.0' + compile group: 'com.bugsnag', name: 'bugsnag', version:'[3.0,4.0)' + + compile group: 'commons-codec', name: 'commons-codec', version:'1.10' + // compile group: 'org.hdrhistogram', name: 'HdrHistogram', version:'2.1.4' + compile group: 'com.hazelcast', name: 'hazelcast', version:'3.5.4' + + testCompile group: 'org.fusesource.mqtt-client', name: 'mqtt-client', version:'1.12' + testCompile group: 'org.eclipse.paho', name: 'org.eclipse.paho.client.mqttv3', version:'1.0.2' + testCompile group: 'org.eclipse.jetty.websocket', name: 'websocket-client', version:'9.2.0.M1' + + testCompile group: 'com.h2database', name: 'h2', version:'1.4.191' +} + +task createPom () { + pom { }.writeTo("build/pom.xml") +} + +jar { + manifest { + instruction 'Bundle-Description', 'Moquette lightweight MQTT Broker' + instruction 'Bundle-License', 'http://www.apache.org/licenses/LICENSE-2.0.txt, http://www.eclipse.org/org/documents/epl-v10.php' + instruction 'Import-Package', '!com.codahale.metrics*, !com.bugsnag*, !com.librato.metrics*, *' + } + into ("META-INF/maven/io.moquette/${project.name}"){ + from "build/pom.xml" + } +} +jar.dependsOn createPom diff --git a/broker/pom.xml b/broker/pom.xml deleted file mode 100644 index 6d8ee53b..00000000 --- a/broker/pom.xml +++ /dev/null @@ -1,282 +0,0 @@ - - 4.0.0 - - ../ - moquette-parent - io.moquette - 0.11-SNAPSHOT - - - moquette-broker - jar - Moquette - broker - - - UTF-8 - io.moquette.moquette-broker - - - - - - - - - - - - org.slf4j - slf4j-api - 1.7.5 - - - - io.netty - netty-common - ${netty.version} - - - - io.netty - netty-buffer - ${netty.version} - - - - io.netty - netty-transport - ${netty.version} - - - - io.netty - netty-handler - ${netty.version} - - - - io.netty - netty-codec - ${netty.version} - - - - io.netty - netty-codec-http - ${netty.version} - - - - io.netty - netty-codec-mqtt - ${netty.version} - - - - io.netty - netty-transport-native-epoll - ${netty.version} - linux-x86_64 - - - - - io.dropwizard.metrics - metrics-core - 3.2.2 - - - io.dropwizard.metrics - metrics-jvm - 3.2.2 - - - - com.librato.metrics - metrics-librato - 5.1.0 - - - - com.librato.metrics - librato-java - 2.1.0 - - - - com.bugsnag - bugsnag - [3.0,4.0) - - - - commons-codec - commons-codec - 1.10 - - - - - - - - - - com.hazelcast - hazelcast - 3.5.4 - - - - - junit - junit - 4.8.2 - test - - - - org.slf4j - slf4j-log4j12 - 1.7.5 - test - - - - - org.mockito - mockito-core - 1.9.0 - test - - - - org.fusesource.mqtt-client - mqtt-client - 1.12 - test - - - - org.eclipse.paho - org.eclipse.paho.client.mqttv3 - 1.0.2 - test - - - - org.eclipse.jetty.websocket - websocket-client - 9.2.0.M1 - test - - - - org.assertj - assertj-core - - 2.6.0 - test - - - - org.awaitility - awaitility - 3.0.0 - test - - - - com.h2database - h2 - 1.4.191 - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - PARANOID - - - **/*Test.java - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - - test-jar - - - - - - - - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - test-jar - - - - - - org.apache.felix - maven-bundle-plugin - - - bundle-manifest - process-classes - - manifest - - - - - - - io.moquette.persistence, - io.moquette.server.config, - io.moquette.spi, - io.moquette.spi.impl.subscriptions, - - - com.bugsnag;bugsnag, - com.librato.metrics;metrics-librato, - com.librato.metrics;librato-java, - - - - - - - - - - bintray - https://api.bintray.com/maven/${bintray.repo}/${bintray.package} - - - diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..4f734260 --- /dev/null +++ b/build.gradle @@ -0,0 +1,89 @@ +allprojects { + apply plugin: 'maven' + + group = 'io.moquette' + version = '0.11-SNAPSHOT' +} + +buildscript { + repositories { + maven { + url "https://plugins.gradle.org/m2/" + } + } + dependencies { + classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.8' + classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' + } +} + +subprojects { + + repositories { + mavenLocal() + + maven { url "https://repo.eclipse.org/content/repositories/paho-releases/" } + maven { url "https://oss.sonatype.org/content/repositories/snapshots" } + maven { url "http://repo.maven.apache.org/maven2" } + } + + apply from: new File(rootDir, 'gradle/java.gradle') + apply from: new File(rootDir, 'gradle/test.gradle') + apply from: new File(rootDir, 'gradle/lint.gradle') + apply plugin: 'com.jfrog.bintray' + apply plugin: 'eclipse' + apply plugin: 'net.ltgt.errorprone' + configurations.errorprone { + resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.14' + } + + ext { + nettyVersion = '4.1.12.Final' + } + + task packageTests(type: Jar) { + from sourceSets.test.output + from sourceSets.test.allSource + from sourceSets.test.resources + classifier = 'tests' + } + artifacts.archives packageTests + + dependencies { + compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.5' + + testCompile group: 'junit', name: 'junit', version:'4.8.2' + testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version:'1.7.5' + testCompile group: 'org.assertj', name: 'assertj-core', version:'2.6.0' + testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0' + testCompile group: 'org.awaitility', name: 'awaitility', version: '3.0.0' + + } + + test { + systemProperties.put "moquette.path", "build/resources/test/" + systemProperties.put "io.netty.leakDetectionLevel", "paranoid" + testLogging { + exceptionFormat 'full' + events "passed", "skipped", "failed" + } + } + + // Deploy set environment variables and run ./gradlew bintrayUpload + bintray { + user = System.getenv('BINTRAY_USER') + key = System.getenv('BINTRAY_KEY') + pkg { + repo = '${project.group}' + name = "${project.name}" + userOrg = 'andsel' + licenses = ['Apache-2.0'] + vcsUrl = "https://api.bintray.com/maven/andsel/maven/${project.group}.${project.name}" + } + } +} + +task wrapper(type: Wrapper) { + gradleVersion = '3.3' +} diff --git a/distribution/build.gradle b/distribution/build.gradle new file mode 100644 index 00000000..d91bb071 --- /dev/null +++ b/distribution/build.gradle @@ -0,0 +1,63 @@ + +description = 'Moquette - distribution' + +apply plugin: 'application' + +// adds task shadowJar - Create a combined JAR of project and runtime dependencies +apply plugin: 'com.github.johnrengelman.shadow' + +mainClassName = "io.moquette.server.Server" + +dependencies { + compile project(':moquette-broker') + compile project(':moquette-h2-storage') + compile project(':moquette-mapdb-storage') +} + +def packageSet = project.copySpec { + from 'src/main/resources/README.txt' + + into ('bin'){ + from 'src/main/scripts/' + fileMode=0755 + } + + into ('lib'){ + from "build/libs/${project.name}-${version}.jar" + rename { "moquette-${version}.jar" } + } + + into ('lib'){ + from configurations.compile + } + + into ('config'){ + from 'src/main/resources/moquette.conf' + from 'src/main/resources/password_file.conf' + from 'src/main/resources/hazelcast.xml' + // from 'src/main/resources/acl.conf' + } + + into ('config'){ + from 'src/main/resources/log4j.properties' + rename { 'moquette-log.properties' } + } +} + +task distMoquetteTar(type: Tar) { + archiveName = "moquette-${version}.tar" + destinationDir file('build') + extension 'tar' + compression = Compression.GZIP + + with packageSet +} +distMoquetteTar.dependsOn jar + +task distMoquetteZip(type: Zip) { + archiveName = "moquette-${version}.zip" + destinationDir file('build') + + with packageSet +} +distMoquetteZip.dependsOn jar diff --git a/distribution/pom.xml b/distribution/pom.xml deleted file mode 100644 index 91339957..00000000 --- a/distribution/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - 4.0.0 - - ../ - - moquette-parent - io.moquette - 0.11-SNAPSHOT - - - distribution - pom - Moquette - distribution - - - - - ${project.groupId} - moquette-broker - ${project.version} - - - - ${project.groupId} - moquette-h2-storage - ${project.version} - - - - ${project.groupId} - moquette-mapdb-storage - ${project.version} - - - - org.slf4j - slf4j-api - 1.7.5 - - - - org.slf4j - slf4j-log4j12 - 1.7.5 - runtime - - - - - - ${basedir}/src/main/ - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.4 - - - distribution-package - package - - single - - - - - ${basedir}/src/main/assembly/assembly.xml - - gnu - - - - - - - - - diff --git a/distribution/src/main/assembly/assembly.xml b/distribution/src/main/assembly/assembly.xml deleted file mode 100644 index 9a064d28..00000000 --- a/distribution/src/main/assembly/assembly.xml +++ /dev/null @@ -1,57 +0,0 @@ - - bundle-tar - - tar.gz - - - false - - - - - src/main/scripts/moquette.sh - bin - 0755 - - - - src/main/scripts/moquette.bat - bin - - - - src/main/resources/log4j.properties - config/ - moquette-log.properties - - - - src/main/resources/moquette.conf - config/ - - - - src/main/resources/password_file.conf - config/ - - - - src/main/resources/hazelcast.xml - config/ - - - - src/main/resources/README.txt - - - - - - - lib/ - true - - - diff --git a/embedding_moquette/build.gradle b/embedding_moquette/build.gradle new file mode 100644 index 00000000..2043131f --- /dev/null +++ b/embedding_moquette/build.gradle @@ -0,0 +1,5 @@ + +description = 'Moquette - Embedded test' +dependencies { + compile project(':moquette-broker') +} diff --git a/embedding_moquette/pom.xml b/embedding_moquette/pom.xml deleted file mode 100644 index cff2d82f..00000000 --- a/embedding_moquette/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - 4.0.0 - - ../ - moquette-parent - io.moquette - 0.11-SNAPSHOT - - - moquette-embedded-test - jar - Moquette - Embedded test - - - - io.moquette - moquette-broker - ${project.version} - - - - - - - - - - junit - junit - 4.8.2 - test - - - - - diff --git a/gradle/java.gradle b/gradle/java.gradle new file mode 100644 index 00000000..375ff2c1 --- /dev/null +++ b/gradle/java.gradle @@ -0,0 +1,9 @@ +apply plugin: 'java' +apply plugin: 'jacoco' + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} diff --git a/gradle/lint.gradle b/gradle/lint.gradle new file mode 100644 index 00000000..9b9fba57 --- /dev/null +++ b/gradle/lint.gradle @@ -0,0 +1,19 @@ +apply plugin: 'checkstyle' +apply plugin: 'findbugs' + +checkstyle { + configProperties.checkstyleConfigDir = "." + configFile = new File(rootDir, 'checkstyle.xml') + ignoreFailures false + toolVersion = '6.7' +} + +findbugs { + toolVersion = '3.0.1' + ignoreFailures true + omitVisitors = ['RuntimeExceptionCapture'] +} + +tasks.withType(FindBugs) { + maxHeapSize = '2g' +} diff --git a/gradle/test.gradle b/gradle/test.gradle new file mode 100644 index 00000000..c7670b40 --- /dev/null +++ b/gradle/test.gradle @@ -0,0 +1,62 @@ +test { + def outputReporter = new OutputReporter() + addTestListener(outputReporter) + addTestOutputListener(outputReporter) +} + +class OutputReporter implements TestListener, TestOutputListener { + + private StringBuilder stdout = new StringBuilder(); + private StringBuilder stderr = new StringBuilder(); + + @Override + void beforeSuite(TestDescriptor suite) { + + } + + @Override + void afterSuite(TestDescriptor suite, TestResult result) { + + } + + @Override + void beforeTest(TestDescriptor testDescriptor) { + if (!testDescriptor.isComposite()) { + stdout.setLength(0); + stderr.setLength(0); + } + } + + @Override + void afterTest(TestDescriptor testDescriptor, TestResult result) { + if (!testDescriptor.isComposite() && result.getResultType() == TestResult.ResultType.FAILURE) { + if (stdout.length() != 0) { + println "" + println "--- STDOUT ---" + print stdout + println "--- STDOUT ---" + } + + if (stderr.length() != 0) { + println "" + println "--- STDERR ---" + println stderr + println "--- STDERR ---" + } + + } + } + + @Override + void onOutput(TestDescriptor testDescriptor, TestOutputEvent outputEvent) { + if (!testDescriptor.isComposite()) { + def buffer = (outputEvent.getDestination() == TestOutputEvent.Destination.StdOut) ? stdout : stderr; + buffer.append(outputEvent.getMessage()); + if (outputEvent.getMessage().contains("LEAK:")) { + println stdout + println stderr + throw new RuntimeException("Netty ResourceLeakDetector"); + } + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..3baa851b Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..0118417b --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu Aug 10 18:13:58 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip diff --git a/gradlew b/gradlew new file mode 100755 index 00000000..27309d92 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..f6d5974e --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/h2_storage/build.gradle b/h2_storage/build.gradle new file mode 100644 index 00000000..f21f1bcf --- /dev/null +++ b/h2_storage/build.gradle @@ -0,0 +1,23 @@ + +description = 'Moquette - H2 storage' + +apply plugin: 'osgi' +apply plugin: 'maven' + +dependencies { + compile project(':moquette-broker') + compile group: 'com.h2database', name: 'h2-mvstore', version: '1.4.192' + + testCompile project(path:':moquette-broker', configuration: 'archives') +} + +task createPom () { + pom { }.writeTo("build/pom.xml") +} + +jar { + into ("META-INF/maven/io.moquette/${project.name}"){ + from "build/pom.xml" + } +} +jar.dependsOn createPom diff --git a/h2_storage/pom.xml b/h2_storage/pom.xml deleted file mode 100644 index a0c93031..00000000 --- a/h2_storage/pom.xml +++ /dev/null @@ -1,129 +0,0 @@ - - 4.0.0 - - ../ - moquette-parent - io.moquette - 0.11-SNAPSHOT - - - moquette-h2-storage - jar - Moquette - H2 storage - - - UTF-8 - io.moquette.moquette-h2-storage - - - - - ${project.groupId} - moquette-broker - ${project.version} - - - - org.slf4j - slf4j-api - 1.7.5 - - - - com.h2database - h2-mvstore - 1.4.192 - - - - - junit - junit - 4.8.2 - test - - - - org.slf4j - slf4j-log4j12 - 1.7.5 - test - - - - - org.mockito - mockito-core - 1.9.0 - test - - - - org.assertj - assertj-core - - 2.6.0 - test - - - - io.moquette - moquette-broker - test-jar - ${project.version} - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*Test.java - - - - - - - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - test-jar - - - - - - org.apache.felix - maven-bundle-plugin - - - bundle-manifest - process-classes - - manifest - - - - - - - - - - bintray - https://api.bintray.com/maven/${bintray.repo}/${bintray.package} - - - diff --git a/mapdb_storage/build.gradle b/mapdb_storage/build.gradle new file mode 100644 index 00000000..4e96fd9c --- /dev/null +++ b/mapdb_storage/build.gradle @@ -0,0 +1,23 @@ + +description = 'Moquette - MapDB storage' + +apply plugin: 'osgi' +apply plugin: 'maven' + +dependencies { + compile project(':moquette-broker') + compile group: 'org.mapdb', name: 'mapdb', version:'1.0.8' + + testCompile project(path:':moquette-broker', configuration: 'archives') +} + +task createPom () { + pom { }.writeTo("build/pom.xml") +} + +jar { + into ("META-INF/maven/io.moquette/${project.name}"){ + from "build/pom.xml" + } +} +jar.dependsOn createPom diff --git a/mapdb_storage/pom.xml b/mapdb_storage/pom.xml deleted file mode 100644 index e69849dd..00000000 --- a/mapdb_storage/pom.xml +++ /dev/null @@ -1,129 +0,0 @@ - - 4.0.0 - - ../ - moquette-parent - io.moquette - 0.11-SNAPSHOT - - - moquette-mapdb-storage - jar - Moquette - MapDB storage - - - UTF-8 - io.moquette.moquette-mapdb-storage - - - - - ${project.groupId} - moquette-broker - ${project.version} - - - - org.slf4j - slf4j-api - 1.7.5 - - - - org.mapdb - mapdb - 1.0.8 - - - - - junit - junit - 4.8.2 - test - - - - org.slf4j - slf4j-log4j12 - 1.7.5 - test - - - - - org.mockito - mockito-core - 1.9.0 - test - - - - org.assertj - assertj-core - - 2.6.0 - test - - - - io.moquette - moquette-broker - test-jar - ${project.version} - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*Test.java - - - - - - - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - test-jar - - - - - - org.apache.felix - maven-bundle-plugin - - - bundle-manifest - process-classes - - manifest - - - - - - - - - - bintray - https://api.bintray.com/maven/${bintray.repo}/${bintray.package} - - - diff --git a/osgi_test/README.md b/osgi_test/README.md index 2c6ff45d..90753be2 100644 --- a/osgi_test/README.md +++ b/osgi_test/README.md @@ -2,4 +2,4 @@ to run the osgi tests use: - mvn clean && mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V && mvn -B test -pl osgi_test \ No newline at end of file + ./gradlew install moquette-osgi-test:test --rerun-tasks diff --git a/osgi_test/build.gradle b/osgi_test/build.gradle new file mode 100644 index 00000000..52af8999 --- /dev/null +++ b/osgi_test/build.gradle @@ -0,0 +1,22 @@ + +description = 'Moquette - OSGi test' + +ext { + paxExamVersion = '4.6.0' +} + +dependencies { + compile project(':moquette-broker') + compile project(':moquette-h2-storage') + compile project(':moquette-mapdb-storage') + + testCompile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.5' + testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.5' + + testCompile group: 'org.ops4j.pax.exam', name: 'pax-exam-container-native', version: paxExamVersion + testCompile group: 'org.ops4j.pax.exam', name: 'pax-exam-junit4', version: paxExamVersion + testCompile group: 'org.ops4j.pax.exam', name: 'pax-exam-link-mvn', version: paxExamVersion + testCompile group: 'org.ops4j.pax.url', name: 'pax-url-aether', version:'1.4.0' + testCompile group: 'org.apache.felix', name: 'org.apache.felix.framework', version:'5.0.0' + testCompile group: 'javax.inject', name: 'javax.inject', version:'1' +} diff --git a/osgi_test/pom.xml b/osgi_test/pom.xml deleted file mode 100644 index 1c2da264..00000000 --- a/osgi_test/pom.xml +++ /dev/null @@ -1,183 +0,0 @@ - - 4.0.0 - - ../ - moquette-parent - io.moquette - 0.11-SNAPSHOT - - - moquette-osgi-test - jar - Moquette - OSGi test - - - 4.6.0 - 1.4.0 - - - - - io.moquette - moquette-broker - ${project.version} - - - - io.moquette - moquette-h2-storage - ${project.version} - - - - io.moquette - moquette-mapdb-storage - ${project.version} - - - - javax.servlet - javax.servlet-api - 3.1.0 - - - - org.slf4j - slf4j-api - 1.7.5 - test - - - - org.slf4j - slf4j-log4j12 - 1.7.5 - test - - - - org.ops4j.pax.exam - pax-exam-container-native - ${pax.exam.version} - test - - - - org.ops4j.pax.exam - pax-exam-junit4 - ${pax.exam.version} - test - - - - org.ops4j.pax.exam - pax-exam-link-mvn - ${pax.exam.version} - test - - - - org.ops4j.pax.url - pax-url-aether - ${url.version} - test - - - - org.apache.felix - org.apache.felix.framework - 5.0.0 - test - - - - javax.inject - javax.inject - 1 - test - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - - - compile - compile - - - - - - - - - - - - - - - run - - - - - - - org.ops4j.pax.exam - exam-maven-plugin - ${pax.exam.version} - - io.moquette.test.osgi.MoquetteOsgiTest - - - - - start-container - stop-container - - - - - - - org.apache.servicemix.tooling - depends-maven-plugin - 1.2 - - - generate-depends-file - generate-resources - - generate-depends-file - - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.12 - - - - integration-test - - - - - always - none - 1 - - - - - diff --git a/osgi_test/src/test/java/io/moquette/test/osgi/MoquetteOsgiTest.java b/osgi_test/src/test/java/io/moquette/test/osgi/MoquetteOsgiTest.java index ad33f91d..7698bb7d 100644 --- a/osgi_test/src/test/java/io/moquette/test/osgi/MoquetteOsgiTest.java +++ b/osgi_test/src/test/java/io/moquette/test/osgi/MoquetteOsgiTest.java @@ -16,11 +16,14 @@ package io.moquette.test.osgi; -import static org.junit.Assert.*; +import static org.junit.Assert.fail; import static org.ops4j.pax.exam.CoreOptions.*; + +import java.io.IOException; import java.util.Arrays; import java.util.LinkedList; import java.util.List; +import javax.inject.Inject; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; @@ -30,7 +33,6 @@ import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; /** * Run a set of unit tests inside of an OSGi container to make sure @@ -45,46 +47,34 @@ public class MoquetteOsgiTest { private BundleContext bundleContext; @Configuration - public Option[] config() { + public Option[] config() throws IOException { + String nettyV = "4.1.12.Final"; return options( junitBundles(), - mavenBundle("com.google.guava", "guava").versionAsInProject(), - //mavenBundle("com.google.code.findbugs", "jsr305").versionAsInProject(), + mavenBundle("com.hazelcast", "hazelcast"), - mavenBundle("com.fasterxml.jackson.core", "jackson-core").versionAsInProject().start(), - mavenBundle("com.fasterxml.jackson.core", "jackson-databind").versionAsInProject(), - mavenBundle("com.fasterxml.jackson.core", "jackson-annotations").versionAsInProject(), - //mavenBundle("com.librato.metrics", "librato-java").versionAsInProject(), - //mavenBundle("com.librato.metrics", "metrics-librato").versionAsInProject(), - mavenBundle("io.dropwizard.metrics", "metrics-core").versionAsInProject(), - mavenBundle("io.dropwizard.metrics", "metrics-jvm").versionAsInProject(), - mavenBundle("com.hazelcast", "hazelcast").versionAsInProject(), + mavenBundle("io.netty", "netty-common", nettyV), + mavenBundle("io.netty", "netty-buffer", nettyV), + mavenBundle("io.netty", "netty-transport", nettyV), + mavenBundle("io.netty", "netty-resolver", nettyV), + mavenBundle("io.netty", "netty-handler", nettyV), + mavenBundle("io.netty", "netty-codec", nettyV), + mavenBundle("io.netty", "netty-codec-http", nettyV), + mavenBundle("io.netty", "netty-codec-mqtt", nettyV), + mavenBundle("io.netty", "netty-transport-native-epoll", nettyV), + mavenBundle("io.netty", "netty-transport-native-unix-common", nettyV), - mavenBundle("io.netty", "netty-common").versionAsInProject(), - mavenBundle("io.netty", "netty-buffer").versionAsInProject(), - mavenBundle("io.netty", "netty-transport").versionAsInProject(), - mavenBundle("io.netty", "netty-resolver").versionAsInProject(), - mavenBundle("io.netty", "netty-handler").versionAsInProject(), - mavenBundle("io.netty", "netty-handler").versionAsInProject(), - mavenBundle("io.netty", "netty-codec").versionAsInProject(), - mavenBundle("io.netty", "netty-codec-http").versionAsInProject(), - mavenBundle("io.netty", "netty-codec-mqtt").versionAsInProject(), - mavenBundle("io.netty", "netty-transport-native-epoll").versionAsInProject(), - mavenBundle("io.netty", "netty-transport-native-unix-common").versionAsInProject(), + mavenBundle("commons-codec", "commons-codec"), - mavenBundle("commons-codec", "commons-codec").versionAsInProject(), + mavenBundle("io.moquette", "moquette-broker"), - mavenBundle("javax.servlet", "javax.servlet-api").versionAsInProject(), + mavenBundle("com.h2database", "h2-mvstore"), + mavenBundle("io.moquette", "moquette-h2-storage"), - mavenBundle("io.moquette", "moquette-broker").versionAsInProject(), - - mavenBundle("com.h2database", "h2-mvstore").versionAsInProject(), - mavenBundle("io.moquette", "moquette-h2-storage").versionAsInProject(), - - mavenBundle("org.mapdb", "mapdb").versionAsInProject(), - mavenBundle("io.moquette", "moquette-mapdb-storage").versionAsInProject() + mavenBundle("org.mapdb", "mapdb", "1.0.8"), + mavenBundle("io.moquette", "moquette-mapdb-storage") ); } diff --git a/perf/build.gradle b/perf/build.gradle new file mode 100644 index 00000000..b57208c9 --- /dev/null +++ b/perf/build.gradle @@ -0,0 +1,9 @@ + +description = 'Moquette - performance tests' +dependencies { + compile project(':moquette-broker') + compile group: 'io.netty', name: 'netty-codec-mqtt', version:"${nettyVersion}" + compile group: 'org.hdrhistogram', name: 'HdrHistogram', version:'2.1.2' + compile group: 'org.eclipse.paho', name: 'org.eclipse.paho.client.mqttv3', version:'1.1.0' + compile group: 'org.eclipse.jetty.toolchain', name: 'jetty-perf-helper', version:'1.0.5' +} diff --git a/perf/pom.xml b/perf/pom.xml deleted file mode 100644 index c7aca338..00000000 --- a/perf/pom.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - 4.0.0 - - ../ - moquette-parent - io.moquette - 0.11-SNAPSHOT - - - moquette-performance - jar - Moquette - performance tests - - - UTF-8 - io.moquette.moquette-performance - - - - - ${project.groupId} - moquette-broker - ${project.version} - - - - ${project.groupId} - moquette-broker - ${project.version} - test-jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.slf4j - slf4j-log4j12 - 1.6.4 - - - io.netty - netty-codec-mqtt - ${netty.version} - - - - org.hdrhistogram - HdrHistogram - 2.1.2 - - - - org.eclipse.paho - org.eclipse.paho.client.mqttv3 - 1.1.0 - - - - org.eclipse.jetty.toolchain - jetty-perf-helper - 1.0.5 - - - - - junit - junit - 4.8.2 - test - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - io/moquette/parser/netty/TestUtils.java - io/moquette/parser/netty/TestUtils$* - - - - - - - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - org.apache.felix - maven-bundle-plugin - - - bundle-manifest - process-classes - - manifest - - - - - - - - - - bintray - https://api.bintray.com/maven/${bintray.repo}/${bintray.package} - - - diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 2bed10a1..00000000 --- a/pom.xml +++ /dev/null @@ -1,235 +0,0 @@ - - 4.0.0 - - UTF-8 - 4.1.12.Final - 1.8 - 1.8 - andsel/maven - io.moquette.moquette-parent - - - io.moquette - moquette-parent - - pom - 0.11-SNAPSHOT - Moquette MQTT - Moquette lightweight MQTT Broker - 2011 - https://github.com/andsel/moquette/ - - - - The Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - Eclipse Public License - Version 1.0 - http://www.eclipse.org/org/documents/epl-v10.php - - - - - - andsel - Andrea Selva - - architect - developer - founder - - +1 - - - - - - Steven Warwick - http://stevenwarwick.com - - - Igor Yova - https://github.com/Fameing - - - Luca Capra - https://github.com/muka - - - Wagner Macedo - https://github.com/wagnerluis1982 - - - Luis Barrios - https://github.com/lbarriosh - - - Christophe Mourette - https://github.com/mackristof - - - Victor Kazakov - https://github.com/kazvictor - - - Neeme Praks - https://github.com/nemecec - - - Kevin Berendsen - https://github.com/kevto - - - Chris Schaefer - https://github.com/windbender - - - Keith Hughes - http://www.inhabitech.com/blog/author/keith/ - - - Luca Capra - luca.capra@create-net.org - - - konradm - - - pkhanal - - - - - scm:git:git@github.com:andsel/moquette.git - scm:git:git@github.com:andsel/moquette.git - git@github.com:andsel/moquette.git - - - - broker - mapdb_storage - h2_storage - distribution - embedding_moquette - osgi_test - perf - - - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.6 - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${source.version} - ${target.version} - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.17 - - checkstyle.xml - checkstyle-suppressions.xml - - true - true - - - - validate - - check - - - - - - - - - - release-sign-artifacts - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - - jar - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - attach-javadocs - - jar - - - - - - - org.apache.maven.plugins - maven-gpg-plugin - - - sign-artifacts - package - - sign - - - - - - - - - - - - Paho Releases - https://repo.eclipse.org/content/repositories/paho-releases/ - - - - sonatype-snapshots - - true - - https://oss.sonatype.org/content/repositories/snapshots - - - - - - bintray - https://api.bintray.com/maven/${bintray.repo}/${bintray.parent.package} - - - diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..3141639d --- /dev/null +++ b/settings.gradle @@ -0,0 +1,16 @@ +rootProject.name = 'moquette-parent' +include ':moquette-broker' +include ':distribution' +include ':moquette-h2-storage' +include ':moquette-mapdb-storage' +include ':moquette-embedded-test' +include ':moquette-osgi-test' +include ':moquette-performance' + +project(':moquette-broker').projectDir = "$rootDir/broker" as File +project(':distribution').projectDir = "$rootDir/distribution" as File +project(':moquette-embedded-test').projectDir = "$rootDir/embedding_moquette" as File +project(':moquette-osgi-test').projectDir = "$rootDir/osgi_test" as File +project(':moquette-performance').projectDir = "$rootDir/perf" as File +project(':moquette-h2-storage').projectDir = "$rootDir/h2_storage" as File +project(':moquette-mapdb-storage').projectDir = "$rootDir/mapdb_storage" as File \ No newline at end of file