build: move composite build to separate directory and add desugar Gradle plugin

This commit is contained in:
Akash Yadav
2024-03-02 12:55:59 +05:30
parent cee7d6a024
commit 7705c06dcc
3132 changed files with 2622 additions and 30 deletions
+40
View File
@@ -166,12 +166,52 @@
<module name="ATS.tree-sitter-log" target="17" />
<module name="ATS.tree-sitter-python" target="17" />
<module name="ATS.tree-sitter-xml" target="17" />
<module name="build-deps.appintro" target="17" />
<module name="build-deps.desugaring-core" target="11" />
<module name="build-deps.desugaring-core.main" target="11" />
<module name="build-deps.desugaring-core.test" target="11" />
<module name="build-deps.fuzzysearch" target="17" />
<module name="build-deps.fuzzysearch.main" target="17" />
<module name="build-deps.fuzzysearch.test" target="17" />
<module name="build-deps.google-java-format" target="17" />
<module name="build-deps.javac" target="17" />
<module name="build-deps.javac.main" target="17" />
<module name="build-deps.javac.test" target="17" />
<module name="build-deps.javapoet" target="17" />
<module name="build-deps.javapoet.main" target="17" />
<module name="build-deps.javapoet.test" target="17" />
<module name="build-deps.jdk-jdeps" target="17" />
<module name="build-deps.jdk-jdeps.main" target="17" />
<module name="build-deps.jdk-jdeps.test" target="17" />
<module name="build-deps.jdt" target="17" />
<module name="build-deps.jdt.main" target="17" />
<module name="build-deps.jdt.test" target="17" />
<module name="build-deps.layoutlib-api" target="17" />
<module name="build-deps.layoutlib-api.main" target="17" />
<module name="build-deps.layoutlib-api.test" target="17" />
<module name="build-logic.ats" target="17" />
<module name="build-logic.ats.main" target="17" />
<module name="build-logic.ats.test" target="17" />
<module name="build-logic.common" target="17" />
<module name="build-logic.common.main" target="17" />
<module name="build-logic.common.test" target="17" />
<module name="build-logic.desugaring" target="17" />
<module name="build-logic.desugaring-core" target="11" />
<module name="build-logic.desugaring-core.main" target="11" />
<module name="build-logic.desugaring-core.test" target="11" />
<module name="build-logic.desugaring.main" target="17" />
<module name="build-logic.desugaring.test" target="17" />
<module name="build-logic.ide" target="17" />
<module name="build-logic.ide.main" target="17" />
<module name="build-logic.ide.test" target="17" />
<module name="build-logic.plugins" target="17" />
<module name="build-logic.plugins.main" target="17" />
<module name="build-logic.plugins.test" target="17" />
<module name="build-logic.properties-parser" target="17" />
<module name="build-logic.properties-parser.main" target="17" />
<module name="build-logic.properties-parser.test" target="17" />
<module name="composite-builds.build-logic.desugaring-core.main" target="11" />
<module name="composite-builds.build-logic.desugaring-core.test" target="11" />
<module name="composite-builds.plugins" target="17" />
<module name="composite-builds.plugins.main" target="17" />
<module name="composite-builds.plugins.test" target="17" />
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>
+12 -1
View File
@@ -1,7 +1,8 @@
@file:Suppress("UnstableApiUsage")
import com.itsaky.androidide.plugins.AndroidIDEAssetsPlugin
import com.itsaky.androidide.build.config.BuildConfig
import com.itsaky.androidide.desugaring.utils.JavaIOReplacements.applyJavaIOReplacements
import com.itsaky.androidide.plugins.AndroidIDEAssetsPlugin
plugins {
id("com.android.application")
@@ -9,6 +10,7 @@ plugins {
id("kotlin-kapt")
id("kotlin-parcelize")
id("androidx.navigation.safeargs.kotlin")
id("com.itsaky.androidide.desugaring")
}
apply {
@@ -41,6 +43,14 @@ android {
kapt { arguments { arg("eventBusIndex", "${BuildConfig.packageName}.events.AppEventsIndex") } }
desugaring {
replacements {
includePackage("org.eclipse.jgit")
applyJavaIOReplacements()
}
}
dependencies {
debugImplementation(libs.common.leakcanary)
@@ -91,6 +101,7 @@ dependencies {
// Dependencies in composite build
implementation(libs.composite.appintro)
implementation(libs.composite.desugaringCore)
implementation(libs.composite.javapoet)
// Local projects here
+3 -2
View File
@@ -31,6 +31,7 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.maven.publish) apply false
alias(libs.plugins.gradle.publish) apply false
}
@@ -54,10 +55,10 @@ subprojects {
project.version = rootProject.version
plugins.withId("com.android.application") {
configureAndroidModule(libs.androidx.lib.desugaring.get())
configureAndroidModule(libs.androidx.libDesugaring)
}
plugins.withId("com.android.library") {
configureAndroidModule(libs.androidx.lib.desugaring.get())
configureAndroidModule(libs.androidx.libDesugaring)
}
plugins.withId("java-library") { configureJavaModule() }
plugins.withId("com.vanniktech.maven.publish.base") { configureMavenPublish() }
+5
View File
@@ -0,0 +1,5 @@
# Composite builds
- `build-deps` - External dependencies that are built from source and used in the main build.
- `build-deps-common` - Common modules that are used in composite builds as well as the main build.
- `build-logic` - Plugins and configuration for building the AndroidIDE project.
@@ -0,0 +1,25 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
plugins {
id("java-library")
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
@@ -0,0 +1,128 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.desugaring.core.java.io;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
* @author Akash Yadav
*/
@SuppressWarnings("unused")
public class DesugarInputStream {
/**
* The maximum size of array to allocate. Some VMs reserve some header words in an array. Attempts
* to allocate larger arrays may result in OutOfMemoryError: Requested array size exceeds VM
* limit
*/
private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8;
// MAX_SKIP_BUFFER_SIZE is used to determine the maximum buffer size to
// use when skipping.
private static final int MAX_SKIP_BUFFER_SIZE = 2048;
private static final int DEFAULT_BUFFER_SIZE = 16384;
private DesugarInputStream() {
throw new UnsupportedOperationException();
}
public static byte[] readAllBytes(InputStream in) throws IOException {
return readNBytes(in, Integer.MAX_VALUE);
}
public static byte[] readNBytes(InputStream in, int len) throws IOException {
if (len < 0) {
throw new IllegalArgumentException("len < 0");
}
List<byte[]> bufs = null;
byte[] result = null;
int total = 0;
int remaining = len;
int n;
do {
byte[] buf = new byte[Math.min(remaining, DEFAULT_BUFFER_SIZE)];
int nread = 0;
// read to EOF which may read more or less than buffer size
while ((n = in.read(buf, nread, Math.min(buf.length - nread, remaining))) > 0) {
nread += n;
remaining -= n;
}
if (nread > 0) {
if (MAX_BUFFER_SIZE - total < nread) {
throw new OutOfMemoryError("Required array size too large");
}
if (nread < buf.length) {
buf = Arrays.copyOfRange(buf, 0, nread);
}
total += nread;
if (result == null) {
result = buf;
} else {
if (bufs == null) {
bufs = new ArrayList<>();
bufs.add(result);
}
bufs.add(buf);
}
}
// if the last call to read returned -1 or the number of bytes
// requested have been read then break
} while (n >= 0 && remaining > 0);
if (bufs == null) {
if (result == null) {
return new byte[0];
}
return result.length == total ? result : Arrays.copyOf(result, total);
}
result = new byte[total];
int offset = 0;
remaining = total;
for (byte[] b : bufs) {
int count = Math.min(b.length, remaining);
System.arraycopy(b, 0, result, offset, count);
offset += count;
remaining -= count;
}
return result;
}
public static int readNBytes(InputStream input, byte[] b, int off, int len) throws IOException {
Objects.checkFromIndexSize(off, len, b.length);
int n = 0;
while (n < len) {
int count = input.read(b, off + n, len - n);
if (count < 0)
break;
n += count;
}
return n;
}
}
@@ -0,0 +1,54 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
@file:Suppress("UnstableApiUsage")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../../gradle/libs.versions.toml"))
}
}
}
include(
":desugaring-core",
)
rootProject.name = "build-deps-common"
gradle.rootProject {
// required for setting SDK location for android modules
project.file("../../local.properties")
.takeIf { it.exists() }
?.copyTo(project.file("local.properties"), overwrite = true)
}

Some files were not shown because too many files have changed in this diff Show More