forked from wequick/Small
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract AarPath class to check if a path is exploded from a specified…
… aar
- Loading branch information
Showing
6 changed files
with
121 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
Android/DevSample/buildSrc/src/main/groovy/net/wequick/gradle/util/AarPath.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2015-present wequick.net | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. You may obtain | ||
* a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package net.wequick.gradle.util | ||
|
||
public class AarPath { | ||
|
||
private static final String CACHE_DIR = "build-cache" | ||
private static final String CACHE_INPUTS_FILE = "inputs" | ||
private static final String CACHE_FILE_PATH_KEY = "FILE_PATH" | ||
|
||
private String mSrc | ||
private boolean isCache | ||
|
||
public AarPath(File path) { | ||
mSrc = path.absolutePath | ||
if (mSrc.contains(CACHE_DIR)) { | ||
this.initWithCachePath(path) | ||
} | ||
} | ||
|
||
private void initWithCachePath(File path) { | ||
while (path.parentFile.name != CACHE_DIR) { | ||
path = path.parentFile | ||
} | ||
|
||
File input = new File(path, CACHE_INPUTS_FILE) | ||
if (!input.exists()) { | ||
return | ||
} | ||
|
||
def prop = new Properties() | ||
prop.load(input.newDataInputStream()) | ||
def src = prop.getProperty(CACHE_FILE_PATH_KEY) | ||
if (src == null) { | ||
return | ||
} | ||
|
||
mSrc = src | ||
isCache = true | ||
} | ||
|
||
public boolean explodedFromAar(Map aar) { | ||
// ~/.gradle/caches/modules-2/files-2.1/net.wequick.small/small/1.1.0/hash/*.aar | ||
// ^^^^^^^^^^^^^^^^^ ^^^^^ | ||
def moduleAarDir = "$aar.group$File.separator$aar.name" | ||
if (mSrc.contains(moduleAarDir)) { | ||
return true | ||
} | ||
|
||
// [sdk]/extras/android/m2repository/com/android/support/support-core-ui/25.1.0/*.aar | ||
// ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ | ||
def repoGroup = aar.group.replaceAll('\\.', File.separator) | ||
def repoAarPath = "$repoGroup$File.separator$aar.name" | ||
return mSrc.contains(repoAarPath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters