Skip to content

Commit 5194a88

Browse files
❇️ security improvement
1 parent 40f47da commit 5194a88

2 files changed

Lines changed: 205 additions & 3 deletions

File tree

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

contentstack/build.gradle

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'maven'
3+
apply plugin: 'signing'
4+
apply plugin: 'jacoco'
5+
6+
tasks.withType(Test) {
7+
jacoco.includeNoLocationClasses = true
8+
}
9+
//https://medium.com/@rafael_toledo/setting-up-an-unified-coverage-report-in-android-with-jacoco-robolectric-and-espresso-ffe239aaf3fa
10+
// gradle clean jacocoTestReport
11+
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
12+
reports {
13+
html.enabled = true
14+
}
15+
16+
afterEvaluate {
17+
classDirectories.setFrom(files(classDirectories.files.collect {
18+
fileTree(dir: it, exclude: '**com/contentstack/okhttp**')
19+
fileTree(dir: it, exclude: '**com/contentstack/okio**')
20+
fileTree(dir: it, exclude: '**com/contentstack/txtmark**')
21+
}))
22+
}
23+
}
24+
android {
25+
26+
testOptions {
27+
unitTests.all {
28+
jacoco {
29+
includeNoLocationClasses = true
30+
}
31+
}
32+
}
33+
34+
signingConfigs {
35+
debug {
36+
storeFile file("/Users/shaileshmishra/Documents/workspace/contentstack/android/keystore/debug.keystore")
37+
storePassword 'android'
38+
keyAlias 'androiddebugkey'
39+
keyPassword 'android'
40+
}
41+
42+
release {
43+
storeFile file("/Users/shaileshmishra/Documents/workspace/contentstack/android/keystore/debug.keystore")
44+
storePassword 'android'
45+
keyAlias 'androiddebugkey'
46+
keyPassword 'android'
47+
}
48+
}
49+
compileSdkVersion 26
50+
defaultConfig {
51+
minSdkVersion 19
52+
versionCode 1
53+
versionName "1.0"
54+
useLibrary 'org.apache.http.legacy'
55+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
56+
signingConfig signingConfigs.release
57+
}
58+
59+
buildTypes {
60+
def localProperties = new Properties()
61+
localProperties.load(new FileInputStream(rootProject.file("local.properties")))
62+
debug {
63+
debuggable true
64+
testCoverageEnabled true
65+
buildConfigField "String", "host", localProperties['host']
66+
buildConfigField "String", "APIKey", localProperties['APIKey']
67+
buildConfigField "String", "deliveryToken", localProperties['deliveryToken']
68+
buildConfigField "String", "environment", localProperties['env']
69+
buildConfigField "String", "contentTypeUID", localProperties['contentType']
70+
buildConfigField "String", "assetUID", localProperties['assetUid']
71+
}
72+
release {
73+
minifyEnabled false
74+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
75+
}
76+
}
77+
flavorDimensions "default"
78+
lintOptions { abortOnError false }
79+
compileOptions {
80+
sourceCompatibility JavaVersion.VERSION_1_8
81+
targetCompatibility JavaVersion.VERSION_1_8
82+
}
83+
}
84+
repositories {
85+
flatDir { dirs 'libs' }
86+
mavenCentral()
87+
mavenLocal()
88+
}
89+
configurations { archives }
90+
dependencies {
91+
configurations.all { resolutionStrategy.force 'com.android.support:support-annotations:23.1.0' }
92+
implementation fileTree(include: ['*.jar'], dir: 'libs')
93+
implementation 'com.contentstack.sdk:utils:1.1.0'
94+
implementation 'com.android.support:appcompat-v7:26.1.0'
95+
implementation 'com.android.support:support-v4:26.1.0'
96+
implementation 'com.android.volley:volley:1.2.0'
97+
testImplementation 'junit:junit:4.13.2'
98+
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
99+
exclude group: 'com.android.support', module: 'support-annotations'
100+
})
101+
}
102+
task clearJar(type: Delete) { delete 'build/libs/Contentstack.jar' }
103+
task unzip(type: Copy) {
104+
def zipFile = file('build/intermediates/intermediate-jars/release/classes.jar')
105+
def outputDir = file("${buildDir}/Contentstack-jar")
106+
from zipTree(zipFile)
107+
into outputDir
108+
}
109+
task createJar(type: Jar) {
110+
archiveName = 'Contentstack.jar'
111+
from('build/Contentstack-jar/')
112+
include 'com/contentstack/'
113+
include 'META-INF/'
114+
}
115+
createJar.dependsOn(clearJar, unzip, build)
116+
/*============================================*/
117+
/*=========== [ MAVEN-PUSH-UPLOAD ] ==========*/
118+
// to upload library to the maven repo run comman -> ./gradlew clean deploy uploadArchive
119+
// on successful upload completion
120+
// visit to the url https://oss.sonatype.org/#stagingRepositories
121+
// select the Staging Repository tab and select the build and close it
122+
// after successful closing publish the artifact to go live
123+
// it will drop the coordinates after successful deployment
124+
/*=============================================*/
125+
def localProperties = new Properties()
126+
localProperties.load(new FileInputStream(rootProject.file("local.properties")))
127+
group = "com.contentstack.sdk"
128+
archivesBaseName = "android"
129+
version = "3.10.0-SNAPSHOT"
130+
task sourceJar(type: Jar) {
131+
from android.sourceSets.main.java.srcDirs
132+
classifier "source"
133+
}
134+
task javadoc(type: Javadoc) {
135+
source = android.sourceSets.main.java.srcDirs
136+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
137+
destinationDir = file("../javadoc/")
138+
failOnError false
139+
}
140+
task javadocJar(type: Jar, dependsOn: javadoc) {
141+
classifier = 'javadoc'
142+
from tasks.javadoc.destinationDir
143+
}
144+
task androidSourcesJar(type: Jar) {
145+
classifier = 'sources'
146+
from android.sourceSets.main.java.srcDirs
147+
}
148+
artifacts {
149+
archives javadocJar
150+
archives androidSourcesJar
151+
}
152+
signing { sign configurations.archives }
153+
uploadArchives {
154+
repositories {
155+
mavenDeployer {
156+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
157+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
158+
authentication(userName: ossrhUsername, password: ossrhPassword)
159+
}
160+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
161+
authentication(userName: ossrhUsername, password: ossrhPassword)
162+
}
163+
pom.project {
164+
name 'contentstack-android-sdk'
165+
packaging 'aar'
166+
description 'Android SDK for Contentstack Content Delivery API, Contentstack is a headless CMS with an API-first approach'
167+
artifactId "android"
168+
url 'https://github.com/contentstack/contentstack-android'
169+
170+
scm {
171+
url 'https://github.com/contentstack/contentstack-android/'
172+
connection 'scm:git@github.com:contentstack/contentstack-android'
173+
developerConnection 'scm:git@github.com:contentstack/contentstack-android.git'
174+
}
175+
176+
licenses {
177+
license {
178+
name 'The MIT License'
179+
url 'http://www.opensource.org/licenses/mit-license.php'
180+
distribution 'repo'
181+
}
182+
}
183+
184+
developers {
185+
developer {
186+
id 'mshaileshr@gmail.com'
187+
name 'Shailesh Mishra'
188+
email 'mobile@contentstack.com'
189+
}
190+
}
191+
}
192+
}
193+
}
194+
}
195+
task uploadSnapshotArchives(dependsOn: uploadArchives) {
196+
if (!version.endsWith("-SNAPSHOT")) {
197+
enabled = false;
198+
dependsOn = [];
199+
}
200+
}
201+
202+
203+
204+
205+

0 commit comments

Comments
 (0)