use of org.apache.maven.model.Scm in project maven by apache.
the class AbstractModelInterpolatorTest method testShouldThrowExceptionOnRecursiveScmConnectionReference.
@Test
public void testShouldThrowExceptionOnRecursiveScmConnectionReference() throws Exception {
Model model = new Model();
Scm scm = new Scm();
scm.setConnection("${project.scm.connection}/somepath");
model.setScm(scm);
ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector();
interpolator.interpolateModel(model, null, createModelBuildingRequest(context), collector);
assertCollectorState(0, 1, 0, collector);
}
use of org.apache.maven.model.Scm in project maven by apache.
the class ModelMerger method mergeModel_Scm.
protected void mergeModel_Scm(Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
Scm src = source.getScm();
if (src != null) {
Scm tgt = target.getScm();
if (tgt == null) {
tgt = new Scm();
tgt.setTag(null);
target.setScm(tgt);
}
mergeScm(tgt, src, sourceDominant, context);
}
}
use of org.apache.maven.model.Scm in project unleash-maven-plugin by shillner.
the class DevVersionUtil method revertScmSettings.
public void revertScmSettings(MavenProject projectToRevert, Document document) {
Scm scm = this.metadata.getCachedScmSettings(projectToRevert);
if (scm != null) {
this.log.debug("\t\tReversion of SCM connection tags");
Document originalPOM = this.metadata.getCachedOriginalPOM(projectToRevert);
Node scmNode = PomUtil.getOrCreateScmNode(document, false);
Node originalScmNode = PomUtil.getOrCreateScmNode(originalPOM, false);
if (scmNode != null) {
Optional<String> connection = PomUtil.getChildNodeTextContent(originalScmNode, PomUtil.NODE_NAME_SCM_CONNECTION);
if (connection.isPresent()) {
PomUtil.setNodeTextContent(scmNode, PomUtil.NODE_NAME_SCM_CONNECTION, connection.get(), false);
}
Optional<String> devConnection = PomUtil.getChildNodeTextContent(originalScmNode, PomUtil.NODE_NAME_SCM_DEV_CONNECTION);
if (devConnection.isPresent()) {
PomUtil.setNodeTextContent(scmNode, PomUtil.NODE_NAME_SCM_DEV_CONNECTION, devConnection.get(), false);
}
Optional<String> url = PomUtil.getChildNodeTextContent(originalScmNode, PomUtil.NODE_NAME_SCM_URL);
if (url.isPresent()) {
PomUtil.setNodeTextContent(scmNode, PomUtil.NODE_NAME_SCM_URL, url.get(), false);
}
if (scm.getTag() != null) {
PomUtil.setNodeTextContent(scmNode, PomUtil.NODE_NAME_SCM_TAG, scm.getTag(), false);
} else {
PomUtil.deleteNode(scmNode, PomUtil.NODE_NAME_SCM_TAG);
}
}
}
}
use of org.apache.maven.model.Scm in project unleash-maven-plugin by shillner.
the class MavenScmUtil method calcProviderName.
/**
* Derives the name of the required SCM provider from the given Maven project by analyzing the scm connection strings
* of the project.
*
* @param project the project from which the SCM provider is retrieved.
* @return the name of the required SCM provider.
*/
public static Optional<String> calcProviderName(MavenProject project) {
String providerName = null;
Scm scm = project.getScm();
if (scm != null) {
// takes the developer connection first or the connection url if devConnection is empty or null
String connection = StringUtils.trimToNull(scm.getDeveloperConnection());
connection = connection != null ? connection : StringUtils.trimToNull(scm.getConnection());
// scm url format description: https://maven.apache.org/scm/scm-url-format.html
if (connection != null) {
// cuts the substring "scm:" at the beginning
connection = connection.substring(4);
// as stated in the scm url format description, the provider delimiter may be a colon (:) or a pipe (|) if
// colons are used otherwise (e.g. for windows paths)
// svn:http://... -> svn:http://...
// svn|http://... -> svn
// svn:http://xyz|... -> svn:http://xyz
int nextPipe = connection.indexOf('|');
if (nextPipe > -1) {
connection = connection.substring(0, nextPipe);
}
// svn -> svn
// svn:http... -> svn
int nextColon = connection.indexOf(':');
if (nextColon > -1) {
providerName = connection.substring(0, nextColon);
} else {
providerName = connection;
}
}
}
return Optional.fromNullable(providerName);
}
use of org.apache.maven.model.Scm in project jahia by Jahia.
the class ModuleBuildHelper method updateDuplicatedPom.
private void updateDuplicatedPom(String moduleName, String artifactId, String groupId, String dstVersion, File dstFolder) throws IOException {
Model pom = null;
try {
pom = PomUtils.read(new File(dstFolder, "pom.xml"));
} catch (XmlPullParserException e) {
throw new IOException(e);
}
if (!"bundle".equals(pom.getPackaging())) {
throw new IOException("This module is not compatible with the current version of Jahia.");
}
pom.setArtifactId(artifactId);
pom.setGroupId(groupId);
pom.setVersion(dstVersion);
pom.setName(moduleName);
Scm scm = new Scm();
scm.setConnection(Constants.SCM_DUMMY_URI);
scm.setDeveloperConnection(Constants.SCM_DUMMY_URI);
pom.setScm(scm);
pom.setDistributionManagement(null);
pom.getProperties().remove("jahia-private-app-store");
PomUtils.write(pom, new File(dstFolder, "pom.xml"));
}
Aggregations