Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's purpose of generating aar? #61

Open
liuyibox opened this issue Sep 1, 2020 · 0 comments
Open

What's purpose of generating aar? #61

liuyibox opened this issue Sep 1, 2020 · 0 comments

Comments

@liuyibox
Copy link

liuyibox commented Sep 1, 2020

Please correct me if I am wrong. The code below in the dlib build.gradle seems to generate aar. Why we need aar? I removed this part and the app seems to be working. Also, if possible, could you go through the code below briefly such that I can get more understanding of this build.gradle file;


apply plugin: 'com.jakewharton.hugo'

// call regular ndk-build(.cmd) script from app directory
def GetNDKDir()  {
    def localProperties = new Properties()

    def NDK_SEARCH_VARS = ['ANDROID_NDK_HOME', 'ANDROID_NDK_ROOT', 'NDKROOT', 'NDKHOME']
    def ndk_path = null

    def lim = (Os.isFamily(Os.FAMILY_WINDOWS)) ? '\\' : '/'

    // Search Local.Properties file
    try {
        localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
        def ndkDir = localProperties.getProperty('ndk.dir')
        ndk_path = ndkDir != null ? ndkDir + lim : null;
    } catch (java.io.FileNotFoundException e) {
        println 'local.properties file not found'
    }

    // Search env var
    if (ndk_path == null){
        for (String var : NDK_SEARCH_VARS) {
            def v = System.getenv(var)

            if (v != null) {
                ndk_path = v + lim
                println "found in System Environment *$var = " + ndk_path
                break
            }
        }
    } else {
        println 'found in local.properties *NDK_PATH = ' + ndk_path
    }

    if (ndk_path == null) {
        println 'No NDK_PATH found'
        ndk_path = ''
    }
    return ndk_path
}

def NDKCommand() {
    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
        return GetNDKDir() + "ndk-build.cmd"
    } else {
        return GetNDKDir() + "ndk-build"
    }
}

apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'

def siteUrl = 'https://github.com/tzutalin/dlib-android-app'      // Homepage URL of the library
def gitUrl = 'https://github.com/tzutalin/dlib-android-app.git'   // Git repository URL

install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'
                name 'An Android library to wrap dlib library'
                url siteUrl
                // Set your license
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'tzutalin'
                        name 'tzutalin'
                        email '[email protected]'
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl

                }
            }
        }
    }
}

task generateSourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier 'sources'
}

task generateJavadocs(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath()
            .join(File.pathSeparator))
    classpath += configurations.javadocDeps
}

task generateJavadocsJar(type: Jar) {
    from generateJavadocs.destinationDir
    classifier 'javadoc'
}
generateJavadocsJar.dependsOn generateJavadocs

artifacts {
    archives generateJavadocsJar
    archives generateSourcesJar
}

Properties properties = new Properties()
if(project.rootProject.file('local.properties').isFile()) {
    properties.load(project.rootProject.file('local.properties').newDataInputStream())

    bintray {
        user = properties.getProperty("bintray.user")
        key = properties.getProperty("bintray.apikey")

        configurations = ['archives']
        pkg {
            repo = "maven"
            name = "dlib-android-app"
            version {
                name = "${rootProject.ext.releaseVersionName}"
                desc = 'An Android library to wrap dlib library'
                released  = new Date()
                vcsTag = "${rootProject.ext.releaseVersionName}"
            }

            websiteUrl = siteUrl
            vcsUrl = gitUrl
            licenses = ["Apache-2.0"]
            publish = true
        }
        configurations = ['archives']
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant