Repository: kafka Updated Branches: refs/heads/trunk c9894fb6e -> 4d0759713
kafka-1419; cross build for scala 2.11; patched by Ivan Lyutov; reviewed by Joe Stein and Jun Rao Project: http://git-wip-us.apache.org/repos/asf/kafka/repo Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/4d075971 Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/4d075971 Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/4d075971 Branch: refs/heads/trunk Commit: 4d0759713fb2722bac8ce7dcbbb047d7af99280a Parents: c9894fb Author: Ivan Lyutov <[email protected]> Authored: Sun Aug 10 21:20:30 2014 -0700 Committer: Jun Rao <[email protected]> Committed: Sun Aug 10 21:20:30 2014 -0700 ---------------------------------------------------------------------- README.md | 4 +- bin/kafka-run-class.sh | 4 +- build.gradle | 46 +++++++------------- .../javaapi/message/ByteBufferMessageSet.scala | 5 ++- .../kafka/message/ByteBufferMessageSet.scala | 5 ++- .../main/scala/kafka/utils/Annotations.scala | 38 ++++++++++++++++ .../scala/kafka/utils/Annotations_2.8.scala | 36 --------------- .../scala/kafka/utils/Annotations_2.9+.scala | 38 ---------------- .../scala/unit/kafka/common/ConfigTest.scala | 4 +- .../scala/unit/kafka/common/TopicTest.scala | 2 +- gradle.properties | 2 +- gradle/buildscript.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- scala.gradle | 12 +++-- 14 files changed, 78 insertions(+), 122 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index d757b97..8cd5cfd 100644 --- a/README.md +++ b/README.md @@ -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 http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/bin/kafka-run-class.sh ---------------------------------------------------------------------- diff --git a/bin/kafka-run-class.sh b/bin/kafka-run-class.sh index 5d5021d..1588e46 100755 --- a/bin/kafka-run-class.sh +++ b/bin/kafka-run-class.sh @@ -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 http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index 9cbedb8..45cf502 100644 --- a/build.gradle +++ b/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' } } http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/core/src/main/scala/kafka/javaapi/message/ByteBufferMessageSet.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/kafka/javaapi/message/ByteBufferMessageSet.scala b/core/src/main/scala/kafka/javaapi/message/ByteBufferMessageSet.scala index fecee8d..0125565 100644 --- a/core/src/main/scala/kafka/javaapi/message/ByteBufferMessageSet.scala +++ b/core/src/main/scala/kafka/javaapi/message/ByteBufferMessageSet.scala @@ -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 = { http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/core/src/main/scala/kafka/message/ByteBufferMessageSet.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/kafka/message/ByteBufferMessageSet.scala b/core/src/main/scala/kafka/message/ByteBufferMessageSet.scala index 73401c5..788c786 100644 --- a/core/src/main/scala/kafka/message/ByteBufferMessageSet.scala +++ b/core/src/main/scala/kafka/message/ByteBufferMessageSet.scala @@ -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 http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/core/src/main/scala/kafka/utils/Annotations.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/kafka/utils/Annotations.scala b/core/src/main/scala/kafka/utils/Annotations.scala new file mode 100644 index 0000000..ab95ce1 --- /dev/null +++ b/core/src/main/scala/kafka/utils/Annotations.scala @@ -0,0 +1,38 @@ +/** + * 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 + +import scala.annotation.StaticAnnotation + +/* 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 http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/core/src/main/scala/kafka/utils/Annotations_2.8.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/kafka/utils/Annotations_2.8.scala b/core/src/main/scala/kafka/utils/Annotations_2.8.scala deleted file mode 100644 index 28269eb..0000000 --- a/core/src/main/scala/kafka/utils/Annotations_2.8.scala +++ /dev/null @@ -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 http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/core/src/main/scala/kafka/utils/Annotations_2.9+.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/kafka/utils/Annotations_2.9+.scala b/core/src/main/scala/kafka/utils/Annotations_2.9+.scala deleted file mode 100644 index ab95ce1..0000000 --- a/core/src/main/scala/kafka/utils/Annotations_2.9+.scala +++ /dev/null @@ -1,38 +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 - -import scala.annotation.StaticAnnotation - -/* 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 http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/core/src/test/scala/unit/kafka/common/ConfigTest.scala ---------------------------------------------------------------------- diff --git a/core/src/test/scala/unit/kafka/common/ConfigTest.scala b/core/src/test/scala/unit/kafka/common/ConfigTest.scala index 74118f4..7bff96c 100644 --- a/core/src/test/scala/unit/kafka/common/ConfigTest.scala +++ b/core/src/test/scala/unit/kafka/common/ConfigTest.scala @@ -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" } http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/core/src/test/scala/unit/kafka/common/TopicTest.scala ---------------------------------------------------------------------- diff --git a/core/src/test/scala/unit/kafka/common/TopicTest.scala b/core/src/test/scala/unit/kafka/common/TopicTest.scala index c8f8f4d..0fb2588 100644 --- a/core/src/test/scala/unit/kafka/common/TopicTest.scala +++ b/core/src/test/scala/unit/kafka/common/TopicTest.scala @@ -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" } http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/gradle.properties ---------------------------------------------------------------------- diff --git a/gradle.properties b/gradle.properties index 4827769..8f9ff15 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ group=org.apache.kafka version=0.8.1 -scalaVersion=2.8.0 +scalaVersion=2.10.1 task=build mavenUrl= http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/gradle/buildscript.gradle ---------------------------------------------------------------------- diff --git a/gradle/buildscript.gradle b/gradle/buildscript.gradle index 225e0a8..5e45c06 100644 --- a/gradle/buildscript.gradle +++ b/gradle/buildscript.gradle @@ -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' } http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/gradle/wrapper/gradle-wrapper.properties ---------------------------------------------------------------------- diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 610282a..d238df3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 http://git-wip-us.apache.org/repos/asf/kafka/blob/4d075971/scala.gradle ---------------------------------------------------------------------- diff --git a/scala.gradle b/scala.gradle index ebd21b8..6adf9af 100644 --- a/scala.gradle +++ b/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
