From f08d21c38d840088a0b67ae2bf07aeab4ad7b77f Mon Sep 17 00:00:00 2001 From: Hailong Wen Date: Thu, 7 Dec 2017 14:54:05 -0800 Subject: Address comments from bogdan and sebright. * Remove unnecessary plugins. * Reuse existing checkstyle.xml and errorprone properties from main project. * Add script in travis and appveyor to build examples. --- examples/README.md | 7 +- examples/build.gradle | 81 +------ examples/buildscripts/checkstyle.license | 15 -- examples/buildscripts/checkstyle.xml | 233 --------------------- examples/gradle/errorprone/experimental_errors | 27 --- .../gradle/errorprone/experimental_suggestions | 25 --- examples/gradle/errorprone/experimental_warnings | 23 -- examples/gradle/errorprone/warnings | 76 ------- 8 files changed, 13 insertions(+), 474 deletions(-) delete mode 100644 examples/buildscripts/checkstyle.license delete mode 100644 examples/buildscripts/checkstyle.xml delete mode 100644 examples/gradle/errorprone/experimental_errors delete mode 100644 examples/gradle/errorprone/experimental_suggestions delete mode 100644 examples/gradle/errorprone/experimental_warnings delete mode 100644 examples/gradle/errorprone/warnings (limited to 'examples') diff --git a/examples/README.md b/examples/README.md index eb37cd17..741e5cd8 100644 --- a/examples/README.md +++ b/examples/README.md @@ -6,7 +6,12 @@ $ ./gradlew installDist ``` -* Remember to change `opencensusVersion` in `build.gradle` to a released version you want to use. +Note: If you are building a SNAPSHOT instead of a release, please install the opencensus-java main project to your local repo first: + +``` +$ cd .. && gradlew install +``` + ## To run "StatsRunner" example use ``` diff --git a/examples/build.gradle b/examples/build.gradle index fa3eb587..7f9b3ad8 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -9,27 +9,15 @@ buildscript { } } dependencies { - classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.2' classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13' - classpath "net.ltgt.gradle:gradle-apt-plugin:0.10" - classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0' classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.6" } } -// Display the version report using: ./gradlew dependencyUpdates -// Also see https://github.com/ben-manes/gradle-versions-plugin. -apply plugin: 'com.github.ben-manes.versions' apply plugin: "checkstyle" -apply plugin: 'maven' apply plugin: 'idea' apply plugin: 'java' -apply plugin: "signing" -apply plugin: "jacoco" -// The plugin only has an effect if a signature is specified -apply plugin: 'ru.vyarus.animalsniffer' apply plugin: 'findbugs' -apply plugin: 'net.ltgt.apt' // Plugins that require java8 if (JavaVersion.current().isJava8Compatible()) { apply plugin: "net.ltgt.errorprone" @@ -44,10 +32,7 @@ repositories { group = "io.opencensus" version = "0.11.0-SNAPSHOT" -// change to the version you want to use. -def opencensusVersion = "0.11.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION - -[compileJava, compileTestJava].each() { +compileJava { // We suppress the "processing" warning as suggested in // https://groups.google.com/forum/#!topic/bazel-discuss/_R3A9TJSoPM it.options.compilerArgs += ["-Xlint:all", "-Xlint:-try", "-Xlint:-processing"] @@ -83,27 +68,6 @@ def opencensusVersion = "0.11.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION } } -compileTestJava { - // serialVersionUID is basically guaranteed to be useless in tests - options.compilerArgs += ["-Xlint:-serial"] - // It undeprecates DoubleSubject.isEqualTo(Double). - options.compilerArgs += ["-Xlint:-deprecation"] -} - -jar.manifest { - attributes('Implementation-Title': name, - 'Implementation-Version': version, - 'Built-By': System.getProperty('user.name'), - 'Built-JDK': System.getProperty('java.version'), - 'Source-Compatibility': sourceCompatibility, - 'Target-Compatibility': targetCompatibility) -} - -javadoc.options { - encoding = 'UTF-8' - links 'https://docs.oracle.com/javase/8/docs/api/' -} - ext { findBugsVersion = '3.0.1' } @@ -126,13 +90,13 @@ findbugsMain { findbugsTest.enabled = false checkstyle { - configFile = file("$rootDir/buildscripts/checkstyle.xml") + configFile = file("$rootDir/../buildscripts/checkstyle.xml") toolVersion = "8.0" ignoreFailures = false if (rootProject.hasProperty("checkstyle.ignoreFailures")) { ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean() } - configProperties["rootDir"] = rootDir + configProperties["rootDir"] = file("$rootDir/../") } // Disable checkstyle if no java8. @@ -146,48 +110,17 @@ if (JavaVersion.current().isJava8Compatible()) { } } -signing { - required false - sign configurations.archives -} - -task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -artifacts { - archives javadocJar, sourcesJar -} - -// At a test failure, log the stack trace to the console so that we don't -// have to open the HTML in a browser. -test { - testLogging { - exceptionFormat = 'full' - showExceptions true - showCauses true - showStackTraces true - } - maxHeapSize = '1500m' -} - tasks.withType(JavaCompile) { sourceCompatibility = '1.8' targetCompatibility = '1.8' } dependencies { - compile "io.opencensus:opencensus-api:${opencensusVersion}", - "io.opencensus:opencensus-contrib-zpages:${opencensusVersion}", - "io.opencensus:opencensus-exporter-trace-logging:${opencensusVersion}" + compile "io.opencensus:opencensus-api:${version}", + "io.opencensus:opencensus-contrib-zpages:${version}", + "io.opencensus:opencensus-exporter-trace-logging:${version}" - runtime "io.opencensus:opencensus-impl:${opencensusVersion}" + runtime "io.opencensus:opencensus-impl:${version}" } // Provide convenience executables for trying out the examples. diff --git a/examples/buildscripts/checkstyle.license b/examples/buildscripts/checkstyle.license deleted file mode 100644 index 27bac1a2..00000000 --- a/examples/buildscripts/checkstyle.license +++ /dev/null @@ -1,15 +0,0 @@ -^/\*$ -^ \* Copyright \d\d\d\d(-\d\d)?, OpenCensus Authors$ -^ \*$ -^ \* Licensed 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\.$ -^ \*/$ \ No newline at end of file diff --git a/examples/buildscripts/checkstyle.xml b/examples/buildscripts/checkstyle.xml deleted file mode 100644 index fdea0c5e..00000000 --- a/examples/buildscripts/checkstyle.xml +++ /dev/null @@ -1,233 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/gradle/errorprone/experimental_errors b/examples/gradle/errorprone/experimental_errors deleted file mode 100644 index 5ce6e181..00000000 --- a/examples/gradle/errorprone/experimental_errors +++ /dev/null @@ -1,27 +0,0 @@ -errorProneExperimentalErrors = \ --Xep:AssistedInjectAndInjectOnSameConstructor:ERROR,\ --Xep:AutoFactoryAtInject:ERROR,\ --Xep:ClassName:ERROR,\ --Xep:ComparisonContractViolated:ERROR,\ --Xep:DepAnn:ERROR,\ --Xep:DivZero:ERROR,\ --Xep:EmptyIf:ERROR,\ --Xep:FuzzyEqualsShouldNotBeUsedInEqualsMethod:ERROR,\ --Xep:InjectInvalidTargetingOnScopingAnnotation:ERROR,\ --Xep:InjectMoreThanOneQualifier:ERROR,\ --Xep:InjectScopeAnnotationOnInterfaceOrAbstractClass:ERROR,\ --Xep:InjectScopeOrQualifierAnnotationRetention:ERROR,\ --Xep:InjectedConstructorAnnotations:ERROR,\ --Xep:InsecureCryptoUsage:ERROR,\ --Xep:IterablePathParameter:ERROR,\ --Xep:JMockTestWithoutRunWithOrRuleAnnotation:ERROR,\ --Xep:JavaxInjectOnFinalField:ERROR,\ --Xep:LockMethodChecker:ERROR,\ --Xep:LongLiteralLowerCaseSuffix:ERROR,\ --Xep:NoAllocation:ERROR,\ --Xep:NumericEquality:ERROR,\ --Xep:ParameterPackage:ERROR,\ --Xep:ProtoStringFieldReferenceEquality:ERROR,\ --Xep:QualifierOrScopeOnInjectMethod:ERROR,\ --Xep:StaticOrDefaultInterfaceMethod:ERROR,\ --Xep:UnlockMethod:ERROR diff --git a/examples/gradle/errorprone/experimental_suggestions b/examples/gradle/errorprone/experimental_suggestions deleted file mode 100644 index 1330b843..00000000 --- a/examples/gradle/errorprone/experimental_suggestions +++ /dev/null @@ -1,25 +0,0 @@ -# FieldMissingNullable is turned off due to -# https://github.com/google/error-prone/issues/823. - -errorProneExperimentalSuggestions = \ --Xep:ConstantField:ERROR,\ --Xep:EmptySetMultibindingContributions:ERROR,\ --Xep:FieldMissingNullable:OFF,\ --Xep:MethodCanBeStatic:ERROR,\ --Xep:MixedArrayDimensions:ERROR,\ --Xep:MultiVariableDeclaration:ERROR,\ --Xep:MultipleTopLevelClasses:ERROR,\ --Xep:MultipleUnaryOperatorsInMethodCall:ERROR,\ --Xep:PackageLocation:ERROR,\ --Xep:ParameterComment:ERROR,\ --Xep:ParameterNotNullable:ERROR,\ --Xep:PrivateConstructorForNoninstantiableModuleTest:ERROR,\ --Xep:PrivateConstructorForUtilityClass:ERROR,\ --Xep:RemoveUnusedImports:ERROR,\ --Xep:ReturnMissingNullable:ERROR,\ --Xep:ThrowsUncheckedException:ERROR,\ --Xep:UngroupedOverloads:ERROR,\ --Xep:UnnecessarySetDefault:ERROR,\ --Xep:UnnecessaryStaticImport:ERROR,\ --Xep:UseBinds:ERROR,\ --Xep:WildcardImport:ERROR diff --git a/examples/gradle/errorprone/experimental_warnings b/examples/gradle/errorprone/experimental_warnings deleted file mode 100644 index b5a7df2b..00000000 --- a/examples/gradle/errorprone/experimental_warnings +++ /dev/null @@ -1,23 +0,0 @@ -errorProneExperimentalWarnings = \ --Xep:AssertFalse:ERROR,\ --Xep:AssistedInjectAndInjectOnConstructors:ERROR,\ --Xep:BigDecimalLiteralDouble:ERROR,\ --Xep:BindingToUnqualifiedCommonType:ERROR,\ --Xep:ConstructorInvokesOverridable:ERROR,\ --Xep:ConstructorLeaksThis:ERROR,\ --Xep:EmptyTopLevelDeclaration:ERROR,\ --Xep:ExpectedExceptionChecker:ERROR,\ --Xep:HardCodedSdCardPath:ERROR,\ --Xep:InconsistentOverloads:ERROR,\ --Xep:MissingDefault:ERROR,\ --Xep:MutableMethodReturnType:ERROR,\ --Xep:NonCanonicalStaticMemberImport:ERROR,\ --Xep:PrimitiveArrayPassedToVarargsMethod:ERROR,\ --Xep:ProvidesFix:ERROR,\ --Xep:QualifierWithTypeUse:ERROR,\ --Xep:RedundantThrows:ERROR,\ --Xep:StaticQualifiedUsingExpression:ERROR,\ --Xep:StringEquality:ERROR,\ --Xep:TestExceptionChecker:ERROR,\ --Xep:UnnecessaryDefaultInEnumSwitch:ERROR,\ --Xep:Var:OFF diff --git a/examples/gradle/errorprone/warnings b/examples/gradle/errorprone/warnings deleted file mode 100644 index da7302dd..00000000 --- a/examples/gradle/errorprone/warnings +++ /dev/null @@ -1,76 +0,0 @@ -errorProneWarnings = \ --Xep:AmbiguousMethodReference:ERROR,\ --Xep:ArgumentSelectionDefectChecker:ERROR,\ --Xep:AssertEqualsArgumentOrderChecker:ERROR,\ --Xep:AssertionFailureIgnored:ERROR,\ --Xep:BadAnnotationImplementation:ERROR,\ --Xep:BadComparable:ERROR,\ --Xep:BoxedPrimitiveConstructor:ERROR,\ --Xep:CannotMockFinalClass:ERROR,\ --Xep:CanonicalDuration:ERROR,\ --Xep:ClassCanBeStatic:ERROR,\ --Xep:ClassNewInstance:ERROR,\ --Xep:CollectionToArraySafeParameter:ERROR,\ --Xep:CollectorShouldNotUseState:ERROR,\ --Xep:ComparableAndComparator:ERROR,\ --Xep:DefaultCharset:ERROR,\ --Xep:DoubleCheckedLocking:ERROR,\ --Xep:EqualsHashCode:ERROR,\ --Xep:EqualsIncompatibleType:ERROR,\ --Xep:Finally:ERROR,\ --Xep:FloatingPointLiteralPrecision:ERROR,\ --Xep:FragmentInjection:ERROR,\ --Xep:FragmentNotInstantiable:ERROR,\ --Xep:FunctionalInterfaceClash:ERROR,\ --Xep:FutureReturnValueIgnored:ERROR,\ --Xep:GetClassOnEnum:ERROR,\ --Xep:ImmutableAnnotationChecker:ERROR,\ --Xep:ImmutableEnumChecker:ERROR,\ --Xep:IncompatibleModifiers:ERROR,\ --Xep:IncrementInForLoopAndHeader:ERROR,\ --Xep:InjectOnConstructorOfAbstractClass:ERROR,\ --Xep:InputStreamSlowMultibyteRead:ERROR,\ --Xep:InstanceOfAndCastMatchWrongType:ERROR,\ --Xep:IntLongMath:ERROR,\ --Xep:IterableAndIterator:ERROR,\ --Xep:JUnit3FloatingPointComparisonWithoutDelta:ERROR,\ --Xep:JUnit4ClassUsedInJUnit3:ERROR,\ --Xep:JUnitAmbiguousTestClass:ERROR,\ --Xep:JavaLangClash:ERROR,\ --Xep:JdkObsolete:ERROR,\ --Xep:LogicalAssignment:ERROR,\ --Xep:MissingFail:ERROR,\ --Xep:MissingOverride:ERROR,\ --Xep:MultipleParallelOrSequentialCalls:ERROR,\ --Xep:MutableConstantField:ERROR,\ --Xep:NamedParameters:ERROR,\ --Xep:NarrowingCompoundAssignment:WARN,\ --Xep:NestedInstanceOfConditions:ERROR,\ --Xep:NonAtomicVolatileUpdate:ERROR,\ --Xep:NonOverridingEquals:ERROR,\ --Xep:NullableConstructor:ERROR,\ --Xep:NullablePrimitive:ERROR,\ --Xep:NullableVoid:ERROR,\ --Xep:OperatorPrecedence:ERROR,\ --Xep:OptionalNotPresent:ERROR,\ --Xep:OverrideThrowableToString:ERROR,\ --Xep:Overrides:ERROR,\ --Xep:OverridesGuiceInjectableMethod:ERROR,\ --Xep:ParameterName:ERROR,\ --Xep:PreconditionsInvalidPlaceholder:ERROR,\ --Xep:ProtoFieldPreconditionsCheckNotNull:ERROR,\ --Xep:ReferenceEquality:ERROR,\ --Xep:RequiredModifiers:ERROR,\ --Xep:ShortCircuitBoolean:ERROR,\ --Xep:SimpleDateFormatConstant:ERROR,\ --Xep:StaticGuardedByInstance:ERROR,\ --Xep:SynchronizeOnNonFinalField:ERROR,\ --Xep:ThreadJoinLoop:ERROR,\ --Xep:TruthConstantAsserts:ERROR,\ --Xep:TypeParameterShadowing:ERROR,\ --Xep:TypeParameterUnusedInFormals:ERROR,\ --Xep:URLEqualsHashCode:ERROR,\ --Xep:UnsynchronizedOverridesSynchronized:ERROR,\ --Xep:UseCorrectAssertInTests:ERROR,\ --Xep:WaitNotInLoop:ERROR,\ --Xep:WakelockReleasedDangerously:ERROR -- cgit v1.2.3