Maven 1.x Announcement Plugin

[PATCH] Check if there is a SCM tag set for the project

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Fixed
  • Affects Version/s: 1.3
  • Fix Version/s: 1.3
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    2

Description

As I mentioned earlier in the dev-list, if the POM defines a <versions> element, than the current version should have an equivalent <version> there, otherwise check-version should fail.

If that happens, announcement:check-version will show this message:

Current release (XXX) does not have an entry at the POM's versions element.

– Felipe

Activity

Hide
Felipe Leme added a comment -

Patch that checks if the project's current version is on the POM's versions element.

Show
Felipe Leme added a comment - Patch that checks if the project's current version is on the POM's versions element.
Hide
Vincent Massol added a comment -

Felipe,

I've not tried to apply the patch yet because I have a few questions on the patch code below:

<j:if test="${size(pom.versions)!=0}">
<j:set var="foundTag" value="false"/>
<j:forEach var="version" items="${pom.versions}">
<j:if test="${version.id==versionVariable}">
<j:set var="found" value="true"/>
</j:if>
</j:forEach>
<j:if test="${!found}">

Several comments:

1/ SNAPSHOT versions should NOT be defined in the <versions> tag. Only released version. Thus if current version is a snapshot version I'm not sure your patch will do the correct thing. But then I may be wrong as I'm not sure I fully understand it...
2/ What is foundTag variable for? It doesn't seem to be used
3/ There's no point in iterating once found is true, right? Thus there should probably be a <j:break/> tag

Thanks

Show
Vincent Massol added a comment - Felipe, I've not tried to apply the patch yet because I have a few questions on the patch code below: <j:if test="${size(pom.versions)!=0}"> <j:set var="foundTag" value="false"/> <j:forEach var="version" items="${pom.versions}"> <j:if test="${version.id==versionVariable}"> <j:set var="found" value="true"/> </j:if> </j:forEach> <j:if test="${!found}"> Several comments: 1/ SNAPSHOT versions should NOT be defined in the <versions> tag. Only released version. Thus if current version is a snapshot version I'm not sure your patch will do the correct thing. But then I may be wrong as I'm not sure I fully understand it... 2/ What is foundTag variable for? It doesn't seem to be used 3/ There's no point in iterating once found is true, right? Thus there should probably be a <j:break/> tag Thanks
Hide
Felipe Leme added a comment -

Here are the answers:

> 1. SNAPSHOT versions should NOT be defined in the <versions> tag. Only released version. Thus if current version is a snapshot version I'm not sure your patch will do the correct thing.

If the current version is a SNAPSHOT, it shouldn't be announced, right? In that case, the patch is fine.

> But then I may be wrong as I'm not sure I fully understand it...

The idea is simple: if thet user is making an annoucement for a release and the releases have tags (i.e., there is a <versions> element set), then the current release should be defined there. It follows the same principles of the current announcement-check, which verifies if the current version is detailed on xdocs/changes.xml. I agree that that these assunptions are too agressive - maybe we could add a flag property indicating if the user wants these checkings (if you agree too, please open a new Jira issue and I will provide a patch for that).

> 2. What is foundTag variable for? It doesn't seem to be used

Sorry, found and foundTag are the same

> 3. There's no point in iterating once found is true, right? Thus there should probably be a <j:break/> tag

Sorry again, I wasn't aware of <j:break> (at least this I can justify - JSTL's Core does no provide such tag .

So, I guess the correct loop should be:

<j:if test="${size(pom.versions)!=0}">
<j:set var="foundTag" value="false"/>
<j:forEach var="version" items="${pom.versions}">
<j:if test="${version.id==versionVariable}">
<j:set var="foundTag" value="true"/>
<j:break/>
</j:if>
</j:forEach>
<j:if test="${!foundTag}">

It would be even simpler if <j:break> offered a var attribute indicating if the look was broke or not:

<j:if test="${size(pom.versions)!=0}">
<j:forEach var="version" items="${pom.versions}">
<j:break var="foundTag" test="${version.id==versionVariable}"/>
</j:forEach>
<j:if test="${!foundTag}">

Felipe

Show
Felipe Leme added a comment - Here are the answers: > 1. SNAPSHOT versions should NOT be defined in the <versions> tag. Only released version. Thus if current version is a snapshot version I'm not sure your patch will do the correct thing. If the current version is a SNAPSHOT, it shouldn't be announced, right? In that case, the patch is fine. > But then I may be wrong as I'm not sure I fully understand it... The idea is simple: if thet user is making an annoucement for a release and the releases have tags (i.e., there is a <versions> element set), then the current release should be defined there. It follows the same principles of the current announcement-check, which verifies if the current version is detailed on xdocs/changes.xml. I agree that that these assunptions are too agressive - maybe we could add a flag property indicating if the user wants these checkings (if you agree too, please open a new Jira issue and I will provide a patch for that). > 2. What is foundTag variable for? It doesn't seem to be used Sorry, found and foundTag are the same > 3. There's no point in iterating once found is true, right? Thus there should probably be a <j:break/> tag Sorry again, I wasn't aware of <j:break> (at least this I can justify - JSTL's Core does no provide such tag . So, I guess the correct loop should be: <j:if test="${size(pom.versions)!=0}"> <j:set var="foundTag" value="false"/> <j:forEach var="version" items="${pom.versions}"> <j:if test="${version.id==versionVariable}"> <j:set var="foundTag" value="true"/> <j:break/> </j:if> </j:forEach> <j:if test="${!foundTag}"> It would be even simpler if <j:break> offered a var attribute indicating if the look was broke or not: <j:if test="${size(pom.versions)!=0}"> <j:forEach var="version" items="${pom.versions}"> <j:break var="foundTag" test="${version.id==versionVariable}"/> </j:forEach> <j:if test="${!foundTag}"> Felipe
Hide
Felipe Leme added a comment -

Vincent,

Here is a new patch using j:break.

Felipe

Show
Felipe Leme added a comment - Vincent, Here is a new patch using j:break. Felipe
Hide
Vincent Massol added a comment -

Applied thanks. Minor note: there was an indentation issue with the patch.

Show
Vincent Massol added a comment - Applied thanks. Minor note: there was an indentation issue with the patch.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
10m
Original Estimate - 10 minutes
Remaining:
10m
Remaining Estimate - 10 minutes
Logged:
Not Specified
Time Spent - Not Specified