diff --git a/src/modules/package.rs b/src/modules/package.rs index 7a2e88a9..d741ad1f 100644 --- a/src/modules/package.rs +++ b/src/modules/package.rs @@ -105,7 +105,7 @@ fn get_gradle_version(context: &Context, config: &PackageConfig) -> Option.*)").unwrap(); + let re = Regex::new(r"(?m)^\s*version\s*=\s*(?P.*)").unwrap(); let caps = re.captures(&contents)?; format_version(&caps["version"], config.version_format) }).or_else(|| { @@ -979,6 +979,18 @@ java { expect_output(&project_dir, Some("v1.2.3"), None); project_dir.close() } + #[test] + fn test_extract_grade_version_from_properties_with_comment_and_whitespace() -> io::Result<()> { + let config_name = "gradle.properties"; + let config_content = " + # or use -Pversion=0.0.1 + version = 1.2.3 + "; + let project_dir = create_project_dir()?; + fill_config(&project_dir, config_name, Some(config_content))?; + expect_output(&project_dir, Some("v1.2.3"), None); + project_dir.close() + } #[test] fn test_extract_mix_version() -> io::Result<()> {