Search in sources :

Example 6 with Scm

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());
}
Also used : Scm(org.apache.maven.model.Scm)

Example 7 with Scm

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;
}
Also used : Scm(org.apache.maven.model.Scm) MavenPomScm(org.gradle.api.publish.maven.MavenPomScm)

Example 8 with Scm

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;
}
Also used : Scm(org.apache.maven.model.Scm) File(java.io.File)

Example 9 with Scm

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()));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) MavenProject(org.apache.maven.project.MavenProject) Scm(org.apache.maven.model.Scm) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Example 10 with Scm

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()));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) MavenProject(org.apache.maven.project.MavenProject) Scm(org.apache.maven.model.Scm) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Aggregations

Scm (org.apache.maven.model.Scm)63 MavenProject (org.apache.maven.project.MavenProject)20 Model (org.apache.maven.model.Model)14 Test (org.junit.Test)10 File (java.io.File)6 IOException (java.io.IOException)6 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)4 DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Properties (java.util.Properties)4 Expectations (mockit.Expectations)4 ReleaseDescriptorBuilder (org.apache.maven.shared.release.config.ReleaseDescriptorBuilder)4 DefaultReleaseEnvironment (org.apache.maven.shared.release.env.DefaultReleaseEnvironment)4 ArrayList (java.util.ArrayList)3 Dependency (org.apache.maven.model.Dependency)3 IssueManagement (org.apache.maven.model.IssueManagement)3 License (org.apache.maven.model.License)3 ScmTranslator (org.apache.maven.shared.release.scm.ScmTranslator)3 HashSet (java.util.HashSet)2