Skip to content

Commit c758ffa

Browse files
tsteinchwarr
authored andcommitted
[java] Allow maven publication and clean up
This commit removes the need for the mvn binary and converts all Java dependencies within the repo to true dependencies, rather than file references. It also generates automatic versions for the core and gradle-plugin projects from git tags.
1 parent 91c3991 commit c758ffa

File tree

25 files changed

+127
-67
lines changed

25 files changed

+127
-67
lines changed

cmake/FindJavaBuildTools.cmake

-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
find_program (GRADLE_EXECUTABLE gradle)
2-
find_program (MAVEN_EXECUTABLE mvn)
32

43
if (GRADLE_EXECUTABLE)
54
execute_process (
@@ -10,13 +9,3 @@ if (GRADLE_EXECUTABLE)
109
else()
1110
message (FATAL_ERROR "gradle was not found. Java code cannot be built.")
1211
endif()
13-
14-
if (MAVEN_EXECUTABLE)
15-
execute_process (
16-
COMMAND ${MAVEN_EXECUTABLE} --version
17-
OUTPUT_VARIABLE maven_version)
18-
message (STATUS "maven found at ${MAVEN_EXECUTABLE}")
19-
message (STATUS "${maven_version}")
20-
else()
21-
message (FATAL_ERROR "maven was not found. Java code cannot be built.")
22-
endif()

cmake/Java.cmake

-23
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,3 @@ function (add_gradle_build target)
3030
add_target_to_folder("${target}")
3131
add_dependencies(java "${target}")
3232
endfunction()
33-
34-
function (add_maven_install target)
35-
set (oneValueArgs AFTER_BUILD JAR)
36-
cmake_parse_arguments (arg "${flagArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
37-
38-
# The path given to -DpomFile is hard-coded to match the output path of
39-
# gradle's maven plugin.
40-
add_custom_command (
41-
COMMAND
42-
${MAVEN_EXECUTABLE}
43-
install:install-file
44-
-DpomFile=build/poms/pom-default.xml
45-
-Dfile=build/libs/${arg_JAR}
46-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
47-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/build/java/${target})
48-
49-
add_custom_target ("${target}"
50-
DEPENDS ${arg_AFTER_BUILD}
51-
${CMAKE_CURRENT_BINARY_DIR}/build/java/${target})
52-
53-
add_target_to_folder("${target}")
54-
add_dependencies(java "${target}")
55-
endfunction()

examples/java/core/blob/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.BlobExample'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/enumerations/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.Enumerations'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/generic_tree/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.GenericTree'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/generics/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.Generics'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/imports/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.Imports'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/inheritance/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.Inheritance'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/nothing_default/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.NothingDefault'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/polymorphic_container/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.PolymorphicContainer'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/protocol_versions/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.ProtocolVersions'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/record_streaming/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.RecordStreaming'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/runtime_schema/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.RuntimeSchemaExample'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/schema_view/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.SchemaView'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/serialization/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.Serialization'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

examples/java/core/untagged_protocols/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ mainClassName = 'org.bondlib.examples.UntaggedProtocols'
2020
applicationDefaultJvmArgs = ['-ea']
2121

2222
repositories {
23+
mavenLocal()
2324
mavenCentral()
2425
}
2526

2627
dependencies {
27-
compile files('../../../../java/core/build/libs/bond-5.0.0.jar')
28+
compile 'org.bondlib:bond:+'
2829
}
2930

3031
compileBond {

java/compat/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake)
44

55
include (Java)
66

7-
add_gradle_build (java-compat DEPENDS java-core)
7+
add_gradle_build (java-compat
8+
DEPENDS java-core)

java/compat/build.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
14
group 'org.bondlib'
2-
version '1.0'
5+
version '0.0'
36

47
buildscript {
58
repositories {
@@ -18,11 +21,12 @@ apply plugin: 'org.bondlib.gradle'
1821
sourceCompatibility = 1.8
1922

2023
repositories {
24+
mavenLocal()
2125
mavenCentral()
2226
}
2327

2428
dependencies {
25-
compile files('../core/build/libs/bond-5.0.0.jar')
29+
compile 'org.bondlib:bond:+'
2630
testCompile group: 'junit', name: 'junit', version: '4.12'
2731
}
2832

java/core/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake)
44

55
include (Java)
66

7-
add_gradle_build (java-core DEPENDS gradle-plugin-install)
7+
add_gradle_build (java-core
8+
GRADLE_TARGET install
9+
DEPENDS gradle-plugin)

java/core/build.gradle

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright (c) Microsoft. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
group 'org.bondlib'
5-
version = '5.0.0'
6-
74
buildscript {
85
repositories {
96
mavenLocal()
@@ -15,9 +12,18 @@ buildscript {
1512
}
1613
}
1714

15+
plugins {
16+
id 'com.palantir.git-version' version '0.9.1'
17+
}
18+
1819
apply plugin: 'java'
20+
apply plugin: 'maven'
21+
apply plugin: 'maven-publish'
1922
apply plugin: 'org.bondlib.gradle'
2023

24+
group 'org.bondlib'
25+
version gitVersion(prefix:'java@')
26+
2127
sourceCompatibility = 1.6
2228

2329
repositories {
@@ -28,6 +34,26 @@ dependencies {
2834
testCompile 'junit:junit:4.12'
2935
}
3036

37+
publishing {
38+
repositories {
39+
maven {
40+
url 'https://msazure.pkgs.visualstudio.com/_packaging/Bond/maven/v1'
41+
credentials {
42+
username "VSTS"
43+
password project.hasProperty('vstsMavenAccessToken') ? "${vstsMavenAccessToken}" : ''
44+
}
45+
}
46+
}
47+
48+
publications {
49+
mavenJava(MavenPublication) {
50+
from components.java
51+
}
52+
}
53+
}
54+
55+
// Some tests have non-ASCII strings that are UTF-8 encoded. In environments
56+
// with system encodings other than UTF-8, javac will fail on those tests.
3157
compileTestJava {
3258
options.encoding = 'UTF-8'
3359
}

java/gradle-plugin/CMakeLists.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake)
44

55
include (Java)
66

7-
add_gradle_build (gradle-plugin GRADLE_TARGET install)
8-
add_maven_install (gradle-plugin-install
9-
AFTER_BUILD gradle-plugin
10-
JAR bond-gradle-1.0.jar)
7+
add_gradle_build (gradle-plugin
8+
GRADLE_TARGET install)

java/gradle-plugin/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ containing this README and repeat as follows:
33

44
* write some code
55
* `gradle build install`
6-
* `mvn install:install-file -Dfile=build/libs/bond-gradle-1.0.jar -DpomFile=build/poms/pom-default.xml`
76

87
This will install the plugin to your local maven repository, which the other
98
Java projects' build.gradles will use in preference to maven central.

java/gradle-plugin/build.gradle

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
plugins {
5+
id 'com.palantir.git-version' version '0.9.1'
6+
}
7+
18
apply plugin: 'groovy'
29
apply plugin: 'maven'
10+
apply plugin: 'maven-publish'
311

412
group 'org.bondlib'
5-
version '1.0'
13+
version gitVersion(prefix:'java@')
614

715
dependencies {
816
compile localGroovy()
917
compile gradleApi()
1018
}
1119

12-
jar {
20+
publishing {
21+
repositories {
22+
maven {
23+
url 'https://msazure.pkgs.visualstudio.com/_packaging/Bond/maven/v1'
24+
credentials {
25+
username "VSTS"
26+
password project.hasProperty('vstsMavenAccessToken') ? "${vstsMavenAccessToken}" : ''
27+
}
28+
}
29+
}
30+
31+
publications {
32+
mavenJava(MavenPublication) {
33+
from components.java
34+
}
35+
}
1336
}

0 commit comments

Comments
 (0)