From a62012e3280238b4c794bbe484b296af3b8fb53a Mon Sep 17 00:00:00 2001 From: JKatzwinkel Date: Mon, 29 Jul 2024 22:19:56 +0200 Subject: [PATCH] fix(package): support alternative gradle module version syntax (#6080) feat(package): support alternative gradle module version syntax (#6079) --- src/modules/package.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/modules/package.rs b/src/modules/package.rs index f6146136..edc9fbe7 100644 --- a/src/modules/package.rs +++ b/src/modules/package.rs @@ -110,7 +110,7 @@ fn get_gradle_version(context: &Context, config: &PackageConfig) -> Option[^'"]+)['"]$"#).unwrap(); /*dark magic*/ + let re = Regex::new(r#"(?m)^version( |\s*=\s*)['"](?P[^'"]+)['"]$"#).unwrap(); /*dark magic*/ let caps = re.captures(&build_file_contents)?; format_version(&caps["version"], config.version_format) @@ -921,6 +921,25 @@ java { project_dir.close() } + #[test] + fn test_extract_gradle_version_setter_notation_single_quote() -> io::Result<()> { + let config_name = "build.gradle"; + let config_content = "plugins { + id 'java' + id 'test.plugin' version '0.2.0' +} +version = '0.1.0' +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +}"; + + let project_dir = create_project_dir()?; + fill_config(&project_dir, config_name, Some(config_content))?; + expect_output(&project_dir, Some("v0.1.0"), None); + project_dir.close() + } + #[test] fn test_extract_gradle_version_double_quote() -> io::Result<()> { let config_name = "build.gradle";