Upload two jars to local maven repo

I am new in Android Studio with Gradle build. I would like to upload two jars to my maven local repository. The 1st jar is my project jar, the other jar is an external jar, I know the path to the external jar.

I tried to create a task to get my project jar first in build.gradle:

task projectJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    archiveName = 'MyApp'
}
  def externalJar = new File(PATH_TO_JAR)

But I am not sure how to continue.

In Gradle, how to upload the two jars to my local maven repository? I want to specify groupName, artifactName & version for the two jars when uploading to local maven repo.

try this …

apply plugin: 'maven-publish'
  publishing {
    publications {
         create( 'module', MavenPublication ) {
                artifact
  externalJar
                groupId
   'group'
                artifactId
'module'
                version
   'ver'
        }
    }
}

I haven’t tried, but your code only upload the external jar, what about my project jar?

apply plugin: 'maven'
uploadArchives {
  repositories {
    mavenDeployer {
      repository(url: project.ext.localRepo)
      pom.version = 'version'
      pom.groupId = 'group'
      pom.artifactId = 'artifact'
    }
  }
}
  $ gradle install
 # to my local gradle cache
  $ gradle uploadArchives
# to my workgroup's internal Apache Archiva server