diff --git a/build.gradle b/build.gradle index 7b97cc2747d..cf2bc5d0a57 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,34 @@ -final String CREDENTIALS_LOCATION = 'credentials.properties'; + +project.ext { + // NOTE: when updating Protobuf dependency, please check that KnownTypes.addStandardProtobufTypes() method + // is updated with new Message types introduced in the new version of Protobuf. + PROTOBUF_VERSION = '3.0.0-beta-3' + PROTOBUF_DEPENDENCY = "com.google.protobuf:protoc:${PROTOBUF_VERSION}" + GRPC_VERSION = '0.14.0' + SLF4J_VERSION = '1.7.21' + + SPINE_PROTOBUF_PLUGIN_ID = 'org.spine3.tools.protobuf-plugin' + PUBLISH_PLUGIN_PATH = "$projectDir/gradle/plugins/publish.gradle" + + CREDENTIALS_FILE_PATH = 'credentials.properties' + PROJECTS_TO_PUBLISH = ["client", "server", "values", "testutil"] +} buildscript { repositories { mavenCentral() mavenLocal() + maven { + url = 'http://maven.teamdev.com/repository/spine' + } } dependencies { - classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.7' + classpath group: 'com.google.protobuf', name:'protobuf-gradle-plugin', version: '0.7.7' + classpath group: 'org.spine3.tools', name: 'protobuf-plugin', version: '1.4.8', changing: true } + configurations.all({ + resolutionStrategy.cacheChangingModulesFor(0, 'seconds') + }) } allprojects { @@ -19,44 +40,32 @@ allprojects { version = '0.5.1-SNAPSHOT' } -project.ext { - // NOTE: when updating Protobuf dependency, please check that KnownTypes.addStandardProtobufTypes() method - // is updated with new Message types introduced in the new version of Protobuf. - PROTOBUF_VERSION = '3.0.0-beta-3'; - PROTOBUF_DEPENDENCY = "com.google.protobuf:protoc:${project.PROTOBUF_VERSION}"; - MAVEN_REPOSITORY_URL = 'http://maven.teamdev.com/repository/spine'; - SPINE_PROTOBUF_PLUGIN_VERSION = "1.4.8" - GRPC_VERSION = '0.14.0' - SLF4J_VERSION = '1.7.21' -} +subprojects { -def repositoryUserName = null; -def repositoryUserPassword = null; -final Properties properties = new Properties(); -final File credentialsFile = file(CREDENTIALS_LOCATION); -if (credentialsFile.exists()) { - properties.load(credentialsFile.newDataInputStream()); - repositoryUserName = properties.getProperty("user.name"); - repositoryUserPassword = properties.getProperty("user.password"); -} + project.ext { + SRC_DIR = "$projectDir/src" + GEN_DIR = "$projectDir/generated" -subprojects { + GEN_MAIN_JAVA_DIR = "$GEN_DIR/main/java" + GEN_TEST_JAVA_DIR = "$GEN_DIR/test/java" - buildscript { - repositories { - mavenLocal() - maven { - url = project.MAVEN_REPOSITORY_URL - } - mavenCentral() - } + GEN_MAIN_GRPC_DIR = "$GEN_DIR/main/grpc" + GEN_TEST_GRPC_DIR = "$GEN_DIR/test/grpc" + + GEN_MAIN_SPINE_DIR = "$GEN_DIR/main/spine" + + TEST_ARTIFACTS_PLUGIN_PATH = '../gradle/plugins/test-artifacts.gradle' + GEN_DESCRIPTOR_SET_PLUGIN_PATH = '../gradle/plugins/generate-descriptor-set.gradle' + GRPC_PLUGIN_PATH = '../gradle/plugins/grpc.gradle' + JACOCO_PLUGIN_PATH = '../gradle/plugins/jacoco.gradle' } - apply plugin: 'java'; - apply plugin: 'com.google.protobuf'; + apply plugin: 'java' + apply plugin: 'com.google.protobuf' + apply from: JACOCO_PLUGIN_PATH - sourceCompatibility = 1.7; - targetCompatibility = 1.7; + sourceCompatibility = 1.7 + targetCompatibility = 1.7 // Set Java home to point to JDK7 in gradle.properties file. // @@ -68,7 +77,6 @@ subprojects { repositories { mavenLocal() mavenCentral() - jcenter() } dependencies { @@ -88,24 +96,19 @@ subprojects { exclude(module: 'hamcrest-core') } testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3' - testCompile 'org.mockito:mockito-core:2.+' + testCompile group: 'org.mockito', name: 'mockito-core', version: '2.+' } - final String SRC_ROOT_DIR = "$projectDir/src"; - final String GEN_ROOT_DIR = "$projectDir/generated"; - final String GEN_MAIN_JAVA_DIR = "${GEN_ROOT_DIR}/main/java"; - final String GEN_TEST_JAVA_DIR = "${GEN_ROOT_DIR}/test/java"; - sourceSets { main { - proto.srcDirs = ["${SRC_ROOT_DIR}/main/proto"] - java.srcDirs = [GEN_MAIN_JAVA_DIR, "${SRC_ROOT_DIR}/main/java"] - resources.srcDirs = ["${GEN_ROOT_DIR}/main/resources"] + proto.srcDirs = ["$SRC_DIR/main/proto"] + java.srcDirs = [GEN_MAIN_JAVA_DIR, "$SRC_DIR/main/java"] + resources.srcDirs = ["$GEN_DIR/main/resources"] } test { - proto.srcDirs = ["${SRC_ROOT_DIR}/test/proto"] - java.srcDirs = [GEN_TEST_JAVA_DIR, "${SRC_ROOT_DIR}/test/java"] - resources.srcDirs = ["${GEN_ROOT_DIR}/test/resources"] + proto.srcDirs = ["$SRC_DIR/test/proto"] + java.srcDirs = [GEN_TEST_JAVA_DIR, "$SRC_DIR/test/java"] + resources.srcDirs = ["$GEN_DIR/test/resources"] } } @@ -115,7 +118,7 @@ subprojects { artifact = "io.grpc:protoc-gen-grpc-java:$GRPC_VERSION" } } - generatedFilesBaseDir = GEN_ROOT_DIR + generatedFilesBaseDir = GEN_DIR protoc { artifact = project.PROTOBUF_DEPENDENCY } @@ -131,15 +134,6 @@ subprojects { classifier "test" } - jacocoTestReport { - reports { - xml.enabled = true - html.enabled = true - } - } - - check.dependsOn jacocoTestReport - idea.module.iml { beforeMerged { final module -> module.dependencies.clear() @@ -150,8 +144,8 @@ subprojects { } idea.module { - generatedSourceDirs += file(GEN_MAIN_JAVA_DIR); - testSourceDirs += file(GEN_TEST_JAVA_DIR); + generatedSourceDirs += file(GEN_MAIN_JAVA_DIR) + testSourceDirs += file(GEN_TEST_JAVA_DIR) } } @@ -166,59 +160,4 @@ idea.project.ipr { } } -task readPublishingCredentials << { - if (repositoryUserName == null || repositoryUserPassword == null) { - throw new InvalidUserDataException("Please set up valid credentials. " + - "Credentials should be set in ${CREDENTIALS_LOCATION} file in the project\'s root."); - } - println "Publishing build as ${repositoryUserName}"; -} - -task publish << {} - -void dependPublish(final Project project) { - final Set credentialsTasks = getTasksByName("readPublishingCredentials", false); - project.getTasksByName("publish", false).each { final task -> - task.dependsOn credentialsTasks; - } - publish.dependsOn project.getTasksByName("publish", false); -} - -// Artifacts to publish -final def publishingProjects = ["client", "server", "values", "testutil"]; - -publishingProjects.each { - project(":$it") { final currentProject -> - - apply plugin: 'maven-publish'; - - publishing { - publications { - mavenJava(MavenPublication) { - groupId = "${group}"; - artifactId = "${currentProject.name}"; - version = "${currentProject.version}"; - - from components.java; - - artifact sourceJar; - artifact testOutputJar; - } - } - } - - publishing { - repositories { - maven { - credentials { - username = "${repositoryUserName}"; - password = "${repositoryUserPassword}"; - } - url = project.MAVEN_REPOSITORY_URL; - } - } - } - - dependPublish(project); - } -} +apply from: PUBLISH_PLUGIN_PATH diff --git a/client/build.gradle b/client/build.gradle index 408482968db..5110c8a82a1 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -1,53 +1,14 @@ -buildscript { - configurations.all { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' - } - dependencies { - classpath group: 'org.spine3.tools', name: 'protobuf-plugin', version: "$SPINE_PROTOBUF_PLUGIN_VERSION", changing: true - } -} dependencies { - compile group: 'io.grpc', name: 'grpc-okhttp', version: "$GRPC_VERSION" - compile group: 'io.grpc', name: 'grpc-protobuf', version: "$GRPC_VERSION" - compile group: 'io.grpc', name: 'grpc-stub', version: "$GRPC_VERSION" + compile group: 'io.grpc', name: 'grpc-okhttp', version: GRPC_VERSION + compile group: 'io.grpc', name: 'grpc-protobuf', version: GRPC_VERSION + compile group: 'io.grpc', name: 'grpc-stub', version: GRPC_VERSION - testCompile project(path: ":testutil", configuration: 'testArtifacts') + testCompile project(path: ":testutil") } -apply plugin: 'org.spine3.tools.protobuf-plugin'; +apply from: GRPC_PLUGIN_PATH -sourceSets { - main { - proto { - srcDirs += ["${project(":client").projectDir}/src/main/proto"] - } - java { - srcDir "$projectDir/generated/main/grpc" - } - } -} +apply from: TEST_ARTIFACTS_PLUGIN_PATH -protobuf { - generateProtoTasks { - all().each { final task -> - task.plugins { - grpc {} - } - } - } -} - -// required for usage of test classes from other modules -configurations { - testArtifacts.extendsFrom testRuntime -} - -task testJar(type: Jar) { - classifier "test" - from sourceSets.test.output -} - -artifacts { - testArtifacts testJar -} +apply plugin: SPINE_PROTOBUF_PLUGIN_ID diff --git a/examples/build.gradle b/examples/build.gradle index d8c8256f7d8..f2d72c1026a 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -1,39 +1,11 @@ -buildscript { - configurations.all { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' - } - dependencies { - classpath group: 'org.spine3.tools', name: 'protobuf-plugin', version: "$SPINE_PROTOBUF_PLUGIN_VERSION", changing: true - } -} dependencies { - testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile project(path: ":client", configuration: 'testArtifacts') - testCompile project(path: ":server", configuration: 'testArtifacts') - - compile project(path: ':client'); - compile project(path: ':server'); + compile project(path: ':client') + compile project(path: ':server') } -sourceSets { - main { - java { - srcDir "$projectDir/generated/main/spine" - } - } -} +sourceSets.main.java.srcDir GEN_MAIN_SPINE_DIR -protobuf { - generateProtoTasks { - all().each { final task -> - task.plugins { - task.generateDescriptorSet = true - task.descriptorSetOptions.path = "${projectDir}/build/descriptors/${task.sourceSet.name}.desc" - task.descriptorSetOptions.includeImports = true - } - } - } -} +apply from: GEN_DESCRIPTOR_SET_PLUGIN_PATH -apply plugin: 'org.spine3.tools.protobuf-plugin'; +apply plugin: SPINE_PROTOBUF_PLUGIN_ID diff --git a/gradle/plugins/generate-descriptor-set.gradle b/gradle/plugins/generate-descriptor-set.gradle new file mode 100644 index 00000000000..471a1548779 --- /dev/null +++ b/gradle/plugins/generate-descriptor-set.gradle @@ -0,0 +1,33 @@ +/* + * Copyright 2016, TeamDev Ltd. All rights reserved. + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// Apply this script if it is needed to generate Protobuf descriptor set (special files with `.desc` extension). +// These files may be needed by Gradle plugins to obtain descriptors of `.proto` files of this project. +protobuf { + generateProtoTasks { + all().each { final task -> + task.plugins { + task.generateDescriptorSet = true + task.descriptorSetOptions.path = "$projectDir/build/descriptors/${task.sourceSet.name}.desc" + task.descriptorSetOptions.includeImports = true + } + } + } +} diff --git a/gradle/plugins/grpc.gradle b/gradle/plugins/grpc.gradle new file mode 100644 index 00000000000..93a54475f6e --- /dev/null +++ b/gradle/plugins/grpc.gradle @@ -0,0 +1,35 @@ +/* + * Copyright 2016, TeamDev Ltd. All rights reserved. + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// Apply this script to use `grpc` plugin in `generateProto` tasks. +// This is needed for gRPC services generation. +// Also adds generated gRPC code to the source sets. + +protobuf { + generateProtoTasks { + all().each { final task -> + task.plugins { + grpc {} + } + } + } +} + +sourceSets.main.java.srcDirs += [GEN_MAIN_GRPC_DIR, GEN_TEST_GRPC_DIR] diff --git a/gradle/plugins/jacoco.gradle b/gradle/plugins/jacoco.gradle new file mode 100644 index 00000000000..f21ae6c030c --- /dev/null +++ b/gradle/plugins/jacoco.gradle @@ -0,0 +1,30 @@ +/* + * Copyright 2016, TeamDev Ltd. All rights reserved. + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// Apply this script to enable JaCoCo test report. + +jacocoTestReport { + reports { + xml.enabled = true + html.enabled = true + } +} + +check.dependsOn jacocoTestReport diff --git a/gradle/plugins/publish.gradle b/gradle/plugins/publish.gradle new file mode 100644 index 00000000000..b84254c3d2a --- /dev/null +++ b/gradle/plugins/publish.gradle @@ -0,0 +1,84 @@ +/* + * Copyright 2016, TeamDev Ltd. All rights reserved. + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// Apply this script to add ability to publish the needed artifacts. + +String repositoryUserName = null +String repositoryUserPassword = null + +task readPublishingCredentials << { + final Properties properties = new Properties() + final File credentialsFile = project.file(project.CREDENTIALS_FILE_PATH) + if (credentialsFile.exists()) { + properties.load(credentialsFile.newDataInputStream()) + repositoryUserName = properties.getProperty("user.name") + repositoryUserPassword = properties.getProperty("user.password") + } + if (repositoryUserName == null || repositoryUserPassword == null) { + throw new InvalidUserDataException("Please set up valid credentials. " + + "Credentials must be set in '${project.CREDENTIALS_FILE_PATH}' file in the project\'s root.") + } + println "Publishing build as ${repositoryUserName}" +} + +task publish << {} + +void dependPublish(final Project project) { + final Set credentialsTasks = getTasksByName("readPublishingCredentials", false) + project.getTasksByName("publish", false).each { final task -> + task.dependsOn credentialsTasks + } + publish.dependsOn project.getTasksByName("publish", false) +} + +PROJECTS_TO_PUBLISH.each { + project(":$it") { final currentProject -> + apply plugin: 'maven-publish' + + publishing { + publications { + mavenJava(MavenPublication) { + groupId = "${group}" + artifactId = "${currentProject.name}" + version = "${currentProject.version}" + + from components.java + + artifact sourceJar + artifact testOutputJar + } + } + } + + publishing { + repositories { + maven { + url = 'http://maven.teamdev.com/repository/spine' + credentials { + username = "${repositoryUserName}" + password = "${repositoryUserPassword}" + } + } + } + } + + dependPublish(project) + } +} diff --git a/gradle/plugins/test-artifacts.gradle b/gradle/plugins/test-artifacts.gradle new file mode 100644 index 00000000000..6454974ef1e --- /dev/null +++ b/gradle/plugins/test-artifacts.gradle @@ -0,0 +1,35 @@ +/* + * Copyright 2016, TeamDev Ltd. All rights reserved. + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// Apply this script if it is needed to use test classes of the current project in other projects. +// The dependency looks like this: +// +// testCompile project(path: ":projectWithTests", configuration: 'testArtifacts') +// +configurations { + testArtifacts.extendsFrom testRuntime +} +task testJar(type: Jar) { + classifier "test" + from sourceSets.test.output +} +artifacts { + testArtifacts testJar +} diff --git a/server/build.gradle b/server/build.gradle index 22c295aac30..cd993ffc71d 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -1,55 +1,18 @@ -buildscript { - configurations.all { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' - } - dependencies { - classpath group: 'org.spine3.tools', name: 'protobuf-plugin', version: "$SPINE_PROTOBUF_PLUGIN_VERSION", changing: true - } -} dependencies { - compile group: 'io.grpc', name: 'grpc-all', version: "$GRPC_VERSION" + compile group: 'io.grpc', name: 'grpc-all', version: GRPC_VERSION - compile project(path: ':client'); - compile project(path: ':values'); + compile project(path: ':client') + compile project(path: ':values') testCompile project(path: ":client", configuration: 'testArtifacts') + testCompile project(path: ":testutil") } -apply plugin: 'org.spine3.tools.protobuf-plugin'; +apply from: GRPC_PLUGIN_PATH -sourceSets { - main { - proto { - srcDirs += ["${project(":server").projectDir}/src/main/proto"] - } - java { - srcDir "$projectDir/generated/main/grpc" - } - } -} +apply from: GEN_DESCRIPTOR_SET_PLUGIN_PATH -protobuf { - generateProtoTasks { - all().each { final task -> - task.plugins { - grpc {} - task.generateDescriptorSet = true - task.descriptorSetOptions.path = "${projectDir}/build/descriptors/${task.sourceSet.name}.desc" - task.descriptorSetOptions.includeImports = true - } - } - } -} +apply from: TEST_ARTIFACTS_PLUGIN_PATH -// required for usage of test classes from other modules -configurations { - testArtifacts.extendsFrom testRuntime -} -task testJar(type: Jar) { - classifier "test" - from sourceSets.test.output -} -artifacts { - testArtifacts testJar -} +apply plugin: SPINE_PROTOBUF_PLUGIN_ID diff --git a/server/src/test/java/org/spine3/server/aggregate/EventApplierMethodShould.java b/server/src/test/java/org/spine3/server/aggregate/EventApplierMethodShould.java index 8cde9cc36ca..5d1434a6353 100644 --- a/server/src/test/java/org/spine3/server/aggregate/EventApplierMethodShould.java +++ b/server/src/test/java/org/spine3/server/aggregate/EventApplierMethodShould.java @@ -38,7 +38,7 @@ @SuppressWarnings("InstanceMethodNamingConvention") public class EventApplierMethodShould { - private HandlerMethod.Factory factory = EventApplierMethod.factory(); + private final HandlerMethod.Factory factory = EventApplierMethod.factory(); @Test public void invoke_applier_method() throws InvocationTargetException { @@ -52,12 +52,12 @@ public void invoke_applier_method() throws InvocationTargetException { } @Test + @SuppressWarnings("deprecation") public void have_deprecated_invoke_method_with_context() throws InvocationTargetException { final ValidApplier applierObject = new ValidApplier(); final EventApplierMethod applier = new EventApplierMethod(applierObject.getMethod()); final ProjectCreated event = Given.EventMessage.projectCreated(); - //noinspection deprecation applier.invoke(applierObject, event, Empty.getDefaultInstance()); assertEquals(event, applierObject.eventApplied); @@ -165,7 +165,7 @@ private static void assertIsEventApplier(Method applier) { private static void assertIsNotEventApplier(Method applier) { assertFalse(EventApplierMethod.PREDICATE.apply(applier)); } - + /* * Valid appliers ****************/ diff --git a/server/src/test/java/org/spine3/server/bc/BoundedContextShould.java b/server/src/test/java/org/spine3/server/bc/BoundedContextShould.java index e1096516990..f1811959be2 100644 --- a/server/src/test/java/org/spine3/server/bc/BoundedContextShould.java +++ b/server/src/test/java/org/spine3/server/bc/BoundedContextShould.java @@ -66,7 +66,6 @@ import static com.google.common.collect.Lists.newArrayList; import static org.junit.Assert.*; -import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; import static org.spine3.base.Responses.ok; import static org.spine3.protobuf.AnyPacker.unpack; diff --git a/server/src/test/java/org/spine3/server/command/CommandBusShould.java b/server/src/test/java/org/spine3/server/command/CommandBusShould.java index b9dec82bcd3..477c61683c6 100644 --- a/server/src/test/java/org/spine3/server/command/CommandBusShould.java +++ b/server/src/test/java/org/spine3/server/command/CommandBusShould.java @@ -66,8 +66,6 @@ import static com.google.common.collect.Lists.newLinkedList; import static java.lang.Math.abs; import static org.junit.Assert.*; -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isA; import static org.mockito.Mockito.*; import static org.spine3.base.CommandStatus.SCHEDULED; import static org.spine3.base.CommandValidationError.*; diff --git a/server/src/test/java/org/spine3/server/event/EventBusShould.java b/server/src/test/java/org/spine3/server/event/EventBusShould.java index 2d2e0cd6f81..a728abc32bf 100644 --- a/server/src/test/java/org/spine3/server/event/EventBusShould.java +++ b/server/src/test/java/org/spine3/server/event/EventBusShould.java @@ -47,7 +47,6 @@ import static com.google.common.collect.Lists.newArrayList; import static org.junit.Assert.*; -import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; @SuppressWarnings("InstanceMethodNamingConvention") diff --git a/server/src/test/java/org/spine3/server/procman/ProcessManagerShould.java b/server/src/test/java/org/spine3/server/procman/ProcessManagerShould.java index 4a19224032a..fc5ccbd900d 100644 --- a/server/src/test/java/org/spine3/server/procman/ProcessManagerShould.java +++ b/server/src/test/java/org/spine3/server/procman/ProcessManagerShould.java @@ -53,7 +53,6 @@ import java.util.Set; import static org.junit.Assert.*; -import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; import static org.spine3.base.Commands.getMessage; import static org.spine3.protobuf.AnyPacker.unpack; diff --git a/testutil/build.gradle b/testutil/build.gradle index 7aa20b77985..607eaf38a05 100644 --- a/testutil/build.gradle +++ b/testutil/build.gradle @@ -4,19 +4,5 @@ dependencies { // that are based on JUnit. compile group: 'junit', name: 'junit', version: '4.12' - compile project(path: ':client'); + compile project(path: ':client') } - -// required for usage of test classes from other modules -configurations { - testArtifacts.extendsFrom testRuntime -} - -task testJar(type: Jar) { - classifier "test" - from sourceSets.test.output -} -artifacts { - testArtifacts testJar -} - diff --git a/values/build.gradle b/values/build.gradle index 582fd7b9183..1ab82b0fecc 100644 --- a/values/build.gradle +++ b/values/build.gradle @@ -1,40 +1,10 @@ -buildscript { - configurations.all { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' - } - dependencies { - classpath group: 'org.spine3.tools', name: 'protobuf-plugin', version: "$SPINE_PROTOBUF_PLUGIN_VERSION", changing: true - } -} - dependencies { - testCompile project(path: ":client", configuration: 'testArtifacts') + compile project(path: ':client') - compile project(path: ':client'); + testCompile project(path: ":testutil") } -apply plugin: 'org.spine3.tools.protobuf-plugin'; +apply from: GEN_DESCRIPTOR_SET_PLUGIN_PATH -sourceSets { - main { - proto { - srcDirs += ["${project(":values").projectDir}/src/main/proto"] - } - java { - srcDir "$projectDir/generated/main/grpc" - } - } -} - -protobuf { - generateProtoTasks { - all().each { final task -> - task.plugins { - task.generateDescriptorSet = true - task.descriptorSetOptions.path = "${projectDir}/build/descriptors/${task.sourceSet.name}.desc" - task.descriptorSetOptions.includeImports = true - } - } - } -} +apply plugin: SPINE_PROTOBUF_PLUGIN_ID