android / project-replicator Goto Github PK
View Code? Open in Web Editor NEWThis project contains a Gradle plugin and a small command-line app that allows replicating the structure of a given Gradle project.
License: Apache License 2.0
This project contains a Gradle plugin and a small command-line app that allows replicating the structure of a given Gradle project.
License: Apache License 2.0
Trying to apply the plugin as described in https://github.com/android/project-replicator/blob/master/docs/USAGE.md results in multiple build errors, at various times:
* What went wrong:
A problem occurred evaluating project ':host-api-demo'.
> KOTLIN_STAT_ENABLED_PROPERTY
* What went wrong:
A problem occurred configuring project ':host-api-demo'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
* What went wrong:
A problem occurred evaluating project ':host-api-demo'.
> Could not initialize class org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuildServices
These Android modules do have compileSdkVersion (or compileSdk using newer dsl). Some modules are not Android modules.
What worked for me was to move the buildscript/classpath entry from build.gradle into settings.gradle's pluginManagement block, add the plugin by id to settings.gradle's plugin{} block, add a resolutionStrategy (since there's no gradle plugin marker published) to resolve the plugin id, and then change the init.gradle's allprojects{apply} to apply by plugin id.
--- settings.gradle
+++ settings.gradle
@@ -48,0 +48,1 @@ pluginManagement {
+ id "com.android.gradle.project.replicator" version "0.2"
@@ -55,2 +56,5 @@ pluginManagement {
resolutionStrategy {
eachPlugin {
+ if (requested.id.id == "com.android.gradle.project.replicator") {
+ useModule("com.android.gradle.replicator:project-replicator:0.2")
+ }
@@ -69,0 +72,1 @@ plugins {
+ id "com.android.gradle.project.replicator" apply false
--- build.gradle
+++ build.gradle
@@ -27,0 +30,3 @@
+allprojects {
+ apply plugin: "com.android.gradle.project.replicator"
+}
This allowed :getStructure
to complete successfully.
Kotlin 1.7.20
Android Gradle Plugin 7.3.1
Gradle 7.5.1
I have built the plugin to the local Maven repository and modified my project's main build.gradle.kts
like this:
buildscript {
repositories {
mavenLocal()
google()
mavenCentral()
}
dependencies {
classpath("com.android.gradle.replicator:project-replicator:0.2")
classpath(libs.kotlin.pluginGradle)
classpath(libs.android.pluginGradle)
}
}
allprojects {
repositories {
google()
mavenCentral()
apply {
plugin("com.android.gradle.replicator.ProjectReplicatorPlugin")
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
}
}
However when syncing Gradle I get the following error:
> Could not determine the dependencies of null.
> Could not resolve all task dependencies for configuration ':classpath'.
> Could not resolve com.android.gradle.replicator:project-replicator:0.2.
Required by:
project :
> No matching variant of com.android.gradle.replicator:project-replicator:0.2 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5.1' but:
- Variant 'apiElements' capability com.android.gradle.replicator:project-replicator:0.2 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 15 and the consumer needed a runtime of a component compatible with Java 11
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5.1')
- Variant 'runtimeElements' capability com.android.gradle.replicator:project-replicator:0.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component compatible with Java 15 and the consumer needed a component compatible with Java 11
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5.1')
The replicated project can't be built with AGP 8.0 because android { namespace = "..." }
is missing.
> Task :my-module:gatherModuleInfo
e: Invalid xml file my-module/src/main/res/values/strings.xml
line 4; column 10: DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.
<!DOCTYPE resources [
↑
Skipping file parsing
This does not terminate the process, it just skips the file.
I'm not sure what the reason is for disallowing DOCTYPE, but it is useful to add named entities for unusual characters. For example, we use it to define entity aliases like these that we can then use in our strings:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE resources [
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY lsquo "‘">
<!ENTITY rsquo "’">
<!ENTITY hellip "…">
<!ENTITY prime "′">
<!ENTITY Prime "″">
<!ENTITY bull "•">
<!ENTITY thinsp " ">
<!ENTITY hairsp " ">
]>
Then later we can refer to these standard entity names in the strings:
<string name="string_name">One last thing…</string>
In this case, we prefer to use …
here, because it is more meaningful for translators, and it is more grammatically correct. I.e., using …
vs ...
. It also translates differently for some languages - for example, some languages prefer a different type of ellipsis, like the midline (⋯
) or vertical ellipsis (⋮
).
Inlining the unicode character can often be difficult for people reading the file to understand that it is a unicode character rather than its similar non-unicode counterpart (i.e., '
apostrophe vs ’
right-single quotation or rsquo), which is why we use the &#<>;
notation. And inlining that notation into the string, someone reading the file won't understand what that number represents unless they look it up.
So the workaround is using the named XML entity: it gives us the exact unicode representation, with a meaningful name, without compromising the character width which can have an impact on some older editors that aren't well equipped to handle multi-byte unicode characters.
Hi!
This code in build.gradle.kts doesn't work:
plugins {
kotlin("jvm") version "1.7.21"
}
buildscript {
repositories {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath("com.android.gradle.replicator:project-replicator:0.2")
}
}
}
allprojects {
apply(plugin = "com.android.gradle.replicator.ProjectReplicatorPlugin") // Plugin with id 'com.android.gradle.replicator.ProjectReplicatorPlugin' not found.
}
What should I do to make it work?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.