-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- introduced "naming strategies" to make that part extendable separate from the parsers -
- Loading branch information
Showing
8 changed files
with
232 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...main/java/org/jenkinsci/plugins/SemanticVersioning/naming/MavenReleaseNamingStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.jenkinsci.plugins.SemanticVersioning.naming; | ||
|
||
import java.util.Map; | ||
import java.util.logging.Logger; | ||
|
||
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.model.Descriptor; | ||
|
||
import org.jenkinsci.plugins.SemanticVersioning.AppVersion; | ||
import org.jenkinsci.plugins.SemanticVersioning.Messages; | ||
import org.jenkinsci.plugins.SemanticVersioning.parsing.AbstractSemanticParserDescription; | ||
|
||
@Extension | ||
public class MavenReleaseNamingStrategy implements NamingStrategy { | ||
|
||
private static Logger logger = Logger.getLogger(String.valueOf(AppVersion.class)); | ||
|
||
public Descriptor<NamingStrategy> getDescriptor() { | ||
return new AbstractSemanticParserDescription() { | ||
|
||
@Override | ||
public String getDisplayName() { | ||
|
||
return Messages.NamingStrategies.MAVEN_RELEASE_DEVELOPMENT; | ||
} | ||
}; | ||
} | ||
|
||
public void exportNames(AppVersion current, Map<String,String> vars, boolean useBuildNumber, int buildNumber) { | ||
logger.info("SemanticVersioningProcesser::getAppVersion -> maven naming: " +current.toJsonString()); | ||
String releaseVersion = current.getMajor()+"."+current.getMinor()+(useBuildNumber?"."+buildNumber:""); | ||
String developmentVersion = current.getMajor()+"."+(useBuildNumber?current.getMinor()+"."+(buildNumber+1):""+(current.getMinor()+1))+"-SNAPSHOT"; | ||
logger.info("SemanticVersioningProcesser::getAppVersion -> setting release version: " +releaseVersion); | ||
logger.info("SemanticVersioningProcesser::getAppVersion -> setting development version: " +developmentVersion); | ||
vars.put("releaseVersion", releaseVersion); | ||
vars.put("developmentVersion", developmentVersion); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/org/jenkinsci/plugins/SemanticVersioning/naming/NamingStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.jenkinsci.plugins.SemanticVersioning.naming; | ||
|
||
import hudson.model.Describable; | ||
|
||
import java.util.Map; | ||
|
||
import org.jenkinsci.plugins.SemanticVersioning.AppVersion; | ||
|
||
public interface NamingStrategy extends Describable<NamingStrategy> { | ||
|
||
public void exportNames(AppVersion current, Map<String,String> vars, boolean useBuildNumber, int buildNumber); | ||
|
||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/org/jenkinsci/plugins/SemanticVersioning/naming/NoopNamingStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.jenkinsci.plugins.SemanticVersioning.naming; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Descriptor; | ||
|
||
import java.util.Map; | ||
import java.util.logging.Logger; | ||
|
||
import org.jenkinsci.plugins.SemanticVersioning.AppVersion; | ||
import org.jenkinsci.plugins.SemanticVersioning.Messages; | ||
import org.jenkinsci.plugins.SemanticVersioning.parsing.AbstractSemanticParserDescription; | ||
|
||
@Extension | ||
public class NoopNamingStrategy implements NamingStrategy { | ||
|
||
private static Logger logger = Logger.getLogger(String.valueOf(AppVersion.class)); | ||
|
||
public Descriptor<NamingStrategy> getDescriptor() { | ||
return new AbstractSemanticParserDescription() { | ||
|
||
@Override | ||
public String getDisplayName() { | ||
|
||
return Messages.NamingStrategies.NOOP_NAMING; | ||
} | ||
}; | ||
} | ||
|
||
public void exportNames(AppVersion current, Map<String,String> vars, boolean useBuildNumber, int buildNumber) { | ||
// it's called "noop", d'oh! | ||
logger.info("SemanticVersioningProcesser::getAppVersion -> not setting anything (NOOP): " + current.toJsonString()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Probably wrong. See jenkinsci/remoting#56.