Skip to content

Commit

Permalink
Merge branch 'gradle/fast_tpatch' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jiawulu committed Jun 26, 2017
2 parents cd2f140 + ab3438d commit ff31187
Show file tree
Hide file tree
Showing 51 changed files with 2,374 additions and 1,044 deletions.
41 changes: 41 additions & 0 deletions atlas-demo/AtlasDemo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## 更新日志

1. 升级atlasplugin到2.3.3.beta1
2. 支持awb之间的依赖,具体参考 firstbundle的配置
1. dependencies 里添加 provided依赖

providedCompile project(':publicbundle')
2. 申明bundle之间依赖关系

➜ firstbundle git:(gradle/2.3.3) ✗ more bundleBaseInfoFile.json
{
"name": "第一个bundle",
"dependency": ["com.taobao.publicBundle"]
}
3. 在 app中添加被依赖的bundle

bundleCompile project(':publicbundle')
3. 加入databinding的bundle,具体参见app的配置

1. 添加databinding的bundle依赖

bundleCompile project(':databindbundle')
2. 配置需要开启的databinding列表

atlas {
tBuildConfig {
dataBindingBundles = ['com.taobao.databindbundle']
...
3. 注意同时开启app的databinding
android {
dataBinding {
enabled = true
}
2 changes: 1 addition & 1 deletion atlas-demo/AtlasDemo/activitygroupcompat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.1.0'
compile('com.taobao.android:atlas_core:5.0.7.166-SNAPSHOT')
compile('com.taobao.android:atlas_core:5.0.7.26')
//compile project(':atlas-core')
}
7 changes: 4 additions & 3 deletions atlas-demo/AtlasDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ android {
// dev {
// minSdkVersion 14
// }
//

// beta {
// minSdkVersion 21
// }
Expand All @@ -59,6 +59,7 @@ atlas {
outOfApkBundles = ['remotebundle']
preLaunch = 'com.taobao.demo.DemoPreLaunch'
classInject false
dataBindingBundles = ['com.taobao.databindbundle']
}

manifestOptions {
Expand Down Expand Up @@ -86,7 +87,7 @@ atlas {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile('com.taobao.android:atlas_core:5.0.7.166-SNAPSHOT@aar') {
compile('com.taobao.android:atlas_core:5.0.7.26@aar') {

transitive = true
}
Expand All @@ -100,7 +101,7 @@ dependencies {
bundleCompile project(':secondbundle')
bundleCompile project(':remotebundle')
bundleCompile project(':publicbundle')
// bundleCompile project(':databindbundle')
bundleCompile project(':databindbundle')

compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ protected void onPostExecute(Void aVoid) {
android.os.Process.killProcess(android.os.Process.myPid());
}
}.execute();
}
}else if (id == R.id.nav_databind_bundle) {

Intent intent = new Intent();
intent.setPackage(getPackageName());
intent.setClassName(this,"com.taobao.databindbundle.databind.DataBundleSampleActivity");
startActivity(intent);
}

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<item
android:id="@+id/nav_dex_patch"
android:title="dex_patch模拟" />
<item
android:id="@+id/nav_databind_bundle"
android:title="databinding模拟" />
</group>

<item android:title="Communicate">
Expand Down
2 changes: 1 addition & 1 deletion atlas-demo/AtlasDemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
dependencies {
classpath "com.taobao.android:atlasplugin:2.3.1.beta55"
classpath "com.taobao.android:atlasplugin:2.3.3.beta2"
}
}

Expand Down
2 changes: 1 addition & 1 deletion atlas-demo/AtlasDemo/firstbundle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
providedCompile project(':middlewarelibrary')
// bundleCompile project(':publicbundle')
providedCompile project(':publicbundle')

compile 'com.android.support.constraint:constraint-layout:1.0.0'
providedCompile 'com.android.support:support-v4:25.3.0'
Expand Down
4 changes: 4 additions & 0 deletions atlas-demo/AtlasDemo/firstbundle/bundleBaseInfoFile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "第一个bundle",
"dependency": ["com.taobao.publicBundle"]
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package com.taobao.firstbundle;

import android.content.ContentResolver;
import android.content.res.Resources;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.taobao.firstbundle.fragment.BlankFragment;

import java.io.FileNotFoundException;
import java.io.InputStream;
import com.taobao.publicBundle.Tools;

public class FirstBundleActivity extends AppCompatActivity implements BlankFragment.OnFragmentInteractionListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_firstbundle);

// bundleCompile
Log.e("providedComple awb", "invoke tools at public bundle Tools.getCurrentTime() > " + Tools.getCurrentTime());

// Toast.makeText(this,"dsfsfs",Toast.LENGTH_LONG).show();
}

Expand Down
3 changes: 2 additions & 1 deletion atlas-demo/AtlasDemo/publicbundle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ android {
targetSdkVersion 25
versionCode 1
versionName "1.0"

//bundle的自有配置
consumerProguardFiles 'proguard-rules.pro'

}
buildTypes {
Expand Down
1 change: 1 addition & 0 deletions atlas-demo/AtlasDemo/publicbundle/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keep class com.taobao.publicBundle.Tools {*;}
15 changes: 13 additions & 2 deletions atlas-gradle-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@

## changelog

### TODO
### 2.3.3.beta1

1. unit tag diff bundle 不变
0. 升级android builder 到 2.3.3版本
1. unit tag 非 diff bundle 保持 不变
2. tBuildConfig.minPackageId 可设置最小的自动分配packageId,默认35(10进制)开始
3. 加强对插件配置使用的校验
1. 不推荐在atlasplugin之前添加google官方的插件,推荐让atlasplugin自动依赖传递进来
2. bundle之前的依赖推荐使用bundleCompile, 如果使用compile awb,会有警告日志
3. awb 之间允许使用 providedCompile 依赖
4. databinding优化,后续bundle的databinding需要独立配置是否启用

tBuildConfig.dataBindingBundles
配置值为 bundle 的packageName
类型为 Set<String>
代码: com.taobao.android.builder.extension.TBuildConfig.dataBindingBundles


### 2.3.1.rc15
Expand Down
7 changes: 3 additions & 4 deletions atlas-gradle-plugin/atlas-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ tasks.findByName("test").enabled=false
dependencies {
compile localGroovy()
compile gradleApi()
compile "com.android.tools.build:gradle:2.3.1"
compile "com.android.tools.build:gradle:2.3.3"
compile "org.apache.commons:commons-lang3:3.4"
compile "commons-lang:commons-lang:2.6"
compile "com.alibaba:fastjson:1.2.6"
Expand All @@ -242,10 +242,9 @@ dependencies {

compile "com.taobao.android:aapt:2.3.1.rc2"

compile "com.taobao.android:dex_patch:1.4.0.9-rc16"
compile "com.taobao.android:dex_patch:1.4.1"

testCompile "junit:junit:4.11"
}

version = '2.3.1.beta59'

version = '2.3.3.beta2'
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.build.gradle.AndroidGradleOptions;
import com.android.build.gradle.AppPlugin;
import com.android.build.gradle.internal.dependency.DependencyGraph;
import com.android.build.gradle.internal.dependency.MutableDependencyDataMap;
import com.android.build.gradle.internal.dependency.VariantDependencies;
Expand Down Expand Up @@ -914,7 +915,10 @@ private void addDependency(
}

// if we don't have one, need to create it.
if (EXT_LIB_ARCHIVE.equals(artifact.getExtension())) {
if (EXT_LIB_ARCHIVE.equals(artifact.getExtension()) ||
//不是app工程,并且是awb依赖
("awb".equals(artifact.getExtension()) && !project.getPlugins().hasPlugin(AppPlugin.class))) {

if (DEBUG_DEPENDENCY) {
printIndent(indent, "TYPE: AAR");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,4 +511,14 @@ public File getAwbProguardDir(AwbBundle awbBundle) {
file.mkdirs();
return file;
}

public boolean isDataBindEnabled(AwbBundle awbBundle){

if( null == appExtension.getDataBinding() || !appExtension.getDataBinding().isEnabled()) {
return false;
}

return atlasExtension.getTBuildConfig().getDataBindingBundles().contains(awbBundle.getPackageName());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.android.builder.dependency.MavenCoordinatesImpl;
import com.android.builder.dependency.level2.AndroidDependency;
Expand All @@ -225,7 +226,10 @@
import com.taobao.android.builder.dependency.parser.ResolvedDependencyInfo;
import org.apache.commons.lang.StringUtils;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ModuleVersionIdentifier;
import org.gradle.api.artifacts.ResolvedArtifact;
import org.gradle.api.artifacts.result.DependencyResult;
import org.gradle.api.artifacts.result.ResolvedDependencyResult;

/**
* 依赖对象转换的工具类
Expand Down Expand Up @@ -372,4 +376,20 @@ public static MavenCoordinatesImpl convert(ResolvedArtifact artifact) {
artifact.getExtension(),
artifact.getClassifier());
}

public static boolean isAwbDependency(DependencyResult dependencyResult,
Map<ModuleVersionIdentifier, List<ResolvedArtifact>> artifacts) {
if (dependencyResult instanceof ResolvedDependencyResult) {
ResolvedDependencyResult resolvedDependencyResult = (ResolvedDependencyResult)dependencyResult;
ModuleVersionIdentifier moduleVersionIdentifier = resolvedDependencyResult.getSelected().getModuleVersion();
List<ResolvedArtifact> resolvedArtifacts = artifacts.get(moduleVersionIdentifier);

if (resolvedArtifacts.size() > 0) {
ResolvedArtifact resolvedArtifact = resolvedArtifacts.get(0);
return ("awb".equals(resolvedArtifact.getType()));
}
}
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,21 @@

package com.android.builder.core;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.lang.reflect.Method;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.android.SdkConstants;
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
Expand All @@ -235,9 +250,6 @@
import com.android.builder.symbols.RGeneration;
import com.android.builder.symbols.SymbolIo;
import com.android.builder.symbols.SymbolTable;
import com.taobao.android.dex.Dex;
import com.taobao.android.dx.merge.CollisionPolicy;
import com.taobao.android.dx.merge.DexMerger;
import com.android.ide.common.process.JavaProcessExecutor;
import com.android.ide.common.process.ProcessException;
import com.android.ide.common.process.ProcessExecutor;
Expand Down Expand Up @@ -272,6 +284,9 @@
import com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper;
import com.taobao.android.builder.tools.manifest.ManifestFileUtils;
import com.taobao.android.builder.tools.zip.ZipUtils;
import com.taobao.android.dex.Dex;
import com.taobao.android.dx.merge.CollisionPolicy;
import com.taobao.android.dx.merge.DexMerger;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
Expand All @@ -281,14 +296,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.lang.reflect.Method;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.*;

import static com.android.builder.model.AndroidProject.FD_INTERMEDIATES;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
Expand Down Expand Up @@ -937,7 +944,9 @@ public void convertByteCode(Collection<File> inputs,
List<File> outputs = new ArrayList<>();

if (fastMultiDex) {
//TODO fixme
ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper("maindex", sLogger, inputs.size() > 8 ? 8 : inputs.size());
//ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper("maindex", sLogger, 1);
List<Runnable> runnables = new ArrayList<>();
for (File input : inputs) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,12 @@
import javax.inject.Inject;

import com.android.build.gradle.AndroidGradleOptions;
import com.android.build.gradle.internal.AtlasDependencyManager;
import com.android.build.gradle.internal.DependencyManager;
import com.taobao.android.builder.manager.AtlasConfigurationHelper;
import com.taobao.android.builder.manager.Version;
import com.taobao.android.builder.tasks.helper.AtlasListTask;
import com.taobao.android.builder.tools.PathUtil;
import com.taobao.android.builder.tools.PluginTypeUtils;
import com.taobao.android.builder.tools.log.LogOutputListener;
import org.gradle.api.Action;
Expand Down Expand Up @@ -356,6 +359,11 @@ private void checkPluginSetup() {
//throw new StopExecutionException(errorMessage);
}

if(!PathUtil.getJarFile(DependencyManager.class).getAbsolutePath().equals(PathUtil.getJarFile(AtlasDependencyManager.class).getAbsolutePath())){
throw new StopExecutionException("please remove the google plugin `classpath 'com.android.tools.build:gradle:xxx'` in buildscript dependencies \n"
+ "it will be auto include by atlasplugin");
}

}

}
Loading

0 comments on commit ff31187

Please sign in to comment.