mirror of https://github.com/apache/kafka.git
kafka-1419; cross build for scala 2.11; patched by Ivan Lyutov; reviewed by Joe Stein and Jun Rao
This commit is contained in:
parent
c9894fb6ee
commit
4d0759713f
|
@ -41,8 +41,8 @@ The release file can be found inside ./core/build/distributions/.
|
|||
### Cleaning the build ###
|
||||
./gradlew clean
|
||||
|
||||
### Running a task on a particular version of Scala (either 2.8.0, 2.8.2, 2.9.1, 2.9.2 or 2.10.1) ###
|
||||
#### (If building a jar with a version other than 2.8.0, the scala version variable in bin/kafka-run-class.sh needs to be changed to run quick start.) ####
|
||||
### Running a task on a particular version of Scala (either 2.9.1, 2.9.2, 2.10.1 or 2.11) ###
|
||||
#### (If building a jar with a version other than 2.10, the scala version variable in bin/kafka-run-class.sh needs to be changed to run quick start.) ####
|
||||
./gradlew -PscalaVersion=2.9.1 jar
|
||||
./gradlew -PscalaVersion=2.9.1 test
|
||||
./gradlew -PscalaVersion=2.9.1 releaseTarGz
|
||||
|
|
|
@ -32,11 +32,11 @@ if [ ! -d "$LOG_DIR" ]; then
|
|||
fi
|
||||
|
||||
if [ -z "$SCALA_VERSION" ]; then
|
||||
SCALA_VERSION=2.8.0
|
||||
SCALA_VERSION=2.10
|
||||
fi
|
||||
|
||||
# run ./gradlew copyDependantLibs to get all dependant jars in a local dir
|
||||
for file in $base_dir/core/build/dependant-libs-${SCALA_VERSION}/*.jar;
|
||||
for file in $base_dir/core/build/dependant-libs-${SCALA_VERSION}*/*.jar;
|
||||
do
|
||||
CLASSPATH=$CLASSPATH:$file
|
||||
done
|
||||
|
|
44
build.gradle
44
build.gradle
|
@ -130,7 +130,7 @@ subprojects {
|
|||
}
|
||||
}
|
||||
|
||||
for ( sv in ['2_8_0', '2_9_1', '2_9_2', '2_10_1'] ) {
|
||||
for ( sv in ['2_9_1', '2_9_2', '2_10_1', '2_11'] ) {
|
||||
String svInDot = sv.replaceAll( "_", ".")
|
||||
|
||||
tasks.create(name: "jar_core_${sv}", type: GradleBuild) {
|
||||
|
@ -170,20 +170,20 @@ for ( sv in ['2_8_0', '2_9_1', '2_9_2', '2_10_1'] ) {
|
|||
}
|
||||
}
|
||||
|
||||
tasks.create(name: "jarAll", dependsOn: ['jar_core_2_8_0', 'jar_core_2_9_1', 'jar_core_2_9_2', 'jar_core_2_10_1', 'clients:jar', 'perf:jar', 'examples:jar', 'contrib:hadoop-consumer:jar', 'contrib:hadoop-producer:jar']) {
|
||||
tasks.create(name: "jarAll", dependsOn: ['jar_core_2_9_1', 'jar_core_2_9_2', 'jar_core_2_10_1', 'jar_core_2_11', 'clients:jar', 'perf:jar', 'examples:jar', 'contrib:hadoop-consumer:jar', 'contrib:hadoop-producer:jar']) {
|
||||
}
|
||||
|
||||
tasks.create(name: "srcJarAll", dependsOn: ['srcJar_2_8_0', 'srcJar_2_9_1', 'srcJar_2_9_2', 'srcJar_2_10_1', 'clients:srcJar', 'perf:srcJar', 'examples:srcJar', 'contrib:hadoop-consumer:srcJar', 'contrib:hadoop-producer:srcJar']) { }
|
||||
tasks.create(name: "srcJarAll", dependsOn: ['srcJar_2_9_1', 'srcJar_2_9_2', 'srcJar_2_10_1', 'srcJar_2_11', 'clients:srcJar', 'perf:srcJar', 'examples:srcJar', 'contrib:hadoop-consumer:srcJar', 'contrib:hadoop-producer:srcJar']) { }
|
||||
|
||||
tasks.create(name: "docsJarAll", dependsOn: ['docsJar_2_8_0', 'docsJar_2_9_1', 'docsJar_2_9_2', 'docsJar_2_10_1', 'clients:docsJar', 'perf:docsJar', 'examples:docsJar', 'contrib:hadoop-consumer:docsJar', 'contrib:hadoop-producer:docsJar']) { }
|
||||
tasks.create(name: "docsJarAll", dependsOn: ['docsJar_2_9_1', 'docsJar_2_9_2', 'docsJar_2_10_1', 'docsJar_2_11', 'clients:docsJar', 'perf:docsJar', 'examples:docsJar', 'contrib:hadoop-consumer:docsJar', 'contrib:hadoop-producer:docsJar']) { }
|
||||
|
||||
tasks.create(name: "testAll", dependsOn: ['test_core_2_8_0', 'test_core_2_9_1', 'test_core_2_9_2', 'test_core_2_10_1', 'clients:test']) {
|
||||
tasks.create(name: "testAll", dependsOn: ['test_core_2_9_1', 'test_core_2_9_2', 'test_core_2_10_1', 'test_core_2_11', 'clients:test']) {
|
||||
}
|
||||
|
||||
tasks.create(name: "releaseTarGzAll", dependsOn: ['releaseTarGz_2_8_0', 'releaseTarGz_2_9_1', 'releaseTarGz_2_9_2', 'releaseTarGz_2_10_1']) {
|
||||
tasks.create(name: "releaseTarGzAll", dependsOn: ['releaseTarGz_2_9_1', 'releaseTarGz_2_9_2', 'releaseTarGz_2_10_1', 'releaseTarGz_2_11']) {
|
||||
}
|
||||
|
||||
tasks.create(name: "uploadArchivesAll", dependsOn: ['uploadCoreArchives_2_8_0', 'uploadCoreArchives_2_9_1', 'uploadCoreArchives_2_9_2', 'uploadCoreArchives_2_10_1', 'perf:uploadArchives', 'examples:uploadArchives', 'contrib:hadoop-consumer:uploadArchives', 'contrib:hadoop-producer:uploadArchives']) {
|
||||
tasks.create(name: "uploadArchivesAll", dependsOn: ['uploadCoreArchives_2_9_1', 'uploadCoreArchives_2_9_2', 'uploadCoreArchives_2_10_1', 'uploadCoreArchives_2_11', 'clients:uploadArchives', 'perf:uploadArchives', 'examples:uploadArchives', 'contrib:hadoop-consumer:uploadArchives', 'contrib:hadoop-producer:uploadArchives']) {
|
||||
}
|
||||
|
||||
project(':core') {
|
||||
|
@ -194,24 +194,6 @@ project(':core') {
|
|||
|
||||
def (major, minor, trivial) = scalaVersion.tokenize('.')
|
||||
|
||||
if(major.toInteger() >= 2 && minor.toInteger() >= 9) {
|
||||
sourceSets {
|
||||
main {
|
||||
scala {
|
||||
exclude 'kafka/utils/Annotations_2.8.scala'
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sourceSets {
|
||||
main {
|
||||
scala {
|
||||
exclude 'kafka/utils/Annotations_2.9+.scala'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':clients')
|
||||
compile "org.scala-lang:scala-library:$scalaVersion"
|
||||
|
@ -224,16 +206,18 @@ project(':core') {
|
|||
testCompile 'org.easymock:easymock:3.0'
|
||||
testCompile 'org.objenesis:objenesis:1.2'
|
||||
testCompile project(':clients')
|
||||
if (scalaVersion.startsWith('2.8')) {
|
||||
testCompile 'org.scalatest:scalatest:1.2'
|
||||
} else if (scalaVersion.startsWith('2.10')) {
|
||||
if (scalaVersion.startsWith('2.10')) {
|
||||
testCompile 'org.scalatest:scalatest_2.10:1.9.1'
|
||||
} else if (scalaVersion.startsWith('2.11')) {
|
||||
compile 'org.scala-lang.modules:scala-xml_2.11:1.0.2'
|
||||
compile 'org.scala-lang.modules:scala-parser-combinators_2.11:1.0.2'
|
||||
testCompile "org.scalatest:scalatest_2.11:2.2.0"
|
||||
} else {
|
||||
testCompile "org.scalatest:scalatest_$scalaVersion:1.8"
|
||||
}
|
||||
testRuntime "$slf4jlog4j"
|
||||
|
||||
zinc 'com.typesafe.zinc:zinc:0.2.5'
|
||||
zinc 'com.typesafe.zinc:zinc:0.3.1'
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
@ -299,7 +283,7 @@ project(':perf') {
|
|||
compile "org.scala-lang:scala-library:$scalaVersion"
|
||||
compile 'net.sf.jopt-simple:jopt-simple:3.2'
|
||||
|
||||
zinc 'com.typesafe.zinc:zinc:0.2.5'
|
||||
zinc 'com.typesafe.zinc:zinc:0.3.1'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,12 +17,11 @@
|
|||
package kafka.javaapi.message
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
import scala.reflect.BeanProperty
|
||||
import java.nio.ByteBuffer
|
||||
import kafka.message._
|
||||
import kafka.javaapi.Implicits.javaListToScalaBuffer
|
||||
|
||||
class ByteBufferMessageSet(@BeanProperty val buffer: ByteBuffer) extends MessageSet {
|
||||
class ByteBufferMessageSet(val buffer: ByteBuffer) extends MessageSet {
|
||||
private val underlying: kafka.message.ByteBufferMessageSet = new kafka.message.ByteBufferMessageSet(buffer)
|
||||
|
||||
def this(compressionCodec: CompressionCodec, messages: java.util.List[Message]) {
|
||||
|
@ -36,6 +35,8 @@ class ByteBufferMessageSet(@BeanProperty val buffer: ByteBuffer) extends Message
|
|||
|
||||
def validBytes: Int = underlying.validBytes
|
||||
|
||||
def getBuffer = buffer
|
||||
|
||||
override def iterator: java.util.Iterator[MessageAndOffset] = new java.util.Iterator[MessageAndOffset] {
|
||||
val underlyingIterator = underlying.iterator
|
||||
override def hasNext(): Boolean = {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package kafka.message
|
||||
|
||||
import scala.reflect.BeanProperty
|
||||
import kafka.utils.Logging
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.channels._
|
||||
|
@ -95,7 +94,7 @@ object ByteBufferMessageSet {
|
|||
* Option 2: Give it a list of messages along with instructions relating to serialization format. Producers will use this method.
|
||||
*
|
||||
*/
|
||||
class ByteBufferMessageSet(@BeanProperty val buffer: ByteBuffer) extends MessageSet with Logging {
|
||||
class ByteBufferMessageSet(val buffer: ByteBuffer) extends MessageSet with Logging {
|
||||
private var shallowValidByteCount = -1
|
||||
|
||||
def this(compressionCodec: CompressionCodec, messages: Message*) {
|
||||
|
@ -110,6 +109,8 @@ class ByteBufferMessageSet(@BeanProperty val buffer: ByteBuffer) extends Message
|
|||
this(NoCompressionCodec, new AtomicLong(0), messages: _*)
|
||||
}
|
||||
|
||||
def getBuffer = buffer
|
||||
|
||||
private def shallowValidBytes: Int = {
|
||||
if(shallowValidByteCount < 0) {
|
||||
var bytes = 0
|
||||
|
|
|
@ -1,36 +0,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.
|
||||
*/
|
||||
|
||||
package kafka.utils
|
||||
|
||||
/* Some helpful annotations */
|
||||
|
||||
/**
|
||||
* Indicates that the annotated class is meant to be threadsafe. For an abstract class it is an part of the interface that an implementation
|
||||
* must respect
|
||||
*/
|
||||
class threadsafe extends StaticAnnotation
|
||||
|
||||
/**
|
||||
* Indicates that the annotated class is not threadsafe
|
||||
*/
|
||||
class nonthreadsafe extends StaticAnnotation
|
||||
|
||||
/**
|
||||
* Indicates that the annotated class is immutable
|
||||
*/
|
||||
class immutable extends StaticAnnotation
|
|
@ -29,7 +29,7 @@ class ConfigTest {
|
|||
@Test
|
||||
def testInvalidClientIds() {
|
||||
val invalidClientIds = new ArrayBuffer[String]()
|
||||
val badChars = Array('/', '\\', ',', '\0', ':', "\"", '\'', ';', '*', '?', ' ', '\t', '\r', '\n', '=')
|
||||
val badChars = Array('/', '\\', ',', '\u0000', ':', "\"", '\'', ';', '*', '?', ' ', '\t', '\r', '\n', '=')
|
||||
for (weirdChar <- badChars) {
|
||||
invalidClientIds += "Is" + weirdChar + "illegal"
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class ConfigTest {
|
|||
@Test
|
||||
def testInvalidGroupIds() {
|
||||
val invalidGroupIds = new ArrayBuffer[String]()
|
||||
val badChars = Array('/', '\\', ',', '\0', ':', "\"", '\'', ';', '*', '?', ' ', '\t', '\r', '\n', '=')
|
||||
val badChars = Array('/', '\\', ',', '\u0000', ':', "\"", '\'', ';', '*', '?', ' ', '\t', '\r', '\n', '=')
|
||||
for (weirdChar <- badChars) {
|
||||
invalidGroupIds += "Is" + weirdChar + "illegal"
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class TopicTest {
|
|||
for (i <- 1 to 6)
|
||||
longName += longName
|
||||
invalidTopicNames += longName
|
||||
val badChars = Array('/', '\\', ',', '\0', ':', "\"", '\'', ';', '*', '?', ' ', '\t', '\r', '\n', '=')
|
||||
val badChars = Array('/', '\\', ',', '\u0000', ':', "\"", '\'', ';', '*', '?', ' ', '\t', '\r', '\n', '=')
|
||||
for (weirdChar <- badChars) {
|
||||
invalidTopicNames += "Is" + weirdChar + "illegal"
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
group=org.apache.kafka
|
||||
version=0.8.1
|
||||
scalaVersion=2.8.0
|
||||
scalaVersion=2.10.1
|
||||
task=build
|
||||
|
||||
mavenUrl=
|
||||
|
|
|
@ -8,5 +8,5 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.6.1'
|
||||
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0'
|
||||
}
|
||||
|
|
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.zip
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-2.0-bin.zip
|
||||
|
|
12
scala.gradle
12
scala.gradle
|
@ -1,5 +1,11 @@
|
|||
if (!hasProperty('scalaVersion')) {
|
||||
ext.scalaVersion = '2.8.0'
|
||||
ext.scalaVersion = '2.10.1'
|
||||
}
|
||||
ext.defaultScalaVersion = '2.10.1'
|
||||
if (scalaVersion.startsWith('2.10')) {
|
||||
ext.baseScalaVersion = '2.10'
|
||||
} else if (scalaVersion.startsWith('2.11')) {
|
||||
ext.baseScalaVersion = '2.11'
|
||||
} else {
|
||||
ext.baseScalaVersion = scalaVersion
|
||||
}
|
||||
ext.defaultScalaVersion = '2.8.0'
|
||||
ext.baseScalaVersion = (scalaVersion.startsWith('2.10')) ? '2.10' : scalaVersion
|
||||
|
|
Loading…
Reference in New Issue