Giter Club home page Giter Club logo

Comments (5)

hi-dhl avatar hi-dhl commented on July 28, 2024

import 不能去掉的,颜色置灰 和 无法跳转等问题,是本地应该没有正常编译通过,编译通过之后就都正常了

from composingbuilds-vs-buildsrc.

tudoutiao avatar tudoutiao commented on July 28, 2024

编译过程没有出现异常提示 build success

plugin-version ------ build.gradle

plugins {
    id('java-gradle-plugin')
    id('org.jetbrains.kotlin.jvm') version '1.6.10'
}

repositories {
    google()
    mavenCentral()
    gradlePluginPortal()
}


dependencies {
    //添加Gradle相关的API,否则无法自定义Plugin和Task
    implementation(gradleApi())
    implementation('org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10')
}

gradlePlugin {
    plugins {
        version {
            //添加插件
            id ='com.hi.dhl.plugin'
            //在根目录创建类 VersionPlugin 继承 Plugin<Project>
            implementationClass = 'com.hi.dhl.plugin.VersionPlugin'
        }
    }
}

根路径下build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.2.0' apply false
    id 'com.android.library' version '7.2.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
    id 'com.hi.dhl.plugin' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app modle--build.gradle

// 1. 导入plugin-version 依赖类
import com.hi.dhl.plugin.*

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.hi.dhl.plugin'
}

android {
    compileSdk BuildConfig.compileSdkVersion

    defaultConfig {
        applicationId BuildConfig.applicationId
        minSdk BuildConfig.minSdkVersion
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

setting.gradle

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "Test2"
include ':app'
includeBuild('plugin-version')

image

image

点击plugin可以跳转,但引用的位置点击not foud

from composingbuilds-vs-buildsrc.

tudoutiao avatar tudoutiao commented on July 28, 2024

我导入运行你的项目,可以正常跳转引用,但如果把

gradle 升级到7.3.3(distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-all.zip),
kotlin 升级到1.6.10(ext.kotlin_version = "1.6.10")

后,虽然编译运行正常,也不能正常的跳转引用了。

image

from composingbuilds-vs-buildsrc.

asyncTop avatar asyncTop commented on July 28, 2024

需要跳转引用,代码提示:将build.gradle 升级成 build.gradle.kts
image
image
@tudoutiao
环境:
gradle 7.2.1. kotlin 1.6.10

from composingbuilds-vs-buildsrc.

hi-dhl avatar hi-dhl commented on July 28, 2024

我导入运行你的项目,可以正常跳转引用,但如果把

gradle 升级到7.3.3(distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-all.zip), kotlin 升级到1.6.10(ext.kotlin_version = "1.6.10")

后,虽然编译运行正常,也不能正常的跳转引用了。

image

https://github.com/hi-dhl/Binding 这个库,我将 AGP 升级到 7x , kotlin 升级到了 1.6.10 ,可以参考一下

from composingbuilds-vs-buildsrc.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.