config/android-maven-publication.gradle
changeset 32 f165a9538ee3
parent 31 0e233781410b
child 33 6291c6dab84b
equal deleted inserted replaced
31:0e233781410b 32:f165a9538ee3
     1 /*
       
     2  * Geekdroid is a utility library for development on the Android
       
     3  * Platform.
       
     4  *
       
     5  * Copyright (C) 2017-2022 by Frederic-Charles Barthelery.
       
     6  *
       
     7  * This file is part of Geekdroid.
       
     8  *
       
     9  * Geekdroid is free software: you can redistribute it and/or modify
       
    10  * it under the terms of the GNU General Public License as published by
       
    11  * the Free Software Foundation, either version 3 of the License, or
       
    12  * (at your option) any later version.
       
    13  *
       
    14  * Geekdroid is distributed in the hope that it will be useful,
       
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    17  * GNU General Public License for more details.
       
    18  *
       
    19  * You should have received a copy of the GNU General Public License
       
    20  * along with Geekdroid.  If not, see <http://www.gnu.org/licenses/>.
       
    21  */
       
    22 
       
    23 /**
       
    24  * This configuration allows to publish android libraries into a maven repository.
       
    25  * You need to define in your build.gradle the following variables :
       
    26  * version = "1.0"                // the version of your projects
       
    27  * ext.artifactId="geny-widgets"  // the maven artifact id
       
    28  * Use ./gradlew tasks to see the name of the publishing tasks.
       
    29  */
       
    30 if (plugins.hasPlugin("com.android.library")) {
       
    31 
       
    32     apply plugin: 'maven-publish'
       
    33 
       
    34     if (!project.ext.properties.containsKey("artifactId")) {
       
    35         ext.artifactId = project.name
       
    36     }
       
    37 
       
    38     publishing {
       
    39         publications {
       
    40             projectRelease(MavenPublication) {
       
    41                 artifactId project.artifactId
       
    42                 artifact "build/outputs/aar/${project.archivesBaseName}-release.aar"
       
    43             }
       
    44 
       
    45             projectSnapshot(MavenPublication) {
       
    46                 artifactId project.artifactId
       
    47                 artifact "build/outputs/aar/${project.archivesBaseName}-debug.aar"
       
    48                 version getVersion() + "-SNAPSHOT"
       
    49             }
       
    50         }
       
    51     }
       
    52 
       
    53     tasks.named("publishProjectReleasePublicationToMavenLocal") {
       
    54         dependsOn "assembleRelease"
       
    55     }
       
    56 
       
    57     tasks.named("publishProjectSnapshotPublicationToMavenLocal") {
       
    58         dependsOn "assembleDebug"
       
    59     }
       
    60 }