Skip to content

Commit

Permalink
Ignore project's version property when resolving properties in a bom
Browse files Browse the repository at this point in the history
Closes gh-315
  • Loading branch information
wilkinsona committed Mar 18, 2022
1 parent 4eaceff commit 358c8d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,6 +39,9 @@ public ProjectPropertySource(Project project) {

@Override
public String getProperty(String name) {
if ("version".equals(name)) {
return null;
}
if (this.project.hasProperty(name)) {
Object property = this.project.property(name);
if (property != null) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,4 +66,13 @@ public class ProjectPropertySourceSpec extends Specification {
property == null
}

def 'Null is returned when project has null property'() {

This comment has been minimized.

Copy link
@mjustin

mjustin Mar 19, 2022

Looks like this test method name was copy/pasted from the previous one, so it doesn't quite match its functionality and it duplicates the test name of the previous one.

This comment has been minimized.

Copy link
@wilkinsona

wilkinsona Mar 19, 2022

Author Contributor

Well spotted, @mjustin. I'm surprised that the compiler didn't catch this and glad that you did. Thanks.

given: 'A project'
project.version = '1.2.3'
when: 'The version property is retrieved'
def property = this.propertySource.getProperty("version")
then: 'The property is null'
property == null
}

}

0 comments on commit 358c8d9

Please sign in to comment.