Skip to content

Commit 538eabf

Browse files
authored
feat(internal/config): support libraries bom version and default java module (#4838)
Support for specifying a libraries_bom_version in the Java configuration. It adds a default java module to the Default configuration struct to allow shared Java settings across all libraries. Updated the Java migration tool (tool/cmd/migrate/java.go) to parse libraries_bom_version from generation_config.yaml and include it in the generated librarian.yaml. This version info is needed in README.md generation. For #4306 For #4308
1 parent 71f7d3b commit 538eabf

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

doc/config-schema.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ This document describes the schema for the librarian.yaml.
6161
| `tag_format` | string | Is the template for git tags, such as "{name}/v{version}". |
6262
| `dotnet` | [DotnetPackage](#dotnetpackage-configuration) (optional) | Contains .NET-specific default configuration. |
6363
| `dart` | [DartPackage](#dartpackage-configuration) (optional) | Contains Dart-specific default configuration. |
64+
| `java` | [JavaModule](#javamodule-configuration) (optional) | Contains Java-specific default configuration. |
6465
| `nodejs` | [NodejsPackage](#nodejspackage-configuration) (optional) | Contains Node.js-specific default configuration. |
6566
| `rust` | [RustDefault](#rustdefault-configuration) (optional) | Contains Rust-specific default configuration. |
6667
| `python` | [PythonDefault](#pythondefault-configuration) (optional) | Contains Python-specific default configuration. |
@@ -225,6 +226,7 @@ This document describes the schema for the librarian.yaml.
225226
| `extra_versioned_modules` | string | Is a list of extra versioned modules. |
226227
| `group_id` | string | Is the Maven group ID, defaults to "com.google.cloud". |
227228
| `issue_tracker_override` | string | Allows the "issue_tracker" field in .repo-metadata.json to be overridden. |
229+
| `libraries_bom_version` | string | Is the version of the libraries-bom to use for Java. |
228230
| `library_type_override` | string | Allows the "library_type" field in .repo-metadata.json to be overridden. |
229231
| `min_java_version` | int | Is the minimum Java version required. |
230232
| `name_pretty_override` | string | Allows the "name_pretty" field in .repo-metadata.json to be overridden. |

internal/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ type Default struct {
142142
// Dart contains Dart-specific default configuration.
143143
Dart *DartPackage `yaml:"dart,omitempty"`
144144

145+
// Java contains Java-specific default configuration.
146+
Java *JavaModule `yaml:"java,omitempty"`
147+
145148
// Nodejs contains Node.js-specific default configuration.
146149
Nodejs *NodejsPackage `yaml:"nodejs,omitempty"`
147150

internal/config/language.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,9 @@ type JavaModule struct {
522522
// to be overridden.
523523
IssueTrackerOverride string `yaml:"issue_tracker_override,omitempty"`
524524

525+
// LibrariesBomVersion is the version of the libraries-bom to use for Java.
526+
LibrariesBomVersion string `yaml:"libraries_bom_version,omitempty"`
527+
525528
// LibraryTypeOverride allows the "library_type" field in .repo-metadata.json
526529
// to be overridden.
527530
LibraryTypeOverride string `yaml:"library_type_override,omitempty"`

tool/cmd/migrate/java.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ type LibraryConfig struct {
123123
// GenerationConfig represents the root of generation_config.yaml.
124124
type GenerationConfig struct {
125125
GoogleapisCommitish string `yaml:"googleapis_commitish"`
126+
LibrariesBomVersion string `yaml:"libraries_bom_version"`
126127
Libraries []LibraryConfig `yaml:"libraries"`
127128
}
128129

@@ -260,6 +261,11 @@ func buildConfig(gen *GenerationConfig, repoPath string, src *config.Source, ver
260261
}
261262
return &config.Config{
262263
Language: "java",
264+
Default: &config.Default{
265+
Java: &config.JavaModule{
266+
LibrariesBomVersion: gen.LibrariesBomVersion,
267+
},
268+
},
263269
Sources: &config.Sources{
264270
Googleapis: src,
265271
},

tool/cmd/migrate/java_test.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ func TestBuildConfig(t *testing.T) {
9191
want: &config.Config{
9292
Language: "java",
9393
Repo: "googleapis/google-cloud-java",
94-
94+
Default: &config.Default{
95+
Java: &config.JavaModule{},
96+
},
9597
Sources: &config.Sources{
9698
Googleapis: &config.Source{Dir: "../../internal/testdata/googleapis"},
9799
},
@@ -121,7 +123,9 @@ func TestBuildConfig(t *testing.T) {
121123
want: &config.Config{
122124
Language: "java",
123125
Repo: "googleapis/google-cloud-java",
124-
126+
Default: &config.Default{
127+
Java: &config.JavaModule{},
128+
},
125129
Sources: &config.Sources{
126130
Googleapis: &config.Source{Dir: "../../internal/testdata/googleapis"},
127131
},
@@ -157,7 +161,9 @@ func TestBuildConfig(t *testing.T) {
157161
want: &config.Config{
158162
Language: "java",
159163
Repo: "googleapis/google-cloud-java",
160-
164+
Default: &config.Default{
165+
Java: &config.JavaModule{},
166+
},
161167
Sources: &config.Sources{
162168
Googleapis: &config.Source{Dir: "../../internal/testdata/googleapis"},
163169
},
@@ -182,6 +188,7 @@ func TestBuildConfig(t *testing.T) {
182188
{
183189
name: "all java fields and overrides",
184190
gen: &GenerationConfig{
191+
LibrariesBomVersion: "1.2.3",
185192
Libraries: []LibraryConfig{
186193
{
187194
LibraryName: "pubsub",
@@ -217,7 +224,11 @@ func TestBuildConfig(t *testing.T) {
217224
want: &config.Config{
218225
Language: "java",
219226
Repo: "googleapis/google-cloud-java",
220-
227+
Default: &config.Default{
228+
Java: &config.JavaModule{
229+
LibrariesBomVersion: "1.2.3",
230+
},
231+
},
221232
Sources: &config.Sources{
222233
Googleapis: &config.Source{Dir: "../../internal/testdata/googleapis"},
223234
},
@@ -280,7 +291,9 @@ func TestBuildConfig(t *testing.T) {
280291
want: &config.Config{
281292
Language: "java",
282293
Repo: "googleapis/google-cloud-java",
283-
294+
Default: &config.Default{
295+
Java: &config.JavaModule{},
296+
},
284297
Sources: &config.Sources{
285298
Googleapis: &config.Source{Dir: "../../internal/testdata/googleapis"},
286299
},

0 commit comments

Comments
 (0)