Skip to content

Commit

Permalink
add bintray script.
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYeoh committed Nov 25, 2019
1 parent 271c472 commit ac7c9af
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 29 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -4,6 +4,7 @@
<p align="center" style="font-size: 0.5em">A tool used to obfuscate aab resources</p>
</h1>

[![Download](https://api.bintray.com/packages/bytedance/maven/AabResGuard/images/download.svg)](https://bintray.com/bytedance/maven/AabResGuard/)
[![License](https://img.shields.io/badge/license-Apache2.0-brightgreen)](LICENSE)
[![Bundletool](https://img.shields.io/badge/Dependency-Bundletool/0.10.0-blue)](https://github.com/google/bundletool)

Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Expand Up @@ -5,7 +5,7 @@ buildscript {
repositories {
google()
jcenter()
if ("true".equalsIgnoreCase(findProperty('useLocalMaven'))) {
if ("true".equalsIgnoreCase(System.getProperty('useLocalMaven', "false"))) {
println "use local repo"
mavenLocal()
} else {
Expand All @@ -18,13 +18,13 @@ buildscript {
}
}
dependencies {
classpath 'digital.wup:android-maven-publish:3.4.0'
classpath deps.plugin.digital
classpath deps.plugin.shadow
classpath deps.plugin['bintray-plugin']
classpath deps.gradle.tools
classpath deps.kotlin.plugin
classpath deps.plugin.digital
classpath "com.github.jengelman.gradle.plugins:shadow:4.0.4"

if ("true".equalsIgnoreCase(findProperty("enableAabResGuardPlugin"))) {
if ("true".equalsIgnoreCase(System.getProperty("enableAabResGuardPlugin", "false"))) {
classpath "com.bytedance.android:aabresguard-plugin:${versions.aabresguard}"
}
}
Expand All @@ -34,7 +34,7 @@ allprojects {
repositories {
google()
jcenter()
if ("true".equalsIgnoreCase(findProperty('useLocalMaven'))) {
if ("true".equalsIgnoreCase(System.getProperty('useLocalMaven', "false"))) {
mavenLocal()
} else {
maven { url findProperty("RELEASE_REPOSITORY_URL") }
Expand Down
6 changes: 5 additions & 1 deletion gradle.properties
Expand Up @@ -24,4 +24,8 @@ PUBLISH_LOCAL_REPO=../repo
useLocalMaven=false
# 是否源码依赖
useSource=false
enableAabResGuardPlugin=true
enableAabResGuardPlugin=true
# bintray
uploadToBintray=true
bintrayInfo.user=****
bintrayInfo.apiKey=***************
2 changes: 1 addition & 1 deletion gradle/aabresguard.gradle
@@ -1,4 +1,4 @@
if (!"true".equalsIgnoreCase(findProperty("enableAabResGuardPlugin"))) {
if (!"true".equalsIgnoreCase(System.getProperty("enableAabResGuardPlugin", "false"))) {
return
}

Expand Down
12 changes: 12 additions & 0 deletions gradle/config.gradle
@@ -1,3 +1,6 @@
loadSystemProperties(rootProject.file("gradle.properties"))
loadSystemProperties(rootProject.file("local.properties"))

apply from: 'gradle/ext.gradle'
apply from: 'gradle/versions.gradle'

Expand All @@ -7,3 +10,12 @@ allprojects {
options.addStringOption('encoding', 'UTF-8')
}
}

static void loadSystemProperties(File path) {
if (!path.exists()) {
return
}
Properties properties = new Properties()
properties.load(path.newDataInputStream())
System.properties.putAll(properties)
}
22 changes: 22 additions & 0 deletions gradle/ext.gradle
@@ -1,5 +1,27 @@
ext {
GROUP_ID = "com.bytedance.android"
bintrayInfo = [
repo : [
name : "AabResGuard",
groupId : GROUP_ID,
artifactId : "aabresguard",
description: "A tool used to obfuscate aab resources",
packaging : "jar",
siteUrl : "https://github.com/bytedance/AabResGuard",
gitUrl : "https://github.com/bytedance/AabResGuard.git",
userOrg : System.getProperty("bintrayInfo.userOrg", "****"),
],
developer: [
id : "JingYeoh",
name : "JingYeoh",
email : "yangjing.yeoh@gmail.com",
user : System.getProperty("bintrayInfo.user", "****"),
apikey: System.getProperty("bintrayInfo.apiKey", "*************")
],
javadoc : [
name: "AabResGuard"
]
]
}

// 读取 local.properties 文件内容
Expand Down
23 changes: 23 additions & 0 deletions gradle/publish-bintray.gradle
@@ -0,0 +1,23 @@
apply plugin: 'com.jfrog.bintray'
if (System.getProperty("uploadToBintray", "false").equalsIgnoreCase("true")) {
bintray {
user = bintrayInfo.developer.user
key = bintrayInfo.developer.apikey
pkg {
repo = 'maven'
name = ARTIFACT_ID
websiteUrl = bintrayInfo.repo.siteUrl
vcsUrl = bintrayInfo.repo.gitUrl
licenses = ["Apache-2.0"]
publish = true
userOrg = bintrayInfo.repo.userOrg

version {
name = versions[ARTIFACT_ID]
released = new Date()
vcsTag = versions[ARTIFACT_ID]
}
}
publications = ['MyPublication']
}
}
48 changes: 41 additions & 7 deletions gradle/publish-shadow.gradle
Expand Up @@ -24,25 +24,59 @@ println "username: $publishUserName"
println "password: $publishPassword"

apply plugin: 'maven-publish'

def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id bintrayInfo.developer.id
name bintrayInfo.developer.name
email bintrayInfo.developer.email
}
}
scm {
url bintrayInfo.repo.siteUrl
}
}

publishing {
publications {
shadow(MavenPublication) { publication ->
MyPublication(MavenPublication) { publication ->
project.shadow.component(publication)
groupId GROUP_ID
artifactId ARTIFACT_ID
version versions[ARTIFACT_ID]

artifact sourcesJar
artifact javadocJar

pom.withXml {
def root = asNode()
root.appendNode('description', bintrayInfo.repo.description)
root.appendNode('name', bintrayInfo.repo.name)
root.appendNode('url', bintrayInfo.repo.siteUrl)
root.children().last() + pomConfig
}
}
}
repositories {
maven {
url = publishUrl
credentials {
username = publishUserName
password = publishPassword

if (!System.getProperty("uploadToBintray", "false").equalsIgnoreCase("true")) {
repositories {
maven {
url = publishUrl
credentials {
username = publishUserName
password = publishPassword
}
}
}
}
}

apply from: "$rootDir/gradle/publish-bintray.gradle"
29 changes: 17 additions & 12 deletions gradle/publish.gradle
Expand Up @@ -24,23 +24,26 @@ println "username: $publishUserName"
println "password: $publishPassword"

publishing {
repositories {
maven {
url = publishUrl
credentials {
username = publishUserName
password = publishPassword
if (!System.getProperty("uploadToBintray", "false").equalsIgnoreCase("true")) {
repositories {
maven {
url = publishUrl
credentials {
username = publishUserName
password = publishPassword
}
}
if (System.getProperty("useLocalMaven", "false").equalsIgnoreCase("true")) {
maven {
url = "${rootProject.projectDir}/repo"
}
}
}

maven {
url = "${rootProject.projectDir}/repo"
}
}

if (project.plugins.hasPlugin("java-library") || project.plugins.hasPlugin("java")) {
publications {
shadow(MavenPublication) {
MyPublication(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
Expand All @@ -53,4 +56,6 @@ publishing {
} else {
throw new GradleScriptException("java-library plugin required")
}
}
}

apply from: "$rootDir/gradle/publish-bintray.gradle"
11 changes: 9 additions & 2 deletions gradle/versions.gradle
@@ -1,9 +1,9 @@
def versions = [:]
versions.gradletools = "3.2.1"
versions.kotlin = "1.3.0"
versions.digital = "3.4.0"
versions.java = "8"
versions.aabresguard = "0.1.0-beta-7"
//versions.aabresguard = "0.1.0-beta-7"
versions.aabresguard = "0.0.1-beta2"
// android
versions.compileSdkVersion = 28
versions.minSdkVersion = 15
Expand All @@ -15,6 +15,11 @@ versions.bundletool = "0.10.0"
versions["aabresguard-core"] = versions.aabresguard
versions["aabresguard-plugin"] = versions.aabresguard

// plugin
versions["bintray-plugin"] = "1.8.4"
versions.shadow = "4.0.4"
versions.digital = "3.4.0"

ext.versions = versions

ext.deps = [:]
Expand All @@ -32,6 +37,8 @@ deps.kotlin = kotlin
// plugin
def plugin = [:]
plugin.digital = "digital.wup:android-maven-publish:${versions.digital}"
plugin.shadow = "com.github.jengelman.gradle.plugins:shadow:${versions.shadow}"
plugin['bintray-plugin'] = "com.jfrog.bintray.gradle:gradle-bintray-plugin:${versions["bintray-plugin"]}"
deps.plugin = plugin
// library
deps.appcompatV7 = "com.android.support:appcompat-v7:${versions.support}"
Expand Down
1 change: 1 addition & 0 deletions samples/app/build.gradle
Expand Up @@ -39,4 +39,5 @@ dependencies {
implementation 'com.mikepenz:ionicons-typeface:2.0.1.5-kotlin@aar'
implementation 'com.mikepenz:pixeden-7-stroke-typeface:1.2.0.3-kotlin@aar'
implementation 'com.mikepenz:material-design-icons-dx-typeface:5.0.1.0-kotlin@aar'
compileOnly deps.plugin['bintray-plugin']
}
1 change: 1 addition & 0 deletions wiki/zh-cn/README.md
Expand Up @@ -4,6 +4,7 @@
<p align="center" style="font-size: 0.5em">针对 aab 文件的资源混淆工具</p>
</h1>

[![Download](https://api.bintray.com/packages/bytedance/maven/AabResGuard/images/download.svg)](https://bintray.com/bytedance/maven/AabResGuard/)
[![License](https://img.shields.io/badge/license-Apache2.0-brightgreen)](../../LICENSE)
[![Bundletool](https://img.shields.io/badge/Dependency-Bundletool/0.10.0-blue)](https://github.com/google/bundletool)

Expand Down

0 comments on commit ac7c9af

Please sign in to comment.