Ana içeriğe geç

Maven Plugin#

Proje içerisinde Maven teknolojisinin yeteneklerini kullanmamızı sağlamaktadır. Daha çok 'Dependency Managemet' ve ' Publishing' önem taşımaktadır.

Projelere iki farklı yöntem ile eklenebilmektedir. Yöntemler şunlardır:

DSL kullanımı

build.gradle
plugins {
    id 'hvl-maven-plugin' version hvlMavenPluginVersion
}

Buildscript kullanımı

build.gradle
buildscript {
    repositories {
        maven {
            url 'http://nexus.bulut.ai/repository/framework-plugin-group/'
        }
    }
    dependencies {
        classpath(group: 'tr.com.havelsan.plugin', name: 'hvl-gradle-maven-plugin', version: hvlMavenPluginVersion)
    }
}

apply plugin: 'hvl-maven-plugin'

Pluginin birçok konfigurasyon parametresi bulunmaktadır. Proje içerisinde kullanımı ve parametreler aşağıdaki gibidir.

Konfigurasyon yapısı#

settings.gradle
hvlMaven {
    // Kullanılacak olan maven konfigurasyon dosyası
    settingsXmlFilePath = System.getProperty("user.home") + '/.m2/settings.xml'
    publishing {
        // Publish bilgisi
        info = [release_offline   : [versionSuffix: '', // Versiyon bilgisine son ek eklemeyi sağlar.
                                     name         : 'framework',
                                     url          : 'http://10.17.1.57:8083/artifactory/libs-release-local/'],
                release_framework : [versionSuffix: '',
                                     name         : 'framework', // Credentials bilgisi  maven settings dosyasından alınmasını sağlar.
                                     url          : 'http://10.151.18.26:8081/artifactory/libs-release-local/'],
                snapshot_framework: [versionSuffix: '-SNAPSHOT',
                                     username     : 'framework',  // Credentials bilgisi username, password olarak verilmiştir.
                                     password     : 'password',
                                     url          : 'http://10.151.18.26:8081/artifactory/libs-snapshot-local/']]
        // Publish scope bilgisi
        scope = 'snapshot_framework'
    }
}

hvlRepositories {
    // Repositories bilgisi
    info = [online   : [[url: ['https://repo.spring.io/release/'
                               , 'https://repo.spring.io/snapshot/'
                               , 'https://repo.spring.io/libs-release/'
                               , 'https://repo.spring.io/libs-milestone-local/'
                               , 'https://repo.spring.io/libs-release-local/'
                               , 'https://repo.maven.apache.org/maven2/'
                               , 'https://repo.spring.io/milestone/'
                               , 'https://repo.gradle.org/gradle/libs-releases-local/'
                               , 'https://jcenter.bintray.com/'
                               , 'https://mvnrepository.com/artifact/'
                               , 'https://plugins.gradle.org/m2/']]],
            offline  : [[name: 'framework',
                         url : ['http://10.17.1.57:8083/artifactory/mbs_local/']]],
            framework: [[username: 'framework',  // Credentials bilgisi username, password olarak verilmiştir.
                         password: 'password',
                         url     : ['http://10.151.18.26:8081/artifactory/mbs_local/']]]]
    // Repositories scope bilgisi
    scope = 'framework'
}

Plugin proje içinde ide üzerinden veya konsol ile kullanılabilir.

Konsol kullanımı

- publish komutu:
  Verilen url adresine oluşturulan kütüphaneyenin dosyalarını gönderir.

  Parametreler:
  - publishingScope

    Kullanım şekli:
    `gradle cleanAll build publish -DpublishingScope=snapshot_bitnexus`

- publishToMavenLocal
  .m2 altına kütüphaneyenin dosyalarını gönderir.

  Parametreler:
   - publishingScope

     Kullanım şekli:
     `gradle cleanAll build publishToMavenLocal -DpublishingScope=snapshot_bitnexus`

Ide üzerinden kullanımı

Proje içerisinde örnek kullanım şekli:

settings.gradle kullanımı

gradle.ext {
    // Environment
    environment = [
            java    : [
                    info               : '21.0.1 (21.0.1-oracle)',
                    sourceCompatibility: 21,
                    targetCompatibility: 21
            ],
            gradle  : [
                    info: '8.5'
            ],
            encoding: [
                    type: 'UTF-8'
            ],
            maven   : [
                    settingsXmlFilePath: System.getProperty("user.home") + '/.m2/settings.xml'
            ],
            docker  : [
                    dockerFilePath     : rootDir.toString() + '/resources/docker/Dockerfile',
                    settingsXmlFilePath: System.getProperty("user.home") + '/.docker/settings.xml'
            ],
            project : [
                    publishingInfo              : [
                            release_bitnexus : [versionSuffix: '',
                                                name         : 'framework-nexus-supervisor',
                                                url: 'http://nexus.bulut.ai/repository/framework-releases/'],
                            snapshot_bitnexus: [versionSuffix: '-SNAPSHOT',
                                                name         : 'framework-nexus-snapshots',
                                                url: 'http://nexus.bulut.ai/repository/framework-snapshots/'],
                    ],
                    repositoriesInfo            : [
                            online  : [[url: ['https://repo.spring.io/release/'
                                              , 'https://repo.spring.io/snapshot/'
                                              , 'https://repo.spring.io/libs-release/'
                                              , 'https://repo.spring.io/libs-milestone-local/'
                                              , 'https://repo.spring.io/libs-release-local/'
                                              , 'https://repo.maven.apache.org/maven2/'
                                              , 'https://repo.spring.io/milestone/'
                                              , 'https://repo.gradle.org/gradle/libs-releases-local/'
                                              , 'https://jcenter.bintray.com/'
                                              , 'https://mvnrepository.com/artifact/'
                                              , 'https://plugins.gradle.org/m2/']]],
                            bitnexus: [[name: 'framework-nexus-dev',
                                        url: ['http://nexus.bulut.ai/repository/framework-group/']]],
                    ],
                    buildscriptRepositoriesInfo : [
                            online  : ['https://plugins.gradle.org/m2/'],
                            bitnexus: ['http://nexus.bulut.ai/repository/framework-plugin-group/']
                    ],
                    dockerPublishingInfo        : [
                            offline: [url: 'docker.local'],
                            harbor : [name: 'framework-harbor-master',
                                      url: 'harbor.bulut.ai/framework']
                    ],
                    publishingScope: 'snapshot_bitnexus',
                    repositoriesScope           : 'bitnexus',
                    buildscriptRepositoriesScope: 'bitnexus',
                    dockerPublishingScope       : 'harbor'
            ],
    ]
}

build.gradle kullanımı

hvlMaven {
    settingsXmlFilePath = gradle.environment.maven.settingsXmlFilePath
    publishing {
        info = gradle.environment.project.publishingInfo
        scope = gradle.environment.project.publishingScope
    }
}

hvlRepositories {
    info = gradle.environment.project.repositoriesInfo
    scope = gradle.environment.project.repositoriesScope
}