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";