Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
14 changed files
with
42 additions
and
77 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
2 changes: 1 addition & 1 deletion
2
locallydynamic-android-lib/sample/installtimefeature/src/main/res/values/strings.xml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="install_time_feature_string">Hi, I am a fragment from an install time feature</string> | ||
<string name="install_time_feature_string" translatable="false">Hi, I am a fragment from an install time feature</string> | ||
</resources> |
2 changes: 1 addition & 1 deletion
2
locallydynamic-android-lib/sample/ondemandfeature/src/main/res/values/strings.xml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="on_demand_feature_string">Hi, I am a fragment from an on demand feature</string> | ||
<string name="on_demand_feature_string" translatable="false">Hi, I am a fragment from an on demand feature</string> | ||
</resources> |
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
10 changes: 10 additions & 0 deletions
10
...le-plugin/plugin/src/main/java/com/jeppeman/locallydynamic/gradle/extensions/BuildType.kt
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,10 @@ | ||
package com.jeppeman.locallydynamic.gradle.extensions | ||
|
||
import com.android.build.gradle.internal.dsl.BuildType | ||
import com.jeppeman.locallydynamic.gradle.LocallyDynamicExtension | ||
import org.gradle.api.plugins.ExtensionAware | ||
|
||
fun BuildType.locallyDynamic(block: LocallyDynamicExtension.() -> Unit) { | ||
val extension = (this as ExtensionAware).extensions.getByType(LocallyDynamicExtension::class.java) | ||
extension.apply(block) | ||
} |
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
57 changes: 5 additions & 52 deletions
57
...namic-studio-plugin/src/main/kotlin/com/jeppeman/locallydynamic/idea/extensions/Module.kt
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 |
---|---|---|
@@ -1,57 +1,10 @@ | ||
package com.jeppeman.locallydynamic.idea.extensions | ||
|
||
import com.android.tools.idea.gradle.util.GradleUtil | ||
import com.android.tools.idea.gradle.project.facet.gradle.GradleFacet | ||
import com.intellij.openapi.module.Module | ||
import org.jetbrains.kotlin.idea.core.util.toPsiFile | ||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile | ||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap | ||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument | ||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression | ||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall | ||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral | ||
import java.util.HashMap | ||
|
||
val Module.hasLocallyDynamicEnabled: Boolean | ||
get() { | ||
GradleUtil.getGradleBuildFile(this)?.let { file -> | ||
file.toPsiFile(project)?.let { psiFile -> | ||
return when (psiFile) { | ||
!is GroovyFile -> false | ||
else -> psiFile.plugins.contains("com.jeppeman.locallydynamic") | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
|
||
val GroovyFile.plugins: List<String> | ||
get() = ArrayList<String>().apply { | ||
statements.toList().filterIsInstance<GrMethodCall>() | ||
.filter { "apply" == it.invokedExpression.text } | ||
.forEach { methodCall -> | ||
val values = HashMap<String?, Any?>() | ||
methodCall.argumentList.allArguments.filterIsInstance<GrNamedArgument>().forEach { | ||
values[it.labelName] = it.expression?.parseValueExpression() | ||
} | ||
values["plugin"]?.let { plugin -> | ||
add(plugin.toString()) | ||
} | ||
} | ||
} | ||
|
||
private fun GrExpression.parseValueExpression(): Any? { | ||
return when (this) { | ||
is GrLiteral -> value | ||
is GrListOrMap -> { | ||
if (isMap) return null | ||
ArrayList<Any>().apply { | ||
initializers.forEach { subexpression -> | ||
subexpression.parseValueExpression()?.let { subValue -> | ||
add(subValue) | ||
} | ||
} | ||
} | ||
} | ||
else -> null | ||
} | ||
} | ||
get() = GradleFacet.getInstance(this) | ||
?.gradleModuleModel | ||
?.gradlePlugins | ||
?.contains("com.jeppeman.locallydynamic.gradle.LocallyDynamicPlugin") == true |