use of org.apache.maven.model.Scm in project siddhi by wso2.
the class MkdocsGitHubPagesDeployMojo method deployDocumentation.
private void deployDocumentation(MavenProject rootMavenProject, String docGenBasePath) {
// Creating the credential provider fot Git
String scmUsername = System.getenv(Constants.SYSTEM_PROPERTY_SCM_USERNAME_KEY);
String scmPassword = System.getenv(Constants.SYSTEM_PROPERTY_SCM_PASSWORD_KEY);
if (scmUsername == null && scmPassword == null) {
getLog().info("SCM_USERNAME and SCM_PASSWORD not defined!");
}
String url = null;
Scm scm = rootMavenProject.getScm();
if (scm != null) {
url = scm.getUrl();
}
// Deploying documentation
DocumentationUtils.updateDocumentationOnGitHub(docGenBasePath, mkdocsConfigFile, readmeFile, mavenProject.getVersion(), getLog());
DocumentationUtils.deployMkdocsOnGitHubPages(mavenProject.getVersion(), rootMavenProject.getBasedir(), url, scmUsername, scmPassword, getLog());
}
use of org.apache.maven.model.Scm in project gradle by gradle.
the class MavenPomFileGenerator method convertScm.
private Scm convertScm(MavenPomScm source) {
Scm target = new Scm();
target.setConnection(source.getConnection().getOrNull());
target.setDeveloperConnection(source.getDeveloperConnection().getOrNull());
target.setUrl(source.getUrl().getOrNull());
target.setTag(source.getTag().getOrNull());
return target;
}
use of org.apache.maven.model.Scm in project fabric8-maven-plugin by fabric8io.
the class IconEnricher method convertIconFileToURL.
private String convertIconFileToURL(File iconFile, String iconRef) throws IOException {
long length = iconFile.length();
int sizeK = Math.round(length / 1024);
byte[] bytes = Files.readBytes(iconFile);
byte[] encoded = Base64Encoder.encode(bytes);
int base64SizeK = Math.round(encoded.length / 1024);
if (base64SizeK < Configs.asInt(getConfig(Config.maximumDataUrlSizeK))) {
String mimeType = guessMediaType(iconFile);
return "data:" + mimeType + ";charset=UTF-8;base64," + new String(encoded);
} else {
File iconSourceFile = new File(appConfigDir, iconFile.getName());
if (iconSourceFile.exists()) {
File rootProjectFolder = getRootProjectFolder();
if (rootProjectFolder != null) {
String relativePath = Files.getRelativePath(rootProjectFolder, iconSourceFile);
String relativeParentPath = Files.getRelativePath(rootProjectFolder, getProject().getBasedir());
String urlPrefix = getConfig(Config.urlPrefix);
if (Strings.isNullOrBlank(urlPrefix)) {
Scm scm = getProject().getScm();
if (scm != null) {
String url = scm.getUrl();
if (url != null) {
String[] prefixes = { "http://github.com/", "https://github.com/" };
for (String prefix : prefixes) {
if (url.startsWith(prefix)) {
url = URLUtils.pathJoin("https://cdn.rawgit.com/", url.substring(prefix.length()));
break;
}
}
if (url.endsWith(relativeParentPath)) {
url = url.substring(0, url.length() - relativeParentPath.length());
}
urlPrefix = url;
}
}
}
if (Strings.isNullOrBlank(urlPrefix)) {
log.warn("No iconUrlPrefix defined or could be found via SCM in the pom.xml so cannot add an icon URL!");
} else {
String answer = URLUtils.pathJoin(urlPrefix, getConfig(Config.branch), relativePath);
return answer;
}
}
} else {
String embeddedIcon = embeddedIconsInConsole(iconRef, "img/icons/");
if (embeddedIcon != null) {
return embeddedIcon;
} else {
log.warn("Cannot find url for icon to use %s", iconRef);
}
}
}
return null;
}
use of org.apache.maven.model.Scm in project fabric8-maven-plugin by fabric8io.
the class MavenScmEnricherTest method testMavenScmOnlyConnection.
@Test
public void testMavenScmOnlyConnection() {
final MavenProject project = new MavenProject();
final Scm scm = new Scm();
scm.setConnection("scm:git:git://github.com/fabric8io/fabric8-maven-plugin.git");
project.setScm(scm);
// Setup mock behaviour
new Expectations() {
{
{
context.getProject();
result = project;
}
}
};
MavenScmEnricher mavenScmEnricher = new MavenScmEnricher(context);
KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().withNewMetadata().withName("foo").endMetadata().build());
mavenScmEnricher.create(PlatformMode.kubernetes, builder);
Map<String, String> scmAnnotations = builder.buildFirstItem().getMetadata().getAnnotations();
assertNotNull(scmAnnotations);
Assert.assertEquals(1, scmAnnotations.size());
assertEquals("HEAD", scmAnnotations.get(Fabric8Annotations.SCM_TAG.value()));
}
use of org.apache.maven.model.Scm in project fabric8-maven-plugin by fabric8io.
the class MavenScmEnricherTest method testMavenScmOnlyDevConnection.
@Test
public void testMavenScmOnlyDevConnection() {
final MavenProject project = new MavenProject();
final Scm scm = new Scm();
scm.setUrl("git://github.com/fabric8io/fabric8-maven-plugin.git");
project.setScm(scm);
// Setup mock behaviour
new Expectations() {
{
{
context.getProject();
result = project;
}
}
};
MavenScmEnricher mavenScmEnricher = new MavenScmEnricher(context);
KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().withNewMetadata().withName("foo").endMetadata().build());
mavenScmEnricher.create(PlatformMode.kubernetes, builder);
Map<String, String> scmAnnotations = builder.buildFirstItem().getMetadata().getAnnotations();
assertNotNull(scmAnnotations);
Assert.assertEquals(2, scmAnnotations.size());
assertEquals("git://github.com/fabric8io/fabric8-maven-plugin.git", scmAnnotations.get(Fabric8Annotations.SCM_URL.value()));
assertEquals("HEAD", scmAnnotations.get(Fabric8Annotations.SCM_TAG.value()));
}
Aggregations