1- final String CREDENTIALS_LOCATION = ' credentials.properties' ;
1+
2+ project. ext {
3+ // NOTE: when updating Protobuf dependency, please check that KnownTypes.addStandardProtobufTypes() method
4+ // is updated with new Message types introduced in the new version of Protobuf.
5+ PROTOBUF_VERSION = ' 3.0.0-beta-3'
6+ PROTOBUF_DEPENDENCY = " com.google.protobuf:protoc:${ PROTOBUF_VERSION} "
7+ GRPC_VERSION = ' 0.14.0'
8+ SLF4J_VERSION = ' 1.7.21'
9+
10+ SPINE_PROTOBUF_PLUGIN_ID = ' org.spine3.tools.protobuf-plugin'
11+ PUBLISH_PLUGIN_PATH = " $projectDir /gradle/plugins/publish.gradle"
12+
13+ CREDENTIALS_FILE_PATH = ' credentials.properties'
14+ PROJECTS_TO_PUBLISH = [" client" , " server" , " values" , " testutil" ]
15+ }
216
317buildscript {
418 repositories {
519 mavenCentral()
620 mavenLocal()
21+ maven {
22+ url = ' http://maven.teamdev.com/repository/spine'
23+ }
724 }
825 dependencies {
9- classpath ' com.google.protobuf:protobuf-gradle-plugin:0.7.7'
26+ classpath group : ' com.google.protobuf' , name :' protobuf-gradle-plugin' , version : ' 0.7.7'
27+ classpath group : ' org.spine3.tools' , name : ' protobuf-plugin' , version : ' 1.4.8' , changing : true
1028 }
29+ configurations. all({
30+ resolutionStrategy. cacheChangingModulesFor(0 , ' seconds' )
31+ })
1132}
1233
1334allprojects {
@@ -19,44 +40,32 @@ allprojects {
1940 version = ' 0.5.1-SNAPSHOT'
2041}
2142
22- project. ext {
23- // NOTE: when updating Protobuf dependency, please check that KnownTypes.addStandardProtobufTypes() method
24- // is updated with new Message types introduced in the new version of Protobuf.
25- PROTOBUF_VERSION = ' 3.0.0-beta-3' ;
26- PROTOBUF_DEPENDENCY = " com.google.protobuf:protoc:${ project.PROTOBUF_VERSION} " ;
27- MAVEN_REPOSITORY_URL = ' http://maven.teamdev.com/repository/spine' ;
28- SPINE_PROTOBUF_PLUGIN_VERSION = " 1.4.8"
29- GRPC_VERSION = ' 0.14.0'
30- SLF4J_VERSION = ' 1.7.21'
31- }
43+ subprojects {
3244
33- def repositoryUserName = null ;
34- def repositoryUserPassword = null ;
35- final Properties properties = new Properties ();
36- final File credentialsFile = file(CREDENTIALS_LOCATION );
37- if (credentialsFile. exists()) {
38- properties. load(credentialsFile. newDataInputStream());
39- repositoryUserName = properties. getProperty(" user.name" );
40- repositoryUserPassword = properties. getProperty(" user.password" );
41- }
45+ project. ext {
46+ SRC_DIR = " $projectDir /src"
47+ GEN_DIR = " $projectDir /generated"
4248
43- subprojects {
49+ GEN_MAIN_JAVA_DIR = " $GEN_DIR /main/java"
50+ GEN_TEST_JAVA_DIR = " $GEN_DIR /test/java"
4451
45- buildscript {
46- repositories {
47- mavenLocal()
48- maven {
49- url = project. MAVEN_REPOSITORY_URL
50- }
51- mavenCentral()
52- }
52+ GEN_MAIN_GRPC_DIR = " $GEN_DIR /main/grpc"
53+ GEN_TEST_GRPC_DIR = " $GEN_DIR /test/grpc"
54+
55+ GEN_MAIN_SPINE_DIR = " $GEN_DIR /main/spine"
56+
57+ TEST_ARTIFACTS_PLUGIN_PATH = ' ../gradle/plugins/test-artifacts.gradle'
58+ GEN_DESCRIPTOR_SET_PLUGIN_PATH = ' ../gradle/plugins/generate-descriptor-set.gradle'
59+ GRPC_PLUGIN_PATH = ' ../gradle/plugins/grpc.gradle'
60+ JACOCO_PLUGIN_PATH = ' ../gradle/plugins/jacoco.gradle'
5361 }
5462
55- apply plugin : ' java' ;
56- apply plugin : ' com.google.protobuf' ;
63+ apply plugin : ' java'
64+ apply plugin : ' com.google.protobuf'
65+ apply from : JACOCO_PLUGIN_PATH
5766
58- sourceCompatibility = 1.7 ;
59- targetCompatibility = 1.7 ;
67+ sourceCompatibility = 1.7
68+ targetCompatibility = 1.7
6069
6170 // Set Java home to point to JDK7 in gradle.properties file.
6271 //
@@ -68,7 +77,6 @@ subprojects {
6877 repositories {
6978 mavenLocal()
7079 mavenCentral()
71- jcenter()
7280 }
7381
7482 dependencies {
@@ -88,24 +96,19 @@ subprojects {
8896 exclude(module : ' hamcrest-core' )
8997 }
9098 testCompile group : ' org.hamcrest' , name : ' hamcrest-all' , version : ' 1.3'
91- testCompile ' org.mockito: mockito-core: 2.+'
99+ testCompile group : ' org.mockito' , name : ' mockito-core' , version : ' 2.+'
92100 }
93101
94- final String SRC_ROOT_DIR = " $projectDir /src" ;
95- final String GEN_ROOT_DIR = " $projectDir /generated" ;
96- final String GEN_MAIN_JAVA_DIR = " ${ GEN_ROOT_DIR} /main/java" ;
97- final String GEN_TEST_JAVA_DIR = " ${ GEN_ROOT_DIR} /test/java" ;
98-
99102 sourceSets {
100103 main {
101- proto. srcDirs = [" ${ SRC_ROOT_DIR } /main/proto" ]
102- java. srcDirs = [GEN_MAIN_JAVA_DIR , " ${ SRC_ROOT_DIR } /main/java" ]
103- resources. srcDirs = [" ${ GEN_ROOT_DIR } /main/resources" ]
104+ proto. srcDirs = [" $S RC_DIR /main/proto" ]
105+ java. srcDirs = [GEN_MAIN_JAVA_DIR , " $S RC_DIR /main/java" ]
106+ resources. srcDirs = [" $G EN_DIR /main/resources" ]
104107 }
105108 test {
106- proto. srcDirs = [" ${ SRC_ROOT_DIR } /test/proto" ]
107- java. srcDirs = [GEN_TEST_JAVA_DIR , " ${ SRC_ROOT_DIR } /test/java" ]
108- resources. srcDirs = [" ${ GEN_ROOT_DIR } /test/resources" ]
109+ proto. srcDirs = [" $S RC_DIR /test/proto" ]
110+ java. srcDirs = [GEN_TEST_JAVA_DIR , " $S RC_DIR /test/java" ]
111+ resources. srcDirs = [" $G EN_DIR /test/resources" ]
109112 }
110113 }
111114
@@ -115,7 +118,7 @@ subprojects {
115118 artifact = " io.grpc:protoc-gen-grpc-java:$GRPC_VERSION "
116119 }
117120 }
118- generatedFilesBaseDir = GEN_ROOT_DIR
121+ generatedFilesBaseDir = GEN_DIR
119122 protoc {
120123 artifact = project. PROTOBUF_DEPENDENCY
121124 }
@@ -131,15 +134,6 @@ subprojects {
131134 classifier " test"
132135 }
133136
134- jacocoTestReport {
135- reports {
136- xml. enabled = true
137- html. enabled = true
138- }
139- }
140-
141- check. dependsOn jacocoTestReport
142-
143137 idea. module. iml {
144138 beforeMerged { final module ->
145139 module. dependencies. clear()
@@ -150,8 +144,8 @@ subprojects {
150144 }
151145
152146 idea. module {
153- generatedSourceDirs + = file(GEN_MAIN_JAVA_DIR );
154- testSourceDirs + = file(GEN_TEST_JAVA_DIR );
147+ generatedSourceDirs + = file(GEN_MAIN_JAVA_DIR )
148+ testSourceDirs + = file(GEN_TEST_JAVA_DIR )
155149 }
156150}
157151
@@ -166,59 +160,4 @@ idea.project.ipr {
166160 }
167161}
168162
169- task readPublishingCredentials << {
170- if (repositoryUserName == null || repositoryUserPassword == null ) {
171- throw new InvalidUserDataException (" Please set up valid credentials. " +
172- " Credentials should be set in ${ CREDENTIALS_LOCATION} file in the project\' s root." );
173- }
174- println " Publishing build as ${ repositoryUserName} " ;
175- }
176-
177- task publish << {}
178-
179- void dependPublish (final Project project ) {
180- final Set<Task > credentialsTasks = getTasksByName(" readPublishingCredentials" , false );
181- project. getTasksByName(" publish" , false ). each { final task ->
182- task. dependsOn credentialsTasks;
183- }
184- publish. dependsOn project. getTasksByName(" publish" , false );
185- }
186-
187- // Artifacts to publish
188- final def publishingProjects = [" client" , " server" , " values" , " testutil" ];
189-
190- publishingProjects. each {
191- project(" :$it " ) { final currentProject ->
192-
193- apply plugin : ' maven-publish' ;
194-
195- publishing {
196- publications {
197- mavenJava(MavenPublication ) {
198- groupId = " ${ group} " ;
199- artifactId = " ${ currentProject.name} " ;
200- version = " ${ currentProject.version} " ;
201-
202- from components. java;
203-
204- artifact sourceJar;
205- artifact testOutputJar;
206- }
207- }
208- }
209-
210- publishing {
211- repositories {
212- maven {
213- credentials {
214- username = " ${ repositoryUserName} " ;
215- password = " ${ repositoryUserPassword} " ;
216- }
217- url = project. MAVEN_REPOSITORY_URL ;
218- }
219- }
220- }
221-
222- dependPublish(project);
223- }
224- }
163+ apply from : PUBLISH_PLUGIN_PATH
0 commit comments