@@ -29,26 +29,25 @@ public void apply(@Nonnull Project rootProject) {
29
29
GitVersioningPluginExtension config = rootProject .getExtensions ()
30
30
.create ("gitVersioning" , GitVersioningPluginExtension .class , rootProject );
31
31
32
- if (parseBoolean (getOption (rootProject , OPTION_NAME_DISABLE ))) {
32
+ if (parseBoolean (getCommandOption (rootProject , OPTION_NAME_DISABLE ))) {
33
33
rootProject .getLogger ().warn ("skip - versioning is disabled" );
34
34
return ;
35
35
}
36
36
37
37
rootProject .afterEvaluate (evaluatedProject -> {
38
38
39
39
GitRepoSituation repoSituation = GitUtil .situation (rootProject .getProjectDir ());
40
- String providedTag = getOption (rootProject , OPTION_NAME_GIT_TAG );
40
+ String providedTag = getCommandOption (rootProject , OPTION_NAME_GIT_TAG );
41
41
if (providedTag != null ) {
42
42
repoSituation .setHeadBranch (null );
43
43
repoSituation .setHeadTags (providedTag .isEmpty () ? emptyList () : singletonList (providedTag ));
44
44
}
45
- String providedBranch = getOption (rootProject , OPTION_NAME_GIT_BRANCH );
45
+ String providedBranch = getCommandOption (rootProject , OPTION_NAME_GIT_BRANCH );
46
46
if (providedBranch != null ) {
47
47
repoSituation .setHeadBranch (providedBranch .isEmpty () ? null : providedBranch );
48
48
}
49
49
50
- final boolean preferTags = config .preferTags || parseBoolean (getOption (rootProject , OPTION_PREFER_TAGS ));
51
-
50
+ final boolean preferTagsOption = getPreferTagsOption (rootProject , config );
52
51
GitVersionDetails gitVersionDetails = GitVersioning .determineVersion (repoSituation ,
53
52
ofNullable (config .commit )
54
53
.map (it -> new VersionDescription (null , it .versionFormat , mapPropertyDescription (it .properties )))
@@ -59,7 +58,7 @@ public void apply(@Nonnull Project rootProject) {
59
58
config .tags .stream ()
60
59
.map (it -> new VersionDescription (it .pattern , it .versionFormat , mapPropertyDescription (it .properties )))
61
60
.collect (toList ()),
62
- preferTags );
61
+ preferTagsOption );
63
62
64
63
65
64
final Map <String , Object > originVersionMap = rootProject .getAllprojects ().stream ().collect (Collectors .toMap (Project ::getPath , p -> p .getVersion ()));
@@ -130,7 +129,7 @@ private PropertyValueDescription mapPropertyValueDescription(GitVersioningPlugin
130
129
.map (it -> new PropertyValueDescription (it .pattern , it .format )).get ();
131
130
}
132
131
133
- private String getOption (final Project project , final String name ) {
132
+ private String getCommandOption (final Project project , final String name ) {
134
133
String value = (String ) project .getProperties ().get (name );
135
134
if (value == null ) {
136
135
String plainName = name .replaceFirst ("^versioning\\ ." , "" );
@@ -142,5 +141,16 @@ private String getOption(final Project project, final String name) {
142
141
}
143
142
return value ;
144
143
}
144
+
145
+ private boolean getPreferTagsOption (final Project rootProject , final GitVersioningPluginExtension config ) {
146
+ final boolean preferTagsOption ;
147
+ final String preferTagsCommandOption = getCommandOption (rootProject , OPTION_PREFER_TAGS );
148
+ if (preferTagsCommandOption != null ){
149
+ preferTagsOption = parseBoolean (preferTagsCommandOption );
150
+ } else {
151
+ preferTagsOption = config .preferTags ;
152
+ }
153
+ return preferTagsOption ;
154
+ }
145
155
}
146
156
0 commit comments