Skip to content

Commit

Permalink
发布私服测试
Browse files Browse the repository at this point in the history
  • Loading branch information
byhook committed Jun 20, 2018
1 parent 0157f82 commit ed41e47
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'

compile(name: 'merge-release', ext: 'aar')
//compile 'com.onzhou.module:merge:1.0.0'
//compile(name: 'merge-release', ext: 'aar')
compile 'com.onzhou.module:merge:1.0.1'

}
Binary file modified app/libs/merge-release.aar
Binary file not shown.
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.onzhou.module">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/onzhou/module/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public void onUploadClick(View view) {


public void onLiveClick(View view) {

LiveRoomActivity.intentStart(this);
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:2.2.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
60 changes: 44 additions & 16 deletions fat-aar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ ext.generated_rsrc_dir = "$build_dir/generated/source/r/release";
ext.base_r2x_dir = "$build_dir/fat-aar/release/";

def gradleVersionStr = GradleVersion.current().getVersion();
ext.gradleApiVersion = gradleVersionStr.substring(0, gradleVersionStr.lastIndexOf(".")).toFloat();

//2.2以上api有变动,报错
ext.gradleApiVersion = "2.2".toFloat();//gradleVersionStr.substring(0, gradleVersionStr.lastIndexOf(".")).toFloat();

println "Gradle version: " + gradleVersionStr;

Expand All @@ -111,12 +113,12 @@ afterEvaluate {
embeddedAarFiles.add(artifact)
}
if (!embeddedAarDirs.contains(aarPath)) {
if( artifact.file.isFile() ){
if (artifact.file.isFile()) {
println artifact.file
println aarPath

copy {
from zipTree( artifact.file )
from zipTree(artifact.file)
into aarPath
}
}
Expand Down Expand Up @@ -144,11 +146,12 @@ afterEvaluate {
// Embed JNI Libraries
bundleRelease.dependsOn embedJniLibs

if(gradleApiVersion >= 2.3f) {
println("==============================" + gradleApiVersion + "==========================")

embedJniLibs.dependsOn transformNativeLibsWithSyncJniLibsForRelease
if (gradleApiVersion >= 2.3f) {
embedJniLibs.dependsOn transformNativelibsWithSyncJniLibsForRelease
ext.bundle_release_dir = "$build_dir/intermediates/bundles/default"
}else{
} else {
embedJniLibs.dependsOn transformNative_libsWithSyncJniLibsForRelease
ext.bundle_release_dir = "$build_dir/intermediates/bundles/release";
}
Expand All @@ -169,6 +172,9 @@ afterEvaluate {
bundleRelease.dependsOn embedJavaJars
embedJavaJars.dependsOn compileReleaseJavaWithJavac

//合并R文件
collectRClass.dependsOn compileReleaseJavaWithJavac

// If proguard is enabled, run the tasks that bundleRelease should depend on before proguard
if (tasks.findByPath('proguardRelease') != null) {
proguardRelease.dependsOn embedJavaJars
Expand All @@ -187,13 +193,27 @@ task embedLibraryResources << {
}
}

/**
* 本地资源
* 由于合并module的时候
* 资源文件无法替换
*/

private List getMergedInputResourceSets(List inputResourceSet) {
//We need to do this trickery here since the class declared here and that used by the runtime
//are different and results in class cast error
def ResourceSetClass = inputResourceSet.get(0).class

List newInputResourceSet = new ArrayList(inputResourceSet)

HashMap<String, String> localRes = new HashMap<String, String>()
String path = buildDir.path.replace("/build", "") + "/src/main/res"
FileTree moduleRes = fileTree(dir: path, include: '**/*.xml')
moduleRes.each { File file ->
println("路径=" + file.getAbsolutePath() + "/" + file.getName())
localRes.put(file.getName(), file.getAbsolutePath())
}

println "getMergedInputResourceSets"

println embeddedAarDirs
Expand All @@ -216,13 +236,21 @@ private List getMergedInputResourceSets(List inputResourceSet) {
if (startIndex < 1 || endIndex < 1)
return;
resname = aarPath.substring(startIndex, endIndex).replace('/', ':')
}
else
} else
resname = (aarPath.split(exploded_aar_dir)[1]).replace('/', ':');

FileTree libRes = fileTree(dir: "$aarPath/res", include: '**/*.xml')
libRes.each { File file ->
if (localRes.containsKey(file.getName())) {
println("资源重复" + file.getAbsolutePath())
file.delete()
}
}
def rs = ResourceSetClass.newInstance([resname, true] as Object[])
rs.addSource(file("$aarPath/res"))
println "ResourceSet is " + rs
println resname
println "$aarPath/res"
newInputResourceSet += rs
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -272,19 +300,19 @@ task generateRJava << {
def mainManifestFile = android.sourceSets.main.manifest.srcFile;
def libPackageName = "";

if(mainManifestFile.exists()) {
if (mainManifestFile.exists()) {

libPackageName = new XmlParser().parse(mainManifestFile).@package
}

embeddedAarDirs.each { aarPath ->

def manifestFile = file("$aarPath/AndroidManifest.xml");
if(!manifestFile.exists()) {
if (!manifestFile.exists()) {
manifestFile = file("./src/main/AndroidManifest.xml");
}

if(manifestFile.exists()) {
if (manifestFile.exists()) {
def aarManifest = new XmlParser().parse(manifestFile);
def aarPackageName = aarManifest.@package

Expand Down Expand Up @@ -366,7 +394,7 @@ task embedJavaJars(dependsOn: embedRClass) << {
else
jar_dir = "$aarPath/jars"

if(embeddedAarFiles.size() > 0){
if (embeddedAarFiles.size() > 0) {

embeddedAarFiles.each {
artifact ->
Expand All @@ -380,7 +408,7 @@ task embedJavaJars(dependsOn: embedRClass) << {
}
}

}else{
} else {

println jar_dir
println classs_release_dir
Expand Down Expand Up @@ -447,11 +475,11 @@ task embedManifests << {
File copyManifest = file("$bundle_release_dir/AndroidManifest.orig.xml")
File aaptManifest = file("$manifest_aaapt_dir/AndroidManifest.xml")

if(!origManifest.exists()) {
if (!origManifest.exists()) {
origManifest = file("./src/main/AndroidManifest.xml")
}

if(!origManifest.exists()) {
if (!origManifest.exists()) {
return;
}

Expand Down Expand Up @@ -539,4 +567,4 @@ class MiLogger implements ILogger {
void verbose(@NonNull String msgFormat, Object... args) {
// System.out.println(String.format("========== DEBUG : " + msgFormat, args))
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
12 changes: 12 additions & 0 deletions liveroom/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
apply from: '../module.gradle'


repositories {
jcenter()
flatDir {
dirs "$rootDir/liveroom/libs"
}
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.github.bumptech.glide:glide:3.8.0'

compile project(':common')
compile project(':download')
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

/**
* @author: andy
Expand All @@ -22,4 +25,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_live_room);
}

@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
ImageView imageView = (ImageView) findViewById(R.id.iv_main);
Glide.with(this).load("http://cdn.byhook.cn/0fc87e6251577216b34ec31f1f76ffdd-320_320.jpg").into(imageView);
}
}
6 changes: 6 additions & 0 deletions liveroom/src/main/res/layout/activity_live_room.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@
android:padding="10dp"
android:text="直播间" />


<ImageView
android:id="@+id/iv_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>
4 changes: 2 additions & 2 deletions merge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ apply from: '../publish.gradle'

android {

/*libraryVariants.all { variant ->
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = getArtifactFileName()
output.outputFile = new File(outputFile.parent, fileName)
}
}
}*/
}

}

Expand Down
2 changes: 1 addition & 1 deletion merge/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
#Fri Aug 18 12:04:47 CST 2017
#maven配置
GROUP=com.onzhou.module
VERSION_NAME=1.0.0
VERSION_NAME=1.0.1
POM_ARTIFACT_ID=merge
7 changes: 7 additions & 0 deletions module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ android {
}
}

repositories {
jcenter()
flatDir {
dirs 'libs', "$rootDir/liveroom/libs"
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
Expand Down
1 change: 0 additions & 1 deletion publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ publishing {
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')

//Iterate over the compile dependencies, adding a <dependency> node for each
depList.values().each {
ResolvedDependency dep ->
def hasGroup = dep.moduleGroup != null
Expand Down

0 comments on commit ed41e47

Please sign in to comment.