How include license to jar file in android library (aar)

1.5k Views Asked by At

I Have aar project and I want to add license to jar file. I add licence to .pom file, but I want add it to jar and get structure like this:

enter image description here Is it possible add LICENSE.txt to .jar by gradle?

2

There are 2 best solutions below

2
Lenoarod On

here is the jar document describes:

JAR file is a file format based on the popular ZIP file format and is used for aggregating many files into one. A JAR file is essentially a zip file that contains an optional META-INF directory

the META_INF function is that:

The META-INF directory, if it exists, is used to store package and extension configuration data, including security, versioning, extension, and services.

so I think you should put it int the META_INF files. you can see this answer get some solution.

0
Chentao Zhou On

if you want add LICENSE.txt into your android library (aar). you should do two things:

  1. add your LICENSE.txt to your project, path: src/main/resources/META-INF(other resources folders are acceptable as well)
  2. add "android {packagingOptions{ merge '**/LICENSE.txt'}" into your xxx(sdkname)/build.gradle file.

the keyword merge means add all matching files to your aar