├── .gitignore ├── README.md ├── android-lib ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── codelang │ │ └── android_lib │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── asset.json │ │ └── test │ │ │ └── test.json │ ├── java │ │ └── com │ │ │ └── codelang │ │ │ └── android_lib │ │ │ ├── AndroidLibActivity.kt │ │ │ └── ui │ │ │ ├── gallery │ │ │ ├── GalleryFragment.kt │ │ │ └── GalleryViewModel.kt │ │ │ ├── home │ │ │ ├── HomeFragment.kt │ │ │ └── HomeViewModel.kt │ │ │ └── slideshow │ │ │ ├── SlideshowFragment.kt │ │ │ └── SlideshowViewModel.kt │ └── res │ │ ├── drawable-xxhdpi │ │ └── ic_menu_camera.webp │ │ ├── drawable │ │ ├── ic_menu_camera.xml │ │ ├── ic_menu_gallery.xml │ │ ├── ic_menu_slideshow.xml │ │ └── side_nav_bar.xml │ │ ├── layout │ │ ├── activity_android_lib.xml │ │ ├── app_bar_android_lib.xml │ │ ├── content_android_lib.xml │ │ ├── fragment_gallery.xml │ │ ├── fragment_home.xml │ │ ├── fragment_slideshow.xml │ │ └── nav_header_android_lib.xml │ │ ├── menu │ │ ├── activity_main_drawer.xml │ │ └── android_lib.xml │ │ ├── navigation │ │ └── mobile_navigation.xml │ │ ├── values-land │ │ └── dimens.xml │ │ ├── values-w1240dp │ │ └── dimens.xml │ │ ├── values-w600dp │ │ └── dimens.xml │ │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── codelang │ └── android_lib │ └── ExampleUnitTest.kt ├── android-lib2 ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── codelang │ │ └── android_lib2 │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── asset.json │ │ └── test │ │ │ └── test.json │ ├── java │ │ ├── android │ │ │ └── app │ │ │ │ └── ActivityThread.java │ │ └── com │ │ │ └── codelang │ │ │ └── android_lib2 │ │ │ ├── AndroidLib2Activity.kt │ │ │ └── TestCase.kt │ └── res │ │ ├── drawable │ │ └── ic_menu_camera.xml │ │ ├── layout │ │ └── activity_android_lib.xml │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── codelang │ └── android_lib2 │ └── ExampleUnitTest.kt ├── app ├── .gitignore ├── ManifestWhite.xml ├── android13.json ├── build.gradle ├── libs │ └── FFmpegAndroid-0.3.2.aar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── codelang │ │ └── includebuildingdemo │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── codelang │ │ │ └── includebuildingdemo │ │ │ ├── MainActivity.kt │ │ │ ├── MyApplication.kt │ │ │ └── hook │ │ │ ├── ClassLoaderUtils.java │ │ │ ├── ProxyClassLoader.java │ │ │ └── ReflectUtils.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_android_lib.xml │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── values-night │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── codelang │ └── includebuildingdemo │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── index.html ├── java-lib ├── .gitignore ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── codelang │ └── java_lib │ └── MyClass.kt ├── plugin ├── .gitignore ├── build.gradle ├── checkPlugin │ ├── .gitignore │ ├── README.md │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── codelang │ │ └── plugin │ │ ├── CheckPlugin.kt │ │ ├── check │ │ ├── base │ │ │ └── BaseFileCheck.kt │ │ ├── manifest │ │ │ ├── ExportedManifest.kt │ │ │ ├── PermissionManifest.kt │ │ │ ├── UsesSDKManifest.kt │ │ │ ├── base │ │ │ │ ├── IManifest.kt │ │ │ │ └── ManifestCheck.kt │ │ │ └── bean │ │ │ │ ├── ExportedFile.kt │ │ │ │ └── ManifestConfig.kt │ │ └── so │ │ │ ├── SoFileSize.kt │ │ │ ├── Support64bit.kt │ │ │ ├── base │ │ │ ├── ISoFile.kt │ │ │ └── SoFileCheck.kt │ │ │ └── bean │ │ │ └── SoFile.kt │ │ ├── config │ │ └── Config.kt │ │ ├── ext │ │ └── NumberExt.kt │ │ ├── extension │ │ └── CheckExtension.kt │ │ ├── html │ │ └── IndexHtml.kt │ │ └── task │ │ └── CheckFileTask.kt ├── classAnalysis │ ├── .gitignore │ ├── README.md │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ ├── classfile │ │ ├── AccessFlags.java │ │ ├── Annotation.java │ │ ├── AnnotationDefault_attribute.java │ │ ├── Attribute.java │ │ ├── AttributeException.java │ │ ├── Attributes.java │ │ ├── BootstrapMethods_attribute.java │ │ ├── CharacterRangeTable_attribute.java │ │ ├── ClassFile.java │ │ ├── ClassReader.java │ │ ├── ClassTranslator.java │ │ ├── ClassWriter.java │ │ ├── Code_attribute.java │ │ ├── CompilationID_attribute.java │ │ ├── ConstantPool.java │ │ ├── ConstantPoolException.java │ │ ├── ConstantValue_attribute.java │ │ ├── DefaultAttribute.java │ │ ├── Dependencies.java │ │ ├── Dependency.java │ │ ├── Deprecated_attribute.java │ │ ├── Descriptor.java │ │ ├── DescriptorException.java │ │ ├── EnclosingMethod_attribute.java │ │ ├── Exceptions_attribute.java │ │ ├── Field.java │ │ ├── InnerClasses_attribute.java │ │ ├── Instruction.java │ │ ├── LineNumberTable_attribute.java │ │ ├── LocalVariableTable_attribute.java │ │ ├── LocalVariableTypeTable_attribute.java │ │ ├── Method.java │ │ ├── MethodParameters_attribute.java │ │ ├── ModuleHashes_attribute.java │ │ ├── ModuleMainClass_attribute.java │ │ ├── ModulePackages_attribute.java │ │ ├── ModuleResolution_attribute.java │ │ ├── ModuleTarget_attribute.java │ │ ├── Module_attribute.java │ │ ├── NestHost_attribute.java │ │ ├── NestMembers_attribute.java │ │ ├── Opcode.java │ │ ├── Record_attribute.java │ │ ├── ReferenceFinder.java │ │ ├── RuntimeAnnotations_attribute.java │ │ ├── RuntimeInvisibleAnnotations_attribute.java │ │ ├── RuntimeInvisibleParameterAnnotations_attribute.java │ │ ├── RuntimeInvisibleTypeAnnotations_attribute.java │ │ ├── RuntimeParameterAnnotations_attribute.java │ │ ├── RuntimeTypeAnnotations_attribute.java │ │ ├── RuntimeVisibleAnnotations_attribute.java │ │ ├── RuntimeVisibleParameterAnnotations_attribute.java │ │ ├── RuntimeVisibleTypeAnnotations_attribute.java │ │ ├── Signature.java │ │ ├── Signature2Readable.java │ │ ├── Signature_attribute.java │ │ ├── SourceDebugExtension_attribute.java │ │ ├── SourceFile_attribute.java │ │ ├── SourceID_attribute.java │ │ ├── StackMapTable_attribute.java │ │ ├── StackMap_attribute.java │ │ ├── Synthetic_attribute.java │ │ ├── Type.java │ │ ├── TypeAnnotation.java │ │ └── package-info.java │ │ └── com │ │ └── codelang │ │ └── parse │ │ ├── ClassAnalysis.kt │ │ ├── bean │ │ ├── ConfigBean.java │ │ └── ResponseBean.java │ │ └── extension │ │ └── ConfigFileExtension.kt ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── modulePlugin │ ├── .gitignore │ ├── README.md │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── codelang │ │ └── plugin │ │ ├── ModulePlugin.kt │ │ └── utils │ │ └── Utils.kt ├── permissionPlugin │ ├── .gitignore │ ├── PermissionPlugin.gradle │ ├── README.md │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── codelang │ │ └── plugin │ │ ├── PermissionPlugin.kt │ │ └── Utils.kt ├── resourcePlugin │ ├── .gitignore │ ├── README.md │ ├── build.gradle │ ├── resourcePlugin.gradle │ ├── result.png │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── codelang │ │ └── plugin │ │ └── ResourcePlugin.kt ├── settings.gradle └── uploadPlugin │ ├── .gitignore │ ├── README.md │ ├── build.gradle │ └── src │ └── main │ └── java │ └── com │ └── codelang │ └── upload │ ├── BaseUploadPlugin.kt │ ├── UploadGithub.kt │ ├── UploadMaven.kt │ ├── config │ └── UploadConfig.kt │ ├── task │ └── SourceJarTask.kt │ └── utils │ ├── FileUtils.kt │ └── Util.kt └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | .idea 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | - [checkPlugin 的使用](./plugin/checkPlugin) 3 | - [uploadPlugin 的使用](./plugin/uploadPlugin) 4 | - [modulePlugin 的使用](./plugin/modulePlugin) 5 | - [resourcePlugin 的使用](./plugin/resourcePlugin) 6 | - [permissionPlugin 的使用](./plugin/permissionPlugin) 7 | - [classAnalysisPlugin 的使用](./plugin/classAnalysis) -------------------------------------------------------------------------------- /android-lib/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /android-lib/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'kotlin-android' 4 | id 'uploadGithub' 5 | } 6 | 7 | upload { 8 | groupId = "com.codelang.library" 9 | artifactId = "android-lib" 10 | version = "1.0.0" 11 | } 12 | 13 | android { 14 | compileSdk 31 15 | 16 | defaultConfig { 17 | minSdk 21 18 | targetSdk 31 19 | versionCode 1 20 | versionName "1.0" 21 | 22 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 23 | consumerProguardFiles "consumer-rules.pro" 24 | } 25 | 26 | buildTypes { 27 | release { 28 | minifyEnabled false 29 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 30 | } 31 | } 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | kotlinOptions { 37 | jvmTarget = '1.8' 38 | } 39 | buildFeatures { 40 | viewBinding true 41 | } 42 | } 43 | 44 | dependencies { 45 | 46 | implementation 'androidx.core:core-ktx:1.7.0' 47 | implementation 'androidx.appcompat:appcompat:1.4.1' 48 | implementation 'com.google.android.material:material:1.5.0' 49 | implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 50 | implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1' 51 | implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' 52 | implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' 53 | implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' 54 | testImplementation 'junit:junit:4.+' 55 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 56 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 57 | 58 | // implementation project(":java-lib") 59 | } -------------------------------------------------------------------------------- /android-lib/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MRwangqi/pluginDemo/aa7a2d0c8bcbcc8fcd8438ca273a468b7a4d4725/android-lib/consumer-rules.pro -------------------------------------------------------------------------------- /android-lib/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /android-lib/src/androidTest/java/com/codelang/android_lib/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.android_lib 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.codelang.android_lib.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /android-lib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /android-lib/src/main/assets/asset.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lib" 3 | } -------------------------------------------------------------------------------- /android-lib/src/main/assets/test/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lib" 3 | } -------------------------------------------------------------------------------- /android-lib/src/main/java/com/codelang/android_lib/AndroidLibActivity.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.android_lib 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | 6 | class AndroidLibActivity : AppCompatActivity() { 7 | 8 | // private lateinit var appBarConfiguration: AppBarConfiguration 9 | // private lateinit var binding: ActivityAndroidLibBinding 10 | 11 | override fun onCreate(savedInstanceState: Bundle?) { 12 | super.onCreate(savedInstanceState) 13 | 14 | 15 | // binding = ActivityAndroidLibBinding.inflate(layoutInflater) 16 | setContentView(R.layout.activity_android_lib) 17 | // 18 | // setSupportActionBar(binding.appBarAndroidLib.toolbar) 19 | // 20 | // binding.appBarAndroidLib.fab.setOnClickListener { view -> 21 | // Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 22 | // .setAction("Action", null).show() 23 | // } 24 | // val drawerLayout: DrawerLayout = binding.drawerLayout 25 | // val navView: NavigationView = binding.navView 26 | // val navController = findNavController(R.id.nav_host_fragment_content_android_lib) 27 | // // Passing each menu ID as a set of Ids because each 28 | // // menu should be considered as top level destinations. 29 | // appBarConfiguration = AppBarConfiguration(setOf( 30 | // R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow), drawerLayout) 31 | // setupActionBarWithNavController(navController, appBarConfiguration) 32 | // navView.setupWithNavController(navController) 33 | } 34 | // 35 | // override fun onCreateOptionsMenu(menu: Menu): Boolean { 36 | // // Inflate the menu; this adds items to the action bar if it is present. 37 | // menuInflater.inflate(R.menu.android_lib, menu) 38 | // return true 39 | // } 40 | // 41 | // override fun onSupportNavigateUp(): Boolean { 42 | // val navController = findNavController(R.id.nav_host_fragment_content_android_lib) 43 | // return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp() 44 | // } 45 | } -------------------------------------------------------------------------------- /android-lib/src/main/java/com/codelang/android_lib/ui/gallery/GalleryFragment.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.android_lib.ui.gallery 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.TextView 8 | import androidx.fragment.app.Fragment 9 | import androidx.lifecycle.Observer 10 | import androidx.lifecycle.ViewModelProvider 11 | import com.codelang.android_lib.R 12 | import com.codelang.android_lib.databinding.FragmentGalleryBinding 13 | 14 | class GalleryFragment : Fragment() { 15 | 16 | private lateinit var galleryViewModel: GalleryViewModel 17 | private var _binding: FragmentGalleryBinding? = null 18 | 19 | // This property is only valid between onCreateView and 20 | // onDestroyView. 21 | private val binding get() = _binding!! 22 | 23 | override fun onCreateView( 24 | inflater: LayoutInflater, 25 | container: ViewGroup?, 26 | savedInstanceState: Bundle? 27 | ): View? { 28 | galleryViewModel = 29 | ViewModelProvider(this).get(GalleryViewModel::class.java) 30 | 31 | _binding = FragmentGalleryBinding.inflate(inflater, container, false) 32 | val root: View = binding.root 33 | 34 | val textView: TextView = binding.textGallery 35 | galleryViewModel.text.observe(viewLifecycleOwner, Observer { 36 | textView.text = it 37 | }) 38 | return root 39 | } 40 | 41 | override fun onDestroyView() { 42 | super.onDestroyView() 43 | _binding = null 44 | } 45 | } -------------------------------------------------------------------------------- /android-lib/src/main/java/com/codelang/android_lib/ui/gallery/GalleryViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.android_lib.ui.gallery 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | 7 | class GalleryViewModel : ViewModel() { 8 | 9 | private val _text = MutableLiveData().apply { 10 | value = "This is gallery Fragment" 11 | } 12 | val text: LiveData = _text 13 | } -------------------------------------------------------------------------------- /android-lib/src/main/java/com/codelang/android_lib/ui/home/HomeFragment.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.android_lib.ui.home 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.TextView 8 | import androidx.fragment.app.Fragment 9 | import androidx.lifecycle.Observer 10 | import androidx.lifecycle.ViewModelProvider 11 | import com.codelang.android_lib.R 12 | import com.codelang.android_lib.databinding.FragmentHomeBinding 13 | 14 | class HomeFragment : Fragment() { 15 | 16 | private lateinit var homeViewModel: HomeViewModel 17 | private var _binding: FragmentHomeBinding? = null 18 | 19 | // This property is only valid between onCreateView and 20 | // onDestroyView. 21 | private val binding get() = _binding!! 22 | 23 | override fun onCreateView( 24 | inflater: LayoutInflater, 25 | container: ViewGroup?, 26 | savedInstanceState: Bundle? 27 | ): View? { 28 | homeViewModel = 29 | ViewModelProvider(this).get(HomeViewModel::class.java) 30 | 31 | _binding = FragmentHomeBinding.inflate(inflater, container, false) 32 | val root: View = binding.root 33 | 34 | val textView: TextView = binding.textHome 35 | homeViewModel.text.observe(viewLifecycleOwner, Observer { 36 | textView.text = it 37 | }) 38 | return root 39 | } 40 | 41 | override fun onDestroyView() { 42 | super.onDestroyView() 43 | _binding = null 44 | } 45 | } -------------------------------------------------------------------------------- /android-lib/src/main/java/com/codelang/android_lib/ui/home/HomeViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.android_lib.ui.home 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | 7 | class HomeViewModel : ViewModel() { 8 | 9 | private val _text = MutableLiveData().apply { 10 | value = "This is home Fragment" 11 | } 12 | val text: LiveData = _text 13 | } -------------------------------------------------------------------------------- /android-lib/src/main/java/com/codelang/android_lib/ui/slideshow/SlideshowFragment.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.android_lib.ui.slideshow 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.TextView 8 | import androidx.fragment.app.Fragment 9 | import androidx.lifecycle.Observer 10 | import androidx.lifecycle.ViewModelProvider 11 | import com.codelang.android_lib.R 12 | import com.codelang.android_lib.databinding.FragmentSlideshowBinding 13 | 14 | class SlideshowFragment : Fragment() { 15 | 16 | private lateinit var slideshowViewModel: SlideshowViewModel 17 | private var _binding: FragmentSlideshowBinding? = null 18 | 19 | // This property is only valid between onCreateView and 20 | // onDestroyView. 21 | private val binding get() = _binding!! 22 | 23 | override fun onCreateView( 24 | inflater: LayoutInflater, 25 | container: ViewGroup?, 26 | savedInstanceState: Bundle? 27 | ): View? { 28 | slideshowViewModel = 29 | ViewModelProvider(this).get(SlideshowViewModel::class.java) 30 | 31 | _binding = FragmentSlideshowBinding.inflate(inflater, container, false) 32 | val root: View = binding.root 33 | 34 | val textView: TextView = binding.textSlideshow 35 | slideshowViewModel.text.observe(viewLifecycleOwner, Observer { 36 | textView.text = it 37 | }) 38 | return root 39 | } 40 | 41 | override fun onDestroyView() { 42 | super.onDestroyView() 43 | _binding = null 44 | } 45 | } -------------------------------------------------------------------------------- /android-lib/src/main/java/com/codelang/android_lib/ui/slideshow/SlideshowViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.android_lib.ui.slideshow 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | 7 | class SlideshowViewModel : ViewModel() { 8 | 9 | private val _text = MutableLiveData().apply { 10 | value = "This is slideshow Fragment" 11 | } 12 | val text: LiveData = _text 13 | } -------------------------------------------------------------------------------- /android-lib/src/main/res/drawable-xxhdpi/ic_menu_camera.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MRwangqi/pluginDemo/aa7a2d0c8bcbcc8fcd8438ca273a468b7a4d4725/android-lib/src/main/res/drawable-xxhdpi/ic_menu_camera.webp -------------------------------------------------------------------------------- /android-lib/src/main/res/drawable/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /android-lib/src/main/res/drawable/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android-lib/src/main/res/drawable/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android-lib/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /android-lib/src/main/res/layout/activity_android_lib.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | -------------------------------------------------------------------------------- /android-lib/src/main/res/layout/app_bar_android_lib.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 33 | 34 | -------------------------------------------------------------------------------- /android-lib/src/main/res/layout/content_android_lib.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 20 | -------------------------------------------------------------------------------- /android-lib/src/main/res/layout/fragment_gallery.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /android-lib/src/main/res/layout/fragment_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /android-lib/src/main/res/layout/fragment_slideshow.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /android-lib/src/main/res/layout/nav_header_android_lib.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 21 | 22 | 27 | -------------------------------------------------------------------------------- /android-lib/src/main/res/menu/activity_main_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 11 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /android-lib/src/main/res/menu/android_lib.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | -------------------------------------------------------------------------------- /android-lib/src/main/res/navigation/mobile_navigation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 19 | 20 | 25 | -------------------------------------------------------------------------------- /android-lib/src/main/res/values-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 48dp 3 | -------------------------------------------------------------------------------- /android-lib/src/main/res/values-w1240dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 200dp 3 | -------------------------------------------------------------------------------- /android-lib/src/main/res/values-w600dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 48dp 3 | -------------------------------------------------------------------------------- /android-lib/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 8dp 6 | 176dp 7 | 16dp 8 | -------------------------------------------------------------------------------- /android-lib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AndroidLibActivity 4 | Open navigation drawer 5 | Close navigation drawer 6 | Android Studio 7 | android.studio@android.com 8 | Navigation header 9 | Settings 10 | 11 | Home 12 | Gallery 13 | Slideshow 14 | -------------------------------------------------------------------------------- /android-lib/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | includebuildingDemo 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/test/java/com/codelang/includebuildingdemo/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.includebuildingdemo 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | import java.util.regex.Pattern 7 | 8 | /** 9 | * Example local unit test, which will execute on the development machine (host). 10 | * 11 | * See [testing documentation](http://d.android.com/tools/testing). 12 | */ 13 | class ExampleUnitTest { 14 | @Test 15 | fun addition_isCorrect() { 16 | assertEquals(4, 2 + 2) 17 | 18 | val githubURL = "git@github.com:MRwangqi/Maven.git" 19 | val lastIndex = githubURL.lastIndexOf("/") 20 | val lastIndex2 = githubURL.lastIndexOf(".git") 21 | 22 | println(githubURL.substring(lastIndex + 1, lastIndex2)) 23 | } 24 | 25 | 26 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.5.30' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | mavenLocal() 7 | maven { 8 | allowInsecureProtocol = true 9 | url "http://localhost:8081/repository/android/" 10 | } 11 | maven{ 12 | url "https://raw.githubusercontent.com/MRwangqi/Maven/main" 13 | } 14 | } 15 | dependencies { 16 | classpath "com.android.tools.build:gradle:7.0.4" 17 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 18 | // NOTE: Do not place your application dependencies here; they belong 19 | // in the individual module build.gradle files 20 | // classpath "com.github.MRwangqi:classAnalysis:1.0.0" 21 | } 22 | } 23 | 24 | plugins { 25 | id "checkPlugin" apply false 26 | id "uploadMaven" apply false 27 | id "uploadGithub" apply false 28 | id "modulePlugin" apply false 29 | id "resourcePlugin" apply false 30 | id "permissionPlugin" apply false 31 | id "classAnalysisPlugin" apply false 32 | id 'org.jetbrains.kotlin.jvm' version '1.6.21' apply false 33 | } 34 | 35 | task clean(type: Delete) { 36 | delete rootProject.buildDir 37 | } 38 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=obsolete 22 | android.nonTransitiveRClass=true 23 | 24 | # GAV 转本地 module 开关 25 | gav2project.enable=true 26 | # 如果指定跳过模块,则不会参与 GAV 到 Project 的转换(仅在 gav2project.enable=true 时生效) 27 | #gav2project.skips=android-lib -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MRwangqi/pluginDemo/aa7a2d0c8bcbcc8fcd8438ca273a468b7a4d4725/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Feb 09 10:38:36 CST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /java-lib/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /java-lib/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'kotlin' 4 | id 'uploadGithub' 5 | } 6 | 7 | java { 8 | sourceCompatibility = JavaVersion.VERSION_11 9 | targetCompatibility = JavaVersion.VERSION_11 10 | } 11 | 12 | upload { 13 | groupId = "com.aa.bb" 14 | artifactId = "java_lib" 15 | version = "1.0.0" 16 | } 17 | -------------------------------------------------------------------------------- /java-lib/src/main/java/com/codelang/java_lib/MyClass.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.java_lib 2 | 3 | class MyClass { 4 | } -------------------------------------------------------------------------------- /plugin/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /plugin/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = '1.5.30' 4 | repositories { 5 | google() 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath "com.android.tools.build:gradle:7.0.4" 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | task clean(type: Delete) { 18 | delete rootProject.buildDir 19 | } -------------------------------------------------------------------------------- /plugin/checkPlugin/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /plugin/checkPlugin/README.md: -------------------------------------------------------------------------------- 1 | ### 一、依赖配置 2 | 3 | 目前提供的检查有: 4 | - so 文件检查 5 | - 64 位 so 未适配检查 6 | - 更安全的导出组件检查 7 | - 未匹配的权限检查 8 | - uses-sdk 检查 9 | 10 | 待补充的功能: 11 | - 大图检测 12 | - 重复资源检测 13 | - 清单文件中不存在的类检查 14 | - 布局文件中不存在的类检查 15 | - 类/方法找不到检查 16 | 17 | 配置 maven 镜像源和依赖 18 | ```java 19 | buildscript { 20 | repositories { 21 | ... 22 | // maven 源 23 | maven{ 24 | url "https://raw.githubusercontent.com/MRwangqi/Maven/main" 25 | } 26 | } 27 | dependencies { 28 | classpath "com.android.tools.build:gradle:7.0.4" 29 | // 依赖 check 插件 30 | classpath "com.github.MRwangqi:checkPlugin:1.0.1" 31 | } 32 | } 33 | ``` 34 | 35 | 然后在 app 工程的 build.gradle 中依赖插件,并且在工程下面配置白名单文件: 36 | 37 | ```java 38 | plugins { 39 | id 'com.android.application' 40 | // apply check 插件 41 | id 'checkPlugin' 42 | } 43 | 44 | check{ 45 | // 配置白名单 46 | manifestWhiteFile="ManifestWhite.xml" 47 | } 48 | ``` 49 | 50 | ManifestWhite.xml 文件如下: 51 | 52 | ```java 53 | 54 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | ``` 66 | 67 | 68 | ### 二、执行检查命令: 69 | 70 | 执行命令模板如下: 71 | > ./gradlew checkDependency -Pbuild=${build variant} 72 | 73 | 要执行的 build variant 可以在 Android studio 中查看: 74 | ![image.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5a6f62c79ade4ae7864c572e852ee9b8~tplv-k3u1fbpfcp-zoom-1.image) 75 | 比如我们要检查 debug 的依赖分析,则命令如下: 76 | > ./gradlew checkDependency -Pbuild=debug 77 | 78 | 当然,也可以直接使用如下命令进行检查,插件默认的 build variant 是 debug 79 | > ./gradlew checkDependency 80 | 81 | 82 | 结果会在 build 目录的 checkPlugin 生成一份 check.html 文件,你可以直接查看 demo 生成的结果报告:[https://mrwangqi.github.io/pluginDemo/](https://mrwangqi.github.io/pluginDemo/) 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /plugin/checkPlugin/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'groovy' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'java-gradle-plugin' 4 | apply plugin: 'maven-publish' 5 | 6 | dependencies { 7 | implementation gradleApi() 8 | implementation localGroovy() 9 | api "com.android.tools.build:gradle-api:$apgVersion" 10 | api "com.android.tools.build:gradle:$apgVersion" 11 | implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 12 | } 13 | 14 | gradlePlugin { 15 | plugins { 16 | version { 17 | id = 'checkPlugin' 18 | implementationClass = 'com.codelang.plugin.CheckPlugin' 19 | } 20 | } 21 | } 22 | 23 | 24 | afterEvaluate { 25 | publishing { 26 | publications { 27 | maven(MavenPublication) { 28 | from components.java 29 | groupId = "com.github.MRwangqi" 30 | artifactId = "checkPlugin" 31 | version = "1.0.1" 32 | } 33 | } 34 | 35 | repositories { 36 | maven { 37 | url = uri(mavenLocal().url) 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/CheckPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin 2 | 3 | import com.codelang.plugin.check.so.base.SoFileCheck 4 | import com.codelang.plugin.check.base.BaseFileCheck 5 | import com.codelang.plugin.check.manifest.base.ManifestCheck 6 | import com.codelang.plugin.config.Config 7 | import com.codelang.plugin.extension.CheckExtension 8 | import com.codelang.plugin.task.CheckFileTask 9 | import org.gradle.api.Plugin 10 | import org.gradle.api.Project 11 | import org.jetbrains.kotlin.konan.file.File 12 | import java.util.* 13 | 14 | class CheckPlugin : Plugin { 15 | companion object { 16 | const val EXT_NAME = "check" 17 | const val BUILD = "build" 18 | } 19 | 20 | override fun apply(project: Project) { 21 | // ./gradlew checkDependency -Pbuild=fullDebug 22 | val params = project.gradle.startParameter.projectProperties 23 | 24 | if (params.containsKey(BUILD)) { 25 | Config.build = params[BUILD] ?: "debug" 26 | } else { 27 | // 默认 debug 兜底 28 | Config.build = "debug" 29 | } 30 | 31 | project.extensions.create(EXT_NAME, CheckExtension::class.java) 32 | 33 | project.afterEvaluate { 34 | val extension = project.extensions.findByName(EXT_NAME) as CheckExtension 35 | 36 | extension.apply { 37 | Config.manifestWhiteFile = project.projectDir.absolutePath + File.Companion.separator + manifestWhiteFile 38 | } 39 | 40 | val checkList = arrayListOf().apply { 41 | add(SoFileCheck()) 42 | add(ManifestCheck()) 43 | } 44 | 45 | val configurationName = Config.build + "CompileClasspath" 46 | val taskName = "checkDependency" 47 | 48 | CheckFileTask(project).runTask(taskName, configurationName, checkList) 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/check/base/BaseFileCheck.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.check.base 2 | 3 | import java.util.zip.ZipInputStream 4 | 5 | /** 6 | * @author wangqi 7 | * @since 2022/2/23. 8 | */ 9 | interface BaseFileCheck { 10 | fun onStart() 11 | 12 | fun onIteratorFile(path:String,dependency:String,fileName: String, fileSize: Long, zipInputStream: ZipInputStream) 13 | 14 | fun onEnd() 15 | } -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/check/manifest/base/IManifest.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.check.manifest.base 2 | 3 | import groovy.util.Node 4 | import java.util.zip.ZipInputStream 5 | 6 | /** 7 | * @author wangqi 8 | * @since 2022/2/27. 9 | */ 10 | interface IManifest { 11 | fun onNode(parentNode: Node,path:String,dependency: String, fileName: String, fileSize: Long, zipInputStream: ZipInputStream) 12 | fun onEnd() 13 | } -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/check/manifest/bean/ExportedFile.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.check.manifest.bean 2 | 3 | /** 4 | * @author wangqi 5 | * @since 2022/2/27. 6 | */ 7 | data class ExportedFile(val path:String,val nodeName: String, val className: String) -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/check/manifest/bean/ManifestConfig.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.check.manifest.bean 2 | 3 | object ManifestConfig { 4 | var usesSdk: UsesSdk = UsesSdk(-1,-1) 5 | var permissions = arrayListOf() 6 | } 7 | 8 | data class UsesSdk(val minSdkVersion: Int, val targetSdkVersion: Int) -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/check/so/base/ISoFile.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.check.so.base 2 | 3 | import java.util.zip.ZipInputStream 4 | 5 | /** 6 | * @author wangqi 7 | * @since 2022/2/27. 8 | */ 9 | interface ISoFile { 10 | fun onIteratorFile(path:String,dependency:String,fileName: String, fileSize: Long, zipInputStream: ZipInputStream) 11 | 12 | fun onEnd() 13 | } -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/check/so/base/SoFileCheck.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.check.so.base 2 | 3 | import com.codelang.plugin.check.base.BaseFileCheck 4 | import com.codelang.plugin.check.so.SoFileSize 5 | import com.codelang.plugin.check.so.Support64bit 6 | import java.util.zip.ZipInputStream 7 | 8 | /** 9 | * @author wangqi 10 | * @since 2022/2/23. 11 | */ 12 | class SoFileCheck : BaseFileCheck { 13 | 14 | private val list = arrayListOf().apply { 15 | add(SoFileSize()) 16 | add(Support64bit()) 17 | } 18 | 19 | override fun onStart() { 20 | 21 | } 22 | 23 | override fun onIteratorFile(path: String, dependency: String, fileName: String, fileSize: Long, zipInputStream: ZipInputStream) { 24 | if (!fileName.endsWith(".so")) return 25 | list.forEach { 26 | it.onIteratorFile(path, dependency, fileName, fileSize, zipInputStream) 27 | } 28 | } 29 | 30 | override fun onEnd() { 31 | list.forEach { 32 | it.onEnd() 33 | } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/check/so/bean/SoFile.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.check.so.bean 2 | 3 | /** 4 | * @author wangqi 5 | * @since 2022/2/27. 6 | */ 7 | data class SoFile(val filePath:String,val fileName: String, val fileSize: Long) -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/config/Config.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.config 2 | 3 | /** 4 | * @author wangqi 5 | * @since 2022/2/28. 6 | */ 7 | object Config { 8 | var build: String = "" 9 | var manifestWhiteFile: String = "" 10 | } -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/ext/NumberExt.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.ext 2 | 3 | import java.text.DecimalFormat 4 | import java.text.SimpleDateFormat 5 | import java.util.* 6 | 7 | /** 8 | * @author wangqi 9 | * @since 2022/2/27. 10 | */ 11 | 12 | 13 | fun Long.toFileSize(): String { 14 | val sb = StringBuffer() 15 | val format = DecimalFormat("###.0") 16 | 17 | when { 18 | this >= 1024 * 1024 * 1024 -> { 19 | val i = (this / (1024.0 * 1024.0 * 1024.0)) 20 | sb.append(format.format(i)).append("GB") 21 | } 22 | this >= 1024 * 1024 -> { 23 | val i = (this / (1024.0 * 1024.0)) 24 | sb.append(format.format(i)).append("MB") 25 | } 26 | this >= 1024 -> { 27 | val i = (this / (1024.0)) 28 | sb.append(format.format(i)).append("KB") 29 | } 30 | else -> { 31 | if (this <= 0) { 32 | sb.append("0B"); 33 | } else { 34 | sb.append(this).append("B") 35 | } 36 | } 37 | } 38 | return sb.toString() 39 | } 40 | 41 | 42 | fun Long.toTime():String{ 43 | val sdf2: SimpleDateFormat = SimpleDateFormat("yyyy 年 MM 月 dd 日 HH 时 mm 分 ss 秒") 44 | return sdf2.format(Date(this)) 45 | } 46 | 47 | -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/extension/CheckExtension.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.extension 2 | 3 | /** 4 | * @author wangqi 5 | * @since 2022/2/27. 6 | */ 7 | open class CheckExtension { 8 | var buildVariants: String = "" 9 | var manifestWhiteFile: String = "" 10 | 11 | override fun toString(): String { 12 | return "CheckExtension(buildVariants='$buildVariants', manifestWhiteFile='$manifestWhiteFile')" 13 | } 14 | 15 | 16 | } -------------------------------------------------------------------------------- /plugin/checkPlugin/src/main/java/com/codelang/plugin/task/CheckFileTask.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.task 2 | 3 | import com.codelang.plugin.check.base.BaseFileCheck 4 | import com.codelang.plugin.html.IndexHtml 5 | import org.gradle.api.Project 6 | import java.io.BufferedInputStream 7 | import java.io.File 8 | import java.io.FileInputStream 9 | import java.util.zip.ZipEntry 10 | import java.util.zip.ZipInputStream 11 | 12 | /** 13 | * @author wangqi 14 | * @since 2022/2/23. 15 | */ 16 | class CheckFileTask(private val project: Project) { 17 | 18 | fun runTask(taskName: String, configurationName: String, checkFiles: ArrayList) { 19 | project.tasks.create(taskName) { 20 | it.doLast { 21 | // 22 | project.configurations.getByName(configurationName).resolvedConfiguration.resolvedArtifacts.forEach { 23 | // 版本 24 | println(it.moduleVersion.toString()+" --> "+it.file) 25 | } 26 | 27 | 28 | val list = project.configurations.getByName(configurationName).asPath.split(File.pathSeparator) 29 | .toList() 30 | 31 | IndexHtml.cleanSection() 32 | 33 | val startTime = System.currentTimeMillis() 34 | 35 | checkFiles.forEach { 36 | it.onStart() 37 | } 38 | 39 | list.forEach { path -> 40 | val input = FileInputStream(path) 41 | val zipInputStream = ZipInputStream(BufferedInputStream(input)) 42 | var ze: ZipEntry? 43 | while (zipInputStream.nextEntry.also { ze = it } != null) { 44 | if (ze!!.isDirectory) { 45 | continue 46 | } 47 | checkFiles.forEach { fileCheck -> 48 | val lastIndex = path.lastIndexOf("/") + 1 49 | fileCheck.onIteratorFile(path.substring(0, lastIndex), path.substring(lastIndex), ze!!.name, ze!!.size, zipInputStream) 50 | } 51 | } 52 | zipInputStream.closeEntry() 53 | input.close() 54 | } 55 | 56 | checkFiles.forEach { 57 | it.onEnd() 58 | } 59 | 60 | val endTime = System.currentTimeMillis() 61 | println("耗时:" + ((endTime - startTime) / 1000f) + "s") 62 | 63 | generatorHtml() 64 | } 65 | } 66 | } 67 | 68 | private fun generatorHtml() { 69 | val buildDir = File(project.buildDir.absolutePath) 70 | if (!buildDir.exists()) { 71 | buildDir.mkdir() 72 | } 73 | 74 | // 写文件 75 | val tempDir = File(project.buildDir.absolutePath + File.separator + "checkPlugin") 76 | if (!tempDir.exists()) { 77 | tempDir.mkdir() 78 | } 79 | 80 | val htmlFile = File(tempDir, "check.html") 81 | if (htmlFile.exists()) { 82 | htmlFile.delete() 83 | } 84 | 85 | htmlFile.createNewFile() 86 | htmlFile.writeText(IndexHtml.getHtml()) 87 | 88 | println("report file:" + htmlFile.absolutePath) 89 | } 90 | 91 | } -------------------------------------------------------------------------------- /plugin/classAnalysis/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /plugin/classAnalysis/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'groovy' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'java-gradle-plugin' 4 | apply plugin: 'maven-publish' 5 | 6 | dependencies { 7 | implementation gradleApi() 8 | implementation localGroovy() 9 | api "com.android.tools.build:gradle-api:$apgVersion" 10 | api "com.android.tools.build:gradle:$apgVersion" 11 | implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 12 | implementation 'com.google.code.gson:gson:2.10' 13 | } 14 | 15 | gradlePlugin { 16 | plugins { 17 | version { 18 | id = 'classAnalysisPlugin' 19 | implementationClass = 'com.codelang.parse.ClassAnalysis' 20 | } 21 | } 22 | } 23 | version="1.0.0" 24 | 25 | afterEvaluate { 26 | publishing { 27 | publications { 28 | maven(MavenPublication) { 29 | from components.java 30 | groupId = "com.github.MRwangqi" 31 | artifactId = "classAnalysis" 32 | version = "1.0.0" 33 | } 34 | } 35 | 36 | repositories { 37 | maven { 38 | url = uri("../../build/Maven") 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/AnnotationDefault_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.15. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class AnnotationDefault_attribute extends Attribute { 39 | AnnotationDefault_attribute(ClassReader cr, int name_index, int length) 40 | throws IOException, Annotation.InvalidAnnotation { 41 | super(name_index, length); 42 | default_value = Annotation.element_value.read(cr); 43 | } 44 | 45 | public AnnotationDefault_attribute(ConstantPool constant_pool, Annotation.element_value default_value) 46 | throws ConstantPoolException { 47 | this(constant_pool.getUTF8Index(Attribute.AnnotationDefault), default_value); 48 | } 49 | 50 | public AnnotationDefault_attribute(int name_index, Annotation.element_value default_value) { 51 | super(name_index, default_value.length()); 52 | this.default_value = default_value; 53 | } 54 | 55 | public R accept(Visitor visitor, D data) { 56 | return visitor.visitAnnotationDefault(this, data); 57 | } 58 | 59 | public final Annotation.element_value default_value; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/AttributeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | /* 29 | *

This is NOT part of any supported API. 30 | * If you write code that depends on this, you do so at your own risk. 31 | * This code and its internal interfaces are subject to change or 32 | * deletion without notice. 33 | */ 34 | public class AttributeException extends Exception { 35 | private static final long serialVersionUID = -4231486387714867770L; 36 | AttributeException() { } 37 | 38 | AttributeException(String msg) { 39 | super(msg); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/CompilationID_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | *

This is NOT part of any supported API. 32 | * If you write code that depends on this, you do so at your own risk. 33 | * This code and its internal interfaces are subject to change or 34 | * deletion without notice. 35 | */ 36 | public class CompilationID_attribute extends Attribute { 37 | 38 | CompilationID_attribute(ClassReader cr, int name_index, int length) throws IOException { 39 | super(name_index, length); 40 | compilationID_index = cr.readUnsignedShort(); 41 | } 42 | 43 | public CompilationID_attribute(ConstantPool constant_pool, int compilationID_index) 44 | throws ConstantPoolException { 45 | this(constant_pool.getUTF8Index(Attribute.CompilationID), compilationID_index); 46 | } 47 | 48 | public CompilationID_attribute(int name_index, int compilationID_index) { 49 | super(name_index, 2); 50 | this.compilationID_index = compilationID_index; 51 | } 52 | 53 | String getCompilationID(ConstantPool constant_pool) 54 | throws ConstantPoolException { 55 | return constant_pool.getUTF8Value(compilationID_index); 56 | } 57 | 58 | public R accept(Visitor visitor, D data) { 59 | return visitor.visitCompilationID(this, data); 60 | } 61 | 62 | public final int compilationID_index; 63 | } 64 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/ConstantPoolException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | /* 29 | *

This is NOT part of any supported API. 30 | * If you write code that depends on this, you do so at your own risk. 31 | * This code and its internal interfaces are subject to change or 32 | * deletion without notice. 33 | */ 34 | public class ConstantPoolException extends Exception { 35 | private static final long serialVersionUID = -2324397349644754565L; 36 | ConstantPoolException(int index) { 37 | this.index = index; 38 | } 39 | 40 | public final int index; 41 | } 42 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/ConstantValue_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.2. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class ConstantValue_attribute extends Attribute { 39 | ConstantValue_attribute(ClassReader cr, int name_index, int length) throws IOException { 40 | super(name_index, length); 41 | constantvalue_index = cr.readUnsignedShort(); 42 | } 43 | 44 | public ConstantValue_attribute(ConstantPool constant_pool, int constantvalue_index) 45 | throws ConstantPoolException { 46 | this(constant_pool.getUTF8Index(Attribute.ConstantValue), constantvalue_index); 47 | } 48 | 49 | public ConstantValue_attribute(int name_index, int constantvalue_index) { 50 | super(name_index, 2); 51 | this.constantvalue_index = constantvalue_index; 52 | } 53 | 54 | public R accept(Visitor visitor, D data) { 55 | return visitor.visitConstantValue(this, data); 56 | } 57 | 58 | public final int constantvalue_index; 59 | } 60 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/DefaultAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | /* 29 | *

This is NOT part of any supported API. 30 | * If you write code that depends on this, you do so at your own risk. 31 | * This code and its internal interfaces are subject to change or 32 | * deletion without notice. 33 | */ 34 | public class DefaultAttribute extends Attribute { 35 | DefaultAttribute(ClassReader cr, int name_index, byte[] data) { 36 | this(cr, name_index, data, null); 37 | } 38 | 39 | DefaultAttribute(ClassReader cr, int name_index, byte[] data, String reason) { 40 | super(name_index, data.length); 41 | info = data; 42 | this.reason = reason; 43 | } 44 | 45 | public DefaultAttribute(ConstantPool constant_pool, int name_index, byte[] info) { 46 | this(constant_pool, name_index, info, null); 47 | } 48 | 49 | public DefaultAttribute(ConstantPool constant_pool, int name_index, 50 | byte[] info, String reason) { 51 | super(name_index, info.length); 52 | this.info = info; 53 | this.reason = reason; 54 | } 55 | 56 | public R accept(Visitor visitor, P p) { 57 | return visitor.visitDefault(this, p); 58 | } 59 | 60 | public final byte[] info; 61 | /** Why did we need to generate a DefaultAttribute 62 | */ 63 | public final String reason; 64 | } 65 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/Deprecated_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.15. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class Deprecated_attribute extends Attribute { 39 | Deprecated_attribute(ClassReader cr, int name_index, int length) throws IOException { 40 | super(name_index, length); 41 | } 42 | 43 | public Deprecated_attribute(ConstantPool constant_pool) 44 | throws ConstantPoolException { 45 | this(constant_pool.getUTF8Index(Attribute.Deprecated)); 46 | } 47 | 48 | public Deprecated_attribute(int name_index) { 49 | super(name_index, 0); 50 | } 51 | 52 | public R accept(Visitor visitor, D data) { 53 | return visitor.visitDeprecated(this, data); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/DescriptorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | /* 29 | *

This is NOT part of any supported API. 30 | * If you write code that depends on this, you do so at your own risk. 31 | * This code and its internal interfaces are subject to change or 32 | * deletion without notice. 33 | */ 34 | public class DescriptorException extends Exception { 35 | private static final long serialVersionUID = 2411890273788901032L; 36 | } 37 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/EnclosingMethod_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | 27 | package classfile; 28 | 29 | import java.io.IOException; 30 | 31 | /** 32 | * See JVMS, section 4.8.7. 33 | * 34 | *

This is NOT part of any supported API. 35 | * If you write code that depends on this, you do so at your own risk. 36 | * This code and its internal interfaces are subject to change or 37 | * deletion without notice. 38 | */ 39 | public class EnclosingMethod_attribute extends Attribute { 40 | EnclosingMethod_attribute(ClassReader cr, int name_index, int length) throws IOException { 41 | super(name_index, length); 42 | class_index = cr.readUnsignedShort(); 43 | method_index = cr.readUnsignedShort(); 44 | } 45 | 46 | public EnclosingMethod_attribute(ConstantPool constant_pool, int class_index, int method_index) 47 | throws ConstantPoolException { 48 | this(constant_pool.getUTF8Index(Attribute.EnclosingMethod), class_index, method_index); 49 | } 50 | 51 | public EnclosingMethod_attribute(int name_index, int class_index, int method_index) { 52 | super(name_index, 4); 53 | this.class_index = class_index; 54 | this.method_index = method_index; 55 | } 56 | 57 | public String getClassName(ConstantPool constant_pool) throws ConstantPoolException { 58 | return constant_pool.getClassInfo(class_index).getName(); 59 | } 60 | 61 | public String getMethodName(ConstantPool constant_pool) throws ConstantPoolException { 62 | if (method_index == 0) 63 | return ""; 64 | return constant_pool.getNameAndTypeInfo(method_index).getName(); 65 | } 66 | 67 | public R accept(Visitor visitor, D data) { 68 | return visitor.visitEnclosingMethod(this, data); 69 | } 70 | 71 | public final int class_index; 72 | public final int method_index; 73 | } 74 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/Exceptions_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.5. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class Exceptions_attribute extends Attribute { 39 | Exceptions_attribute(ClassReader cr, int name_index, int length) throws IOException { 40 | super(name_index, length); 41 | number_of_exceptions = cr.readUnsignedShort(); 42 | exception_index_table = new int[number_of_exceptions]; 43 | for (int i = 0; i < number_of_exceptions; i++) 44 | exception_index_table[i] = cr.readUnsignedShort(); 45 | } 46 | 47 | public Exceptions_attribute(ConstantPool constant_pool, int[] exception_index_table) 48 | throws ConstantPoolException { 49 | this(constant_pool.getUTF8Index(Attribute.Exceptions), exception_index_table); 50 | } 51 | 52 | public Exceptions_attribute(int name_index, int[] exception_index_table) { 53 | super(name_index, 2 + 2 * exception_index_table.length); 54 | this.number_of_exceptions = exception_index_table.length; 55 | this.exception_index_table = exception_index_table; 56 | } 57 | 58 | public String getException(int index, ConstantPool constant_pool) throws ConstantPoolException { 59 | int exception_index = exception_index_table[index]; 60 | return constant_pool.getClassInfo(exception_index).getName(); 61 | } 62 | 63 | public R accept(Visitor visitor, D data) { 64 | return visitor.visitExceptions(this, data); 65 | } 66 | 67 | public final int number_of_exceptions; 68 | public final int[] exception_index_table; 69 | } 70 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/Field.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /* 31 | *

This is NOT part of any supported API. 32 | * If you write code that depends on this, you do so at your own risk. 33 | * This code and its internal interfaces are subject to change or 34 | * deletion without notice. 35 | */ 36 | public class Field { 37 | Field(ClassReader cr) throws IOException { 38 | access_flags = new AccessFlags(cr); 39 | name_index = cr.readUnsignedShort(); 40 | descriptor = new Descriptor(cr); 41 | attributes = new Attributes(cr); 42 | } 43 | 44 | public Field(AccessFlags access_flags, 45 | int name_index, Descriptor descriptor, 46 | Attributes attributes) { 47 | this.access_flags = access_flags; 48 | this.name_index = name_index; 49 | this.descriptor = descriptor; 50 | this.attributes = attributes; 51 | } 52 | 53 | public int byteLength() { 54 | return 6 + attributes.byteLength(); 55 | } 56 | 57 | public String getName(ConstantPool constant_pool) throws ConstantPoolException { 58 | return constant_pool.getUTF8Value(name_index); 59 | } 60 | 61 | public final AccessFlags access_flags; 62 | public final int name_index; 63 | public final Descriptor descriptor; 64 | public final Attributes attributes; 65 | } 66 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/LineNumberTable_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.12. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class LineNumberTable_attribute extends Attribute { 39 | LineNumberTable_attribute(ClassReader cr, int name_index, int length) throws IOException { 40 | super(name_index, length); 41 | line_number_table_length = cr.readUnsignedShort(); 42 | line_number_table = new Entry[line_number_table_length]; 43 | for (int i = 0; i < line_number_table_length; i++) 44 | line_number_table[i] = new Entry(cr); 45 | } 46 | 47 | public LineNumberTable_attribute(ConstantPool constant_pool, Entry[] line_number_table) 48 | throws ConstantPoolException { 49 | this(constant_pool.getUTF8Index(Attribute.LineNumberTable), line_number_table); 50 | } 51 | 52 | public LineNumberTable_attribute(int name_index, Entry[] line_number_table) { 53 | super(name_index, 2 + line_number_table.length * Entry.length()); 54 | this.line_number_table_length = line_number_table.length; 55 | this.line_number_table = line_number_table; 56 | } 57 | 58 | public R accept(Visitor visitor, D data) { 59 | return visitor.visitLineNumberTable(this, data); 60 | } 61 | 62 | public final int line_number_table_length; 63 | public final Entry[] line_number_table; 64 | 65 | public static class Entry { 66 | Entry(ClassReader cr) throws IOException { 67 | start_pc = cr.readUnsignedShort(); 68 | line_number = cr.readUnsignedShort(); 69 | } 70 | 71 | public static int length() { 72 | return 4; 73 | } 74 | 75 | public final int start_pc; 76 | public final int line_number; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/Method.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /* 31 | *

This is NOT part of any supported API. 32 | * If you write code that depends on this, you do so at your own risk. 33 | * This code and its internal interfaces are subject to change or 34 | * deletion without notice. 35 | */ 36 | public class Method { 37 | Method(ClassReader cr) throws IOException { 38 | access_flags = new AccessFlags(cr); 39 | name_index = cr.readUnsignedShort(); 40 | descriptor = new Descriptor(cr); 41 | attributes = new Attributes(cr); 42 | } 43 | 44 | public Method(AccessFlags access_flags, 45 | int name_index, Descriptor descriptor, 46 | Attributes attributes) { 47 | this.access_flags = access_flags; 48 | this.name_index = name_index; 49 | this.descriptor = descriptor; 50 | this.attributes = attributes; 51 | } 52 | 53 | public int byteLength() { 54 | return 6 + attributes.byteLength(); 55 | } 56 | 57 | public String getName(ConstantPool constant_pool) throws ConstantPoolException { 58 | return constant_pool.getUTF8Value(name_index); 59 | } 60 | 61 | public final AccessFlags access_flags; 62 | public final int name_index; 63 | public final Descriptor descriptor; 64 | public final Attributes attributes; 65 | } 66 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/ModuleMainClass_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.15. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class ModuleMainClass_attribute extends Attribute { 39 | ModuleMainClass_attribute(ClassReader cr, int name_index, int length) throws IOException { 40 | super(name_index, length); 41 | main_class_index = cr.readUnsignedShort(); 42 | } 43 | 44 | public ModuleMainClass_attribute(ConstantPool constant_pool, int mainClass_index) 45 | throws ConstantPoolException { 46 | this(constant_pool.getUTF8Index(Attribute.ModuleMainClass), mainClass_index); 47 | } 48 | 49 | public ModuleMainClass_attribute(int name_index, int mainClass_index) { 50 | super(name_index, 2); 51 | this.main_class_index = mainClass_index; 52 | } 53 | 54 | public String getMainClassName(ConstantPool constant_pool) throws ConstantPoolException { 55 | return constant_pool.getClassInfo(main_class_index).getName(); 56 | } 57 | 58 | @Override 59 | public R accept(Visitor visitor, D data) { 60 | return visitor.visitModuleMainClass(this, data); 61 | } 62 | 63 | public final int main_class_index; 64 | } 65 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/ModulePackages_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import classfile.ConstantPool.CONSTANT_Package_info; 29 | 30 | import java.io.IOException; 31 | 32 | /** 33 | * See JVMS, section 4.8.15. 34 | * 35 | *

This is NOT part of any supported API. 36 | * If you write code that depends on this, you do so at your own risk. 37 | * This code and its internal interfaces are subject to change or 38 | * deletion without notice. 39 | */ 40 | public class ModulePackages_attribute extends Attribute { 41 | ModulePackages_attribute(ClassReader cr, int name_index, int length) 42 | throws IOException { 43 | super(name_index, length); 44 | packages_count = cr.readUnsignedShort(); 45 | packages_index = new int[packages_count]; 46 | for (int i = 0; i < packages_count; i++) 47 | packages_index[i] = cr.readUnsignedShort(); 48 | } 49 | 50 | public ModulePackages_attribute(ConstantPool constant_pool, 51 | int[] packages_index) 52 | throws ConstantPoolException { 53 | this(constant_pool.getUTF8Index(Attribute.ModulePackages), 54 | packages_index); 55 | } 56 | 57 | public ModulePackages_attribute(int name_index, 58 | int[] packages_index) { 59 | super(name_index, 2 + packages_index.length * 2); 60 | this.packages_count = packages_index.length; 61 | this.packages_index = packages_index; 62 | } 63 | 64 | public String getPackage(int index, ConstantPool constant_pool) throws ConstantPoolException { 65 | int package_index = packages_index[index]; 66 | CONSTANT_Package_info info = constant_pool.getPackageInfo(package_index); 67 | return info.getName(); 68 | } 69 | 70 | @Override 71 | public R accept(Visitor visitor, D data) { 72 | return visitor.visitModulePackages(this, data); 73 | } 74 | 75 | public final int packages_count; 76 | public final int[] packages_index; 77 | } 78 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/ModuleResolution_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.15. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class ModuleResolution_attribute extends Attribute { 39 | public static final int DO_NOT_RESOLVE_BY_DEFAULT = 0x0001; 40 | public static final int WARN_DEPRECATED = 0x0002; 41 | public static final int WARN_DEPRECATED_FOR_REMOVAL = 0x0004; 42 | public static final int WARN_INCUBATING = 0x0008; 43 | 44 | ModuleResolution_attribute(ClassReader cr, int name_index, int length) 45 | throws IOException { 46 | super(name_index, length); 47 | resolution_flags = cr.readUnsignedShort(); 48 | } 49 | 50 | public ModuleResolution_attribute(ConstantPool constant_pool, 51 | int resolution_flags) 52 | throws ConstantPoolException { 53 | this(constant_pool.getUTF8Index(Attribute.ModuleResolution), 54 | resolution_flags); 55 | } 56 | 57 | public ModuleResolution_attribute(int name_index, 58 | int resolution_flags) { 59 | super(name_index, 2); 60 | this.resolution_flags = resolution_flags; 61 | } 62 | 63 | @Override 64 | public R accept(Visitor visitor, D data) { 65 | return visitor.visitModuleResolution(this, data); 66 | } 67 | 68 | public final int resolution_flags; 69 | } 70 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/ModuleTarget_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.15. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class ModuleTarget_attribute extends Attribute { 39 | ModuleTarget_attribute(ClassReader cr, int name_index, int length) throws IOException { 40 | super(name_index, length); 41 | target_platform_index = cr.readUnsignedShort(); 42 | } 43 | 44 | public ModuleTarget_attribute(int name_index, int target_platform_index) { 45 | super(name_index, 2); 46 | this.target_platform_index = target_platform_index; 47 | } 48 | 49 | @Override 50 | public R accept(Visitor visitor, D data) { 51 | return visitor.visitModuleTarget(this, data); 52 | } 53 | 54 | public final int target_platform_index; 55 | } 56 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/NestHost_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import classfile.ConstantPool.CONSTANT_Class_info; 29 | 30 | import java.io.IOException; 31 | 32 | /** 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class NestHost_attribute extends Attribute { 39 | NestHost_attribute(ClassReader cr, int name_index, int length) throws IOException { 40 | super(name_index, length); 41 | top_index = cr.readUnsignedShort(); 42 | } 43 | 44 | public NestHost_attribute(ConstantPool constant_pool, int signature_index) 45 | throws ConstantPoolException { 46 | this(constant_pool.getUTF8Index(Attribute.Signature), signature_index); 47 | } 48 | 49 | public NestHost_attribute(int name_index, int top_index) { 50 | super(name_index, 2); 51 | this.top_index = top_index; 52 | } 53 | 54 | public CONSTANT_Class_info getNestTop(ConstantPool constant_pool) throws ConstantPoolException { 55 | return constant_pool.getClassInfo(top_index); 56 | } 57 | 58 | public R accept(Visitor visitor, D data) { 59 | return visitor.visitNestHost(this, data); 60 | } 61 | 62 | public final int top_index; 63 | } 64 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/NestMembers_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import classfile.ConstantPool.CONSTANT_Class_info; 29 | 30 | import java.io.IOException; 31 | import java.util.stream.IntStream; 32 | 33 | /** 34 | *

This is NOT part of any supported API. 35 | * If you write code that depends on this, you do so at your own risk. 36 | * This code and its internal interfaces are subject to change or 37 | * deletion without notice. 38 | */ 39 | public class NestMembers_attribute extends Attribute { 40 | NestMembers_attribute(ClassReader cr, int name_index, int length) throws IOException { 41 | super(name_index, length); 42 | int len = cr.readUnsignedShort(); 43 | members_indexes = new int[len]; 44 | for (int i = 0 ; i < len ; i++) { 45 | members_indexes[i] = cr.readUnsignedShort(); 46 | } 47 | } 48 | 49 | public NestMembers_attribute(int name_index, int[] members_indexes) { 50 | super(name_index, 2); 51 | this.members_indexes = members_indexes; 52 | } 53 | 54 | public CONSTANT_Class_info[] getChildren(ConstantPool constant_pool) throws ConstantPoolException { 55 | return IntStream.of(members_indexes) 56 | .mapToObj(i -> { 57 | try { 58 | return constant_pool.getClassInfo(i); 59 | } catch (ConstantPoolException ex) { 60 | throw new AssertionError(ex); 61 | } 62 | }).toArray(CONSTANT_Class_info[]::new); 63 | } 64 | 65 | public R accept(Visitor visitor, D data) { 66 | return visitor.visitNestMembers(this, data); 67 | } 68 | 69 | public final int[] members_indexes; 70 | } 71 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/Record_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | *

This is NOT part of any supported API. 32 | * If you write code that depends on this, you do so at your own risk. 33 | * This code and its internal interfaces are subject to change or 34 | * deletion without notice. 35 | */ 36 | public class Record_attribute extends Attribute { 37 | Record_attribute(ClassReader cr, int name_index, int length) throws IOException { 38 | super(name_index, length); 39 | component_count = cr.readUnsignedShort(); 40 | component_info_arr = new ComponentInfo[component_count]; 41 | for (int i = 0; i < component_count; i++) { 42 | component_info_arr[i] = new ComponentInfo(cr); 43 | } 44 | } 45 | 46 | @Override 47 | public R accept(Visitor visitor, D data) { 48 | return visitor.visitRecord(this, data); 49 | } 50 | 51 | public final int component_count; 52 | public final ComponentInfo[] component_info_arr; 53 | 54 | public static class ComponentInfo { 55 | ComponentInfo(ClassReader cr) throws IOException { 56 | name_index = cr.readUnsignedShort(); 57 | descriptor = new Descriptor(cr); 58 | attributes = new Attributes(cr); 59 | } 60 | 61 | public String getName(ConstantPool constant_pool) throws ConstantPoolException { 62 | return constant_pool.getUTF8Value(name_index); 63 | } 64 | 65 | public final int name_index; 66 | public final Descriptor descriptor; 67 | public final Attributes attributes; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/RuntimeAnnotations_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.16 and 4.8.17. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public abstract class RuntimeAnnotations_attribute extends Attribute { 39 | protected RuntimeAnnotations_attribute(ClassReader cr, int name_index, int length) 40 | throws IOException, Annotation.InvalidAnnotation { 41 | super(name_index, length); 42 | int num_annotations = cr.readUnsignedShort(); 43 | annotations = new Annotation[num_annotations]; 44 | for (int i = 0; i < annotations.length; i++) 45 | annotations[i] = new Annotation(cr); 46 | } 47 | 48 | protected RuntimeAnnotations_attribute(int name_index, Annotation[] annotations) { 49 | super(name_index, length(annotations)); 50 | this.annotations = annotations; 51 | } 52 | 53 | private static int length(Annotation[] annos) { 54 | int n = 2; 55 | for (Annotation anno: annos) 56 | n += anno.length(); 57 | return n; 58 | } 59 | 60 | public final Annotation[] annotations; 61 | } 62 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/RuntimeInvisibleAnnotations_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.17. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class RuntimeInvisibleAnnotations_attribute extends RuntimeAnnotations_attribute { 39 | RuntimeInvisibleAnnotations_attribute(ClassReader cr, int name_index, int length) 40 | throws IOException, AttributeException { 41 | super(cr, name_index, length); 42 | } 43 | 44 | public RuntimeInvisibleAnnotations_attribute(ConstantPool cp, Annotation[] annotations) 45 | throws ConstantPoolException { 46 | this(cp.getUTF8Index(Attribute.RuntimeInvisibleAnnotations), annotations); 47 | } 48 | 49 | public RuntimeInvisibleAnnotations_attribute(int name_index, Annotation[] annotations) { 50 | super(name_index, annotations); 51 | } 52 | 53 | public R accept(Visitor visitor, P p) { 54 | return visitor.visitRuntimeInvisibleAnnotations(this, p); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/RuntimeInvisibleParameterAnnotations_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.18. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class RuntimeInvisibleParameterAnnotations_attribute extends RuntimeParameterAnnotations_attribute { 39 | RuntimeInvisibleParameterAnnotations_attribute(ClassReader cr, int name_index, int length) 40 | throws IOException, Annotation.InvalidAnnotation { 41 | super(cr, name_index, length); 42 | } 43 | 44 | public RuntimeInvisibleParameterAnnotations_attribute(ConstantPool cp, Annotation[][] parameter_annotations) 45 | throws ConstantPoolException { 46 | this(cp.getUTF8Index(Attribute.RuntimeInvisibleParameterAnnotations), parameter_annotations); 47 | } 48 | 49 | public RuntimeInvisibleParameterAnnotations_attribute(int name_index, Annotation[][] parameter_annotations) { 50 | super(name_index, parameter_annotations); 51 | } 52 | 53 | public R accept(Visitor visitor, P p) { 54 | return visitor.visitRuntimeInvisibleParameterAnnotations(this, p); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/RuntimeInvisibleTypeAnnotations_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JSR 308 specification, Section 3. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class RuntimeInvisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute { 39 | RuntimeInvisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length) 40 | throws IOException, Annotation.InvalidAnnotation { 41 | super(cr, name_index, length); 42 | } 43 | 44 | public RuntimeInvisibleTypeAnnotations_attribute(ConstantPool cp, TypeAnnotation[] annotations) 45 | throws ConstantPoolException { 46 | this(cp.getUTF8Index(Attribute.RuntimeInvisibleTypeAnnotations), annotations); 47 | } 48 | 49 | public RuntimeInvisibleTypeAnnotations_attribute(int name_index, TypeAnnotation[] annotations) { 50 | super(name_index, annotations); 51 | } 52 | 53 | public R accept(Visitor visitor, P p) { 54 | return visitor.visitRuntimeInvisibleTypeAnnotations(this, p); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/RuntimeParameterAnnotations_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.18 and 4.8.19. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public abstract class RuntimeParameterAnnotations_attribute extends Attribute { 39 | RuntimeParameterAnnotations_attribute(ClassReader cr, int name_index, int length) 40 | throws IOException, Annotation.InvalidAnnotation { 41 | super(name_index, length); 42 | int num_parameters = cr.readUnsignedByte(); 43 | parameter_annotations = new Annotation[num_parameters][]; 44 | for (int p = 0; p < parameter_annotations.length; p++) { 45 | int num_annotations = cr.readUnsignedShort(); 46 | Annotation[] annotations = new Annotation[num_annotations]; 47 | for (int i = 0; i < num_annotations; i++) 48 | annotations[i] = new Annotation(cr); 49 | parameter_annotations[p] = annotations; 50 | } 51 | } 52 | 53 | protected RuntimeParameterAnnotations_attribute(int name_index, Annotation[][] parameter_annotations) { 54 | super(name_index, length(parameter_annotations)); 55 | this.parameter_annotations = parameter_annotations; 56 | } 57 | 58 | private static int length(Annotation[][] anno_arrays) { 59 | int n = 1; 60 | for (Annotation[] anno_array: anno_arrays) { 61 | n += 2; 62 | for (Annotation anno: anno_array) 63 | n += anno.length(); 64 | } 65 | return n; 66 | } 67 | 68 | public final Annotation[][] parameter_annotations; 69 | } 70 | 71 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/RuntimeTypeAnnotations_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JSR 308 specification, Section 3. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public abstract class RuntimeTypeAnnotations_attribute extends Attribute { 39 | protected RuntimeTypeAnnotations_attribute(ClassReader cr, int name_index, int length) 40 | throws IOException, Annotation.InvalidAnnotation { 41 | super(name_index, length); 42 | int num_annotations = cr.readUnsignedShort(); 43 | annotations = new TypeAnnotation[num_annotations]; 44 | for (int i = 0; i < annotations.length; i++) 45 | annotations[i] = new TypeAnnotation(cr); 46 | } 47 | 48 | protected RuntimeTypeAnnotations_attribute(int name_index, TypeAnnotation[] annotations) { 49 | super(name_index, length(annotations)); 50 | this.annotations = annotations; 51 | } 52 | 53 | private static int length(TypeAnnotation[] annos) { 54 | int n = 2; 55 | for (TypeAnnotation anno: annos) 56 | n += anno.length(); 57 | return n; 58 | } 59 | 60 | public final TypeAnnotation[] annotations; 61 | } 62 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/RuntimeVisibleAnnotations_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.16. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class RuntimeVisibleAnnotations_attribute extends RuntimeAnnotations_attribute { 39 | RuntimeVisibleAnnotations_attribute(ClassReader cr, int name_index, int length) 40 | throws IOException, Annotation.InvalidAnnotation { 41 | super(cr, name_index, length); 42 | } 43 | 44 | public RuntimeVisibleAnnotations_attribute(ConstantPool cp, Annotation[] annotations) 45 | throws ConstantPoolException { 46 | this(cp.getUTF8Index(Attribute.RuntimeVisibleAnnotations), annotations); 47 | } 48 | 49 | public RuntimeVisibleAnnotations_attribute(int name_index, Annotation[] annotations) { 50 | super(name_index, annotations); 51 | } 52 | 53 | public R accept(Visitor visitor, P p) { 54 | return visitor.visitRuntimeVisibleAnnotations(this, p); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/RuntimeVisibleParameterAnnotations_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.18. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class RuntimeVisibleParameterAnnotations_attribute extends RuntimeParameterAnnotations_attribute { 39 | RuntimeVisibleParameterAnnotations_attribute(ClassReader cr, int name_index, int length) 40 | throws IOException, Annotation.InvalidAnnotation { 41 | super(cr, name_index, length); 42 | } 43 | 44 | public RuntimeVisibleParameterAnnotations_attribute(ConstantPool cp, Annotation[][] parameter_annotations) 45 | throws ConstantPoolException { 46 | this(cp.getUTF8Index(Attribute.RuntimeVisibleParameterAnnotations), parameter_annotations); 47 | } 48 | 49 | public RuntimeVisibleParameterAnnotations_attribute(int name_index, Annotation[][] parameter_annotations) { 50 | super(name_index, parameter_annotations); 51 | } 52 | 53 | public R accept(Visitor visitor, P p) { 54 | return visitor.visitRuntimeVisibleParameterAnnotations(this, p); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/RuntimeVisibleTypeAnnotations_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JSR 308 specification, Section 3. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class RuntimeVisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute { 39 | RuntimeVisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length) 40 | throws IOException, Annotation.InvalidAnnotation { 41 | super(cr, name_index, length); 42 | } 43 | 44 | public RuntimeVisibleTypeAnnotations_attribute(ConstantPool cp, TypeAnnotation[] annotations) 45 | throws ConstantPoolException { 46 | this(cp.getUTF8Index(Attribute.RuntimeVisibleTypeAnnotations), annotations); 47 | } 48 | 49 | public RuntimeVisibleTypeAnnotations_attribute(int name_index, TypeAnnotation[] annotations) { 50 | super(name_index, annotations); 51 | } 52 | 53 | public R accept(Visitor visitor, P p) { 54 | return visitor.visitRuntimeVisibleTypeAnnotations(this, p); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/Signature_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.9. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class Signature_attribute extends Attribute { 39 | Signature_attribute(ClassReader cr, int name_index, int length) throws IOException { 40 | super(name_index, length); 41 | signature_index = cr.readUnsignedShort(); 42 | } 43 | 44 | public Signature_attribute(ConstantPool constant_pool, int signature_index) 45 | throws ConstantPoolException { 46 | this(constant_pool.getUTF8Index(Attribute.Signature), signature_index); 47 | } 48 | 49 | public Signature_attribute(int name_index, int signature_index) { 50 | super(name_index, 2); 51 | this.signature_index = signature_index; 52 | } 53 | 54 | public String getSignature(ConstantPool constant_pool) throws ConstantPoolException { 55 | return constant_pool.getUTF8Value(signature_index); 56 | } 57 | 58 | public Signature getParsedSignature() { 59 | return new Signature(signature_index); 60 | } 61 | 62 | public R accept(Visitor visitor, D data) { 63 | return visitor.visitSignature(this, data); 64 | } 65 | 66 | public final int signature_index; 67 | } 68 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/SourceDebugExtension_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | import java.nio.charset.Charset; 30 | 31 | /** 32 | * See JVMS, section 4.8.15. 33 | * 34 | *

This is NOT part of any supported API. 35 | * If you write code that depends on this, you do so at your own risk. 36 | * This code and its internal interfaces are subject to change or 37 | * deletion without notice. 38 | */ 39 | public class SourceDebugExtension_attribute extends Attribute { 40 | private static final Charset UTF8 = Charset.forName("UTF-8"); 41 | 42 | SourceDebugExtension_attribute(ClassReader cr, int name_index, int length) throws IOException { 43 | super(name_index, length); 44 | debug_extension = new byte[attribute_length]; 45 | cr.readFully(debug_extension); 46 | } 47 | 48 | public SourceDebugExtension_attribute(ConstantPool constant_pool, byte[] debug_extension) 49 | throws ConstantPoolException { 50 | this(constant_pool.getUTF8Index(Attribute.SourceDebugExtension), debug_extension); 51 | } 52 | 53 | public SourceDebugExtension_attribute(int name_index, byte[] debug_extension) { 54 | super(name_index, debug_extension.length); 55 | this.debug_extension = debug_extension; 56 | } 57 | 58 | public String getValue() { 59 | return new String(debug_extension, UTF8); 60 | } 61 | 62 | public R accept(Visitor visitor, D data) { 63 | return visitor.visitSourceDebugExtension(this, data); 64 | } 65 | 66 | public final byte[] debug_extension; 67 | } 68 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/SourceFile_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.10. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class SourceFile_attribute extends Attribute { 39 | SourceFile_attribute(ClassReader cr, int name_index, int length) throws IOException { 40 | super(name_index, length); 41 | sourcefile_index = cr.readUnsignedShort(); 42 | } 43 | 44 | public SourceFile_attribute(ConstantPool constant_pool, int sourcefile_index) 45 | throws ConstantPoolException { 46 | this(constant_pool.getUTF8Index(Attribute.SourceFile), sourcefile_index); 47 | } 48 | 49 | public SourceFile_attribute(int name_index, int sourcefile_index) { 50 | super(name_index, 2); 51 | this.sourcefile_index = sourcefile_index; 52 | } 53 | 54 | public String getSourceFile(ConstantPool constant_pool) throws ConstantPoolException { 55 | return constant_pool.getUTF8Value(sourcefile_index); 56 | } 57 | 58 | public R accept(Visitor visitor, P p) { 59 | return visitor.visitSourceFile(this, p); 60 | } 61 | 62 | public final int sourcefile_index; 63 | } 64 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/SourceID_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | *

This is NOT part of any supported API. 32 | * If you write code that depends on this, you do so at your own risk. 33 | * This code and its internal interfaces are subject to change or 34 | * deletion without notice. 35 | */ 36 | public class SourceID_attribute extends Attribute { 37 | 38 | SourceID_attribute(ClassReader cr, int name_index, int length) throws IOException { 39 | super(name_index, length); 40 | sourceID_index = cr.readUnsignedShort(); 41 | } 42 | 43 | public SourceID_attribute(ConstantPool constant_pool, int sourceID_index) 44 | throws ConstantPoolException { 45 | this(constant_pool.getUTF8Index(Attribute.SourceID), sourceID_index); 46 | } 47 | 48 | public SourceID_attribute(int name_index, int sourceID_index) { 49 | super(name_index, 2); 50 | this.sourceID_index = sourceID_index; 51 | } 52 | 53 | String getSourceID(ConstantPool constant_pool) throws ConstantPoolException { 54 | return constant_pool.getUTF8Value(sourceID_index); 55 | } 56 | 57 | public R accept(Visitor visitor, D data) { 58 | return visitor.visitSourceID(this, data); 59 | } 60 | 61 | public final int sourceID_index; 62 | } 63 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/StackMap_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | *

This is NOT part of any supported API. 32 | * If you write code that depends on this, you do so at your own risk. 33 | * This code and its internal interfaces are subject to change or 34 | * deletion without notice. 35 | */ 36 | public class StackMap_attribute extends Attribute { 37 | StackMap_attribute(ClassReader cr, int name_index, int length) 38 | throws IOException, StackMapTable_attribute.InvalidStackMap { 39 | super(name_index, length); 40 | number_of_entries = cr.readUnsignedShort(); 41 | entries = new stack_map_frame[number_of_entries]; 42 | for (int i = 0; i < number_of_entries; i++) 43 | entries[i] = new stack_map_frame(cr); 44 | } 45 | 46 | public StackMap_attribute(ConstantPool constant_pool, stack_map_frame[] entries) 47 | throws ConstantPoolException { 48 | this(constant_pool.getUTF8Index(Attribute.StackMap), entries); 49 | } 50 | 51 | public StackMap_attribute(int name_index, stack_map_frame[] entries) { 52 | super(name_index, StackMapTable_attribute.length(entries)); 53 | this.number_of_entries = entries.length; 54 | this.entries = entries; 55 | } 56 | 57 | public R accept(Visitor visitor, D data) { 58 | return visitor.visitStackMap(this, data); 59 | } 60 | 61 | public final int number_of_entries; 62 | public final stack_map_frame entries[]; 63 | 64 | public static class stack_map_frame extends StackMapTable_attribute.full_frame { 65 | stack_map_frame(ClassReader cr) 66 | throws IOException, StackMapTable_attribute.InvalidStackMap { 67 | super(255, cr); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/Synthetic_attribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | package classfile; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * See JVMS, section 4.8.8. 32 | * 33 | *

This is NOT part of any supported API. 34 | * If you write code that depends on this, you do so at your own risk. 35 | * This code and its internal interfaces are subject to change or 36 | * deletion without notice. 37 | */ 38 | public class Synthetic_attribute extends Attribute { 39 | Synthetic_attribute(ClassReader cr, int name_index, int length) throws IOException { 40 | super(name_index, length); 41 | } 42 | 43 | public Synthetic_attribute(ConstantPool constant_pool) 44 | throws ConstantPoolException { 45 | this(constant_pool.getUTF8Index(Attribute.Synthetic)); 46 | } 47 | 48 | public Synthetic_attribute(int name_index) { 49 | super(name_index, 0); 50 | } 51 | 52 | public R accept(Visitor visitor, D data) { 53 | return visitor.visitSynthetic(this, data); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/classfile/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | /** 27 | A minimalist library to read and write class files into objects closely 28 | based on the corresponding definitions in 29 | The Java™ Virtual Machine Specification (JVMS). 30 | 31 |

This is NOT part of any supported API. 32 | If you write code that depends on this, you do so at your own risk. 33 | This code and its internal interfaces are subject to change or 34 | deletion without notice. 35 | */ 36 | package classfile; 37 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/com/codelang/parse/bean/ConfigBean.java: -------------------------------------------------------------------------------- 1 | package com.codelang.parse.bean; 2 | 3 | import java.util.List; 4 | 5 | import javax.annotation.Nullable; 6 | 7 | public class ConfigBean { 8 | private List stringRef; 9 | private List methodRef; 10 | private List fieldRef; 11 | 12 | @Nullable 13 | public List getStringRef() { 14 | return stringRef; 15 | } 16 | 17 | public void setStringRef(List stringRef) { 18 | this.stringRef = stringRef; 19 | } 20 | 21 | @Nullable 22 | public List getFieldRef() { 23 | return fieldRef; 24 | } 25 | 26 | public void setFieldRef(List fieldRef) { 27 | this.fieldRef = fieldRef; 28 | } 29 | 30 | @Nullable 31 | public List getMethodRef() { 32 | return methodRef; 33 | } 34 | 35 | public void setMethodRef(List methodRef) { 36 | this.methodRef = methodRef; 37 | } 38 | 39 | public static class Method { 40 | private String className; 41 | private String method; 42 | private String signature; 43 | 44 | public String getClassName() { 45 | return className; 46 | } 47 | 48 | public void setClassName(String className) { 49 | this.className = className; 50 | } 51 | 52 | public String getMethod() { 53 | return method; 54 | } 55 | 56 | public void setMethod(String method) { 57 | this.method = method; 58 | } 59 | 60 | public String getSignature() { 61 | return signature; 62 | } 63 | 64 | public void setSignature(String signature) { 65 | this.signature = signature; 66 | } 67 | } 68 | 69 | public static class Feild { 70 | private String className; 71 | private String fieldName; 72 | private String signature; 73 | 74 | public String getClassName() { 75 | return className; 76 | } 77 | 78 | public void setClassName(String className) { 79 | this.className = className; 80 | } 81 | 82 | public String getFieldName() { 83 | return fieldName; 84 | } 85 | 86 | public void setFieldName(String fieldName) { 87 | this.fieldName = fieldName; 88 | } 89 | 90 | public String getSignature() { 91 | return signature; 92 | } 93 | 94 | public void setSignature(String signature) { 95 | this.signature = signature; 96 | } 97 | 98 | @Override 99 | public String toString() { 100 | return "Feild{" + 101 | "className='" + className + '\'' + 102 | ", fieldName='" + fieldName + '\'' + 103 | ", signature='" + signature + '\'' + 104 | '}'; 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /plugin/classAnalysis/src/main/java/com/codelang/parse/extension/ConfigFileExtension.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.parse.extension 2 | 3 | open class ConfigFileExtension { 4 | var configFile: String = "" 5 | } -------------------------------------------------------------------------------- /plugin/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | #org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | 23 | apgVersion=7.0.0 24 | kotlinVersion=1.5.30 25 | 26 | org.gradle.jvmargs=-XX:MaxPermSize=4g -XX:+HeapDumpOnOutOfMemoryError -Xmx4g -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5006 -------------------------------------------------------------------------------- /plugin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MRwangqi/pluginDemo/aa7a2d0c8bcbcc8fcd8438ca273a468b7a4d4725/plugin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /plugin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Feb 09 10:43:29 CST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /plugin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /plugin/modulePlugin/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /plugin/modulePlugin/README.md: -------------------------------------------------------------------------------- 1 | 本地 module 与 GAV 转换插件,适用于使用壳工程改造的组件化,效果可查看 demo 2 | 3 | 配置 maven 镜像源和依赖 4 | ```java 5 | buildscript { 6 | repositories { 7 | ... 8 | // maven 源 9 | maven{ 10 | url "https://raw.githubusercontent.com/MRwangqi/Maven/main" 11 | } 12 | } 13 | dependencies { 14 | classpath "com.android.tools.build:gradle:7.0.4" 15 | // 依赖 check 插件 16 | classpath "com.github.MRwangqi:modulePlugin:1.0.0" 17 | } 18 | } 19 | ``` 20 | 21 | 在 app 工程的 build.gradle 中依赖插件(app 为主壳模块) 22 | 23 | ```java 24 | plugins { 25 | id 'com.android.application' 26 | // apply modulePlugin 插件 27 | id 'modulePlugin' 28 | } 29 | ``` 30 | 31 | 32 | gradle.properties 配置 33 | 34 | ``` 35 | # GAV 转本地 module 开关 36 | gav2project.enable=true 37 | # 如果指定跳过模块,则不会参与 GAV 与 Project 的转换(仅在 gav2project.enable=true 时生效) 38 | gav2project.skips=android-lib,android-lib 39 | ``` 40 | 41 | 42 | 开启转换开关效果: 43 | ``` 44 | > Configure project :app 45 | 排除依赖:implementation com.codelang.library:android-lib:1.0.0 46 | 替换本地模块:implementation project(:android-lib) 47 | ``` 48 | 49 | 开启跳过模块效果: 50 | ``` 51 | > Configure project :app 52 | ------- 跳过模块:android-lib----依赖为:com.codelang.library:android-lib-------- 53 | ``` -------------------------------------------------------------------------------- /plugin/modulePlugin/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'groovy' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'java-gradle-plugin' 4 | apply plugin: 'maven-publish' 5 | 6 | dependencies { 7 | implementation gradleApi() 8 | implementation localGroovy() 9 | api "com.android.tools.build:gradle-api:$apgVersion" 10 | api "com.android.tools.build:gradle:$apgVersion" 11 | implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 12 | } 13 | 14 | version = "1.0.0" 15 | group = "com.github.MRwangqi" 16 | 17 | gradlePlugin { 18 | plugins { 19 | version { 20 | id = 'modulePlugin' 21 | implementationClass = 'com.codelang.plugin.ModulePlugin' 22 | } 23 | } 24 | } 25 | 26 | 27 | afterEvaluate { 28 | publishing { 29 | publications { 30 | maven(MavenPublication) { 31 | from components.java 32 | groupId = "com.github.MRwangqi" 33 | artifactId = "modulePlugin" 34 | version = "1.0.0" 35 | } 36 | } 37 | 38 | repositories { 39 | maven { 40 | url = "../../build/Maven" 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /plugin/modulePlugin/src/main/java/com/codelang/plugin/utils/Utils.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin.utils 2 | 3 | import org.gradle.api.Project 4 | 5 | object Utils { 6 | 7 | private const val GAV_ENABLE = "gav2project.enable" 8 | private const val GAV_SKIPS = "gav2project.skips" 9 | 10 | fun isEnable(project: Project): Boolean { 11 | try { 12 | if (project.rootProject.hasProperty(GAV_ENABLE)) { 13 | return project.rootProject.properties[GAV_ENABLE].toString().toBoolean() 14 | } 15 | } catch (e: Exception) { 16 | } 17 | return true 18 | } 19 | 20 | fun getSkips(project: Project): List { 21 | try { 22 | if (project.rootProject.hasProperty(GAV_SKIPS)) { 23 | return project.rootProject.properties[GAV_SKIPS].toString().split(",") 24 | } 25 | } catch (e: Exception) { 26 | } 27 | return arrayListOf() 28 | } 29 | } -------------------------------------------------------------------------------- /plugin/permissionPlugin/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /plugin/permissionPlugin/PermissionPlugin.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MRwangqi/pluginDemo/aa7a2d0c8bcbcc8fcd8438ca273a468b7a4d4725/plugin/permissionPlugin/PermissionPlugin.gradle -------------------------------------------------------------------------------- /plugin/permissionPlugin/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MRwangqi/pluginDemo/aa7a2d0c8bcbcc8fcd8438ca273a468b7a4d4725/plugin/permissionPlugin/README.md -------------------------------------------------------------------------------- /plugin/permissionPlugin/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'groovy' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'java-gradle-plugin' 4 | apply plugin: 'maven-publish' 5 | 6 | dependencies { 7 | implementation gradleApi() 8 | implementation localGroovy() 9 | api "com.android.tools.build:gradle-api:$apgVersion" 10 | api "com.android.tools.build:gradle:$apgVersion" 11 | implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 12 | } 13 | 14 | version = "1.0.0" 15 | group = "com.github.MRwangqi" 16 | 17 | gradlePlugin { 18 | plugins { 19 | version { 20 | id = 'permissionPlugin' 21 | implementationClass = 'com.codelang.plugin.PermissionPlugin' 22 | } 23 | } 24 | } 25 | 26 | 27 | afterEvaluate { 28 | publishing { 29 | publications { 30 | maven(MavenPublication) { 31 | from components.java 32 | groupId = "com.github.MRwangqi" 33 | artifactId = "permissionPlugin" 34 | version = "1.0.0" 35 | } 36 | } 37 | 38 | repositories { 39 | maven { 40 | url = "../../build/Maven" 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /plugin/permissionPlugin/src/main/java/com/codelang/plugin/PermissionPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin 2 | 3 | import com.android.build.gradle.AppExtension 4 | import groovy.util.Node 5 | import groovy.xml.XmlParser 6 | import groovy.xml.XmlUtil 7 | import org.gradle.api.Plugin 8 | import org.gradle.api.Project 9 | import java.io.File 10 | 11 | /** 12 | * 官方清单文件合并规则: 13 | * https://developer.android.com/studio/build/manifest-merge?hl=zh-cn 14 | */ 15 | class PermissionPlugin : Plugin { 16 | 17 | override fun apply(project: Project) { 18 | println("PermissionPlugin start ---------->") 19 | 20 | 21 | // 获取 main 下的清单文件,如果找不到,则手动指定清单文件 22 | val mainAndroidManifest = project.extensions.getByType(AppExtension::class.java) 23 | .sourceSets.find { it.name == "main" }?.manifest?.srcFile 24 | ?: File(project.projectDir, "src/main/AndroidManifest.xml") 25 | 26 | // 1、读取主工程下清单文件的权限,并从主工程中删除,避免有小伙伴在该文件中提交敏感权限 27 | val parentNode = XmlParser(false, false).parse(mainAndroidManifest) 28 | val childrenNode = parentNode.children() 29 | val permissionNodes = childrenNode.map { it as Node }.filter { it.name() == "uses-permission" }.toList() 30 | if (permissionNodes.isNotEmpty()) { 31 | childrenNode.removeAll(permissionNodes) 32 | val xmlText = XmlUtil.serialize(parentNode) 33 | mainAndroidManifest.writeText(xmlText) 34 | } 35 | 36 | 37 | // 2、生成权限文件,直接使用主工程清单文件去除权限的模板 38 | val permissionPath = File(project.projectDir, "permission") 39 | permissionPath.mkdir() 40 | val permissionFile = File(permissionPath, "AndroidManifest.xml") 41 | if (permissionFile.exists()) { 42 | permissionFile.delete() 43 | } 44 | permissionFile.createNewFile() 45 | 46 | // 添加自定义权限 47 | getPermission().forEach { 48 | childrenNode.add(0, Node(null, it)) 49 | } 50 | val xmlText2 = XmlUtil.serialize(parentNode) 51 | permissionFile.writeText(xmlText2) 52 | 53 | // 将生成的权限文件添加进 main sourceSet 中参与项目编译 54 | project.afterEvaluate { 55 | project.extensions.getByType(AppExtension::class.java) 56 | .sourceSets.find { it.name == "main" }?.manifest?.srcFile(permissionFile) 57 | } 58 | } 59 | 60 | 61 | private fun getPermission(): List { 62 | val list = arrayListOf() 63 | list.addAll(getCommonPermissions()) 64 | list.addAll(getPhoneBlackPermission()) 65 | return list 66 | } 67 | 68 | /** 69 | * 设置通用权限 70 | */ 71 | private fun getCommonPermissions(): List { 72 | val list = arrayListOf() 73 | list.add(Utils.getPermission("android.permission.INTERNET")) 74 | return list 75 | } 76 | 77 | /** 78 | * phone 相关的敏感权限需要移除 79 | */ 80 | private fun getPhoneBlackPermission(): List { 81 | val list = arrayListOf() 82 | list.add(Utils.getRemovePermission("android.permission.CALL_PHONE")) 83 | list.add(Utils.getRemovePermission("android.permission.READ_PHONE_STATE")) 84 | return list 85 | } 86 | 87 | } -------------------------------------------------------------------------------- /plugin/permissionPlugin/src/main/java/com/codelang/plugin/Utils.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.plugin 2 | 3 | object Utils { 4 | 5 | fun getRemovePermission(name: String): String { 6 | return """ 7 | uses-permission android:name="$name" tools:node="remove" 8 | """.trimIndent() 9 | } 10 | 11 | 12 | fun getPermission(name: String): String { 13 | return """ 14 | uses-permission android:name="$name" 15 | """.trimIndent() 16 | } 17 | } -------------------------------------------------------------------------------- /plugin/resourcePlugin/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /plugin/resourcePlugin/README.md: -------------------------------------------------------------------------------- 1 | 资源重复检查,目前仅支持: 2 | - Drawable 目录重复资源检查 3 | - Assets 目录重复资源检查 4 | - layout 目录重复资源检查 5 | 6 | 配置 maven 镜像源和依赖 7 | ```java 8 | buildscript { 9 | repositories { 10 | ... 11 | // maven 源 12 | maven{ 13 | url "https://raw.githubusercontent.com/MRwangqi/Maven/main" 14 | } 15 | } 16 | dependencies { 17 | classpath "com.android.tools.build:gradle:7.0.4" 18 | // 依赖 resourcePlugin 插件 19 | classpath "com.github.MRwangqi:resourcePlugin:1.0.0" 20 | } 21 | } 22 | ``` 23 | 24 | 在 app 工程的 build.gradle 中依赖插件(app 为主壳模块) 25 | 26 | ```java 27 | plugins { 28 | id 'com.android.application' 29 | // apply resourcePlugin 插件 30 | id 'resourcePlugin' 31 | } 32 | ``` 33 | 34 | 35 | 36 | 也有一些小伙伴的项目没有适配 AGP 7.X,所以,这里用 gradle file 写了一遍,但只实现了 layout 的重复检查,其他两个就交由大家自己实现了,照葫芦画瓢,我觉得应该不难。 37 | 38 | 在 app 工程的 build.gradle 中引入 [resourcePlugin.gradle](resourcePlugin.gradle) 文件 39 | ```aidl 40 | plugins { 41 | id 'com.android.application' 42 | } 43 | apply from :"resourcePlugin.gradle" 44 | ``` 45 | 46 | 47 | 示例 demo 运行效果: 48 | ![result](result.png) 49 | 50 | -------------------------------------------------------------------------------- /plugin/resourcePlugin/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'groovy' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'java-gradle-plugin' 4 | apply plugin: 'maven-publish' 5 | 6 | dependencies { 7 | implementation gradleApi() 8 | implementation localGroovy() 9 | api "com.android.tools.build:gradle-api:$apgVersion" 10 | api "com.android.tools.build:gradle:$apgVersion" 11 | implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 12 | } 13 | 14 | version = "1.0.0" 15 | group = "com.github.MRwangqi" 16 | 17 | gradlePlugin { 18 | plugins { 19 | version { 20 | id = 'resourcePlugin' 21 | implementationClass = 'com.codelang.plugin.ResourcePlugin' 22 | } 23 | } 24 | } 25 | 26 | 27 | afterEvaluate { 28 | publishing { 29 | publications { 30 | maven(MavenPublication) { 31 | from components.java 32 | groupId = "com.github.MRwangqi" 33 | artifactId = "resourcePlugin" 34 | version = "1.0.0" 35 | } 36 | } 37 | 38 | repositories { 39 | maven { 40 | url = "../../build/Maven" 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /plugin/resourcePlugin/resourcePlugin.gradle: -------------------------------------------------------------------------------- 1 | project.extensions.getByName("android").applicationVariants.all { variant -> 2 | def mergeResourcesTask = variant.mergeResourcesProvider.get() 3 | def mergeAssetsTask = variant.mergeAssetsProvider.get() 4 | 5 | def resourceTask = project.task("DuplicateResource${variant.name.capitalize()}Check") 6 | resourceTask.doLast { 7 | def files = variant.allRawAndroidResources.files 8 | checkResLayout(project, files) 9 | checkResDrawable(files) 10 | checkAssets(mergeAssetsTask.getLibraries().files, mergeAssetsTask.sourceFolderInputs.files) 11 | } 12 | mergeResourcesTask.dependsOn(resourceTask) 13 | } 14 | 15 | 16 | def checkResLayout(Project project, Set files) { 17 | def hashMap = new HashMap() 18 | def duplicateLayout = new HashMap>() 19 | // todo 处理 layout 20 | files.each { file -> 21 | def layoutDir = file.listFiles().find { it.isDirectory() && it.name == "layout" } 22 | if (layoutDir != null) { 23 | layoutDir.listFiles().each { layout -> 24 | if (hashMap.containsKey(layout.name)) { 25 | def list = duplicateLayout[layout.name] 26 | if (list == null) { 27 | list = new ArrayList() 28 | list.add(hashMap[layout.name]) 29 | } 30 | list.add(layout.absolutePath) 31 | // 资源重复 32 | duplicateLayout[layout.name] = list 33 | } else { 34 | hashMap[layout.name] = layout.absolutePath 35 | } 36 | } 37 | } 38 | } 39 | 40 | if (!duplicateLayout.isEmpty()) { 41 | println() 42 | project.logger.error("-------- layout 资源重复----------") 43 | duplicateLayout.each { entry -> 44 | println(entry.key) 45 | entry.value.each { 46 | project.logger.error("----> " + it) 47 | } 48 | } 49 | } 50 | } 51 | 52 | def checkResDrawable(Set files) { 53 | // todo 处理 Drawable 54 | } 55 | 56 | def checkAssets(Set libraryFolder, Set sourceFolder) { 57 | // todo 处理 assets 58 | } -------------------------------------------------------------------------------- /plugin/resourcePlugin/result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MRwangqi/pluginDemo/aa7a2d0c8bcbcc8fcd8438ca273a468b7a4d4725/plugin/resourcePlugin/result.png -------------------------------------------------------------------------------- /plugin/settings.gradle: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | rootProject.name = "plugin" 8 | include ':checkPlugin' 9 | include ':uploadPlugin' 10 | include ':modulePlugin' 11 | include ':resourcePlugin' 12 | include ':permissionPlugin' 13 | include ':classAnalysis' 14 | -------------------------------------------------------------------------------- /plugin/uploadPlugin/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /plugin/uploadPlugin/README.md: -------------------------------------------------------------------------------- 1 | ## 一、配置 maven 镜像源和依赖 2 | ```java 3 | buildscript { 4 | repositories { 5 | ... 6 | // 配上 maven 源 7 | maven{ 8 | url "https://raw.githubusercontent.com/MRwangqi/Maven/main" 9 | } 10 | } 11 | dependencies { 12 | classpath "com.android.tools.build:gradle:7.0.4" 13 | // 依赖 upload 插件 14 | classpath "com.github.MRwangqi:uploadPlugin:1.0.0" 15 | } 16 | } 17 | ``` 18 | 19 | ## 二、依赖插件 20 | 21 | 目前插件支持两种方式上传: 22 | 23 | ### 1、上传到 github 24 | 25 | 在模块工程的 build.gradle 中依赖插件: 26 | 27 | ```java 28 | plugins { 29 | id 'com.android.library' 30 | // 配置上传到 github 31 | id 'uploadGithub' 32 | } 33 | 34 | upload { 35 | // 必选 36 | groupId = "" 37 | // 必选 38 | artifactId = "" 39 | // 必选 40 | version = "" 41 | } 42 | ``` 43 | 44 | 插件在运行时会读取 local.properties 中 github 的内容 45 | 46 | > local.properties 配置 47 | ``` 48 | # github 仓库链接(可选,如果不配置的话则发布到 project 下的 build/repo 目录) 49 | # XXX 为填充区域 50 | githubURL = XXX 51 | # github 仓库分支(可选,如果不配置的话则以仓库当前配置的分支为准) 52 | githubBranch = XXX 53 | ``` 54 | 55 | 56 | ### 2、上传到 maven 57 | 58 | 在模块工程的 build.gradle 中依赖插件: 59 | 60 | ```java 61 | plugins { 62 | id 'com.android.library' 63 | // 配置上传到 maven nexus 64 | id 'uploadMaven' 65 | } 66 | 67 | upload { 68 | // 必选 69 | groupId = "" 70 | // 必选 71 | artifactId = "" 72 | // 必选 73 | version = "" 74 | } 75 | ``` 76 | 77 | 插件在运行时会读取 local.properties 中 nexus 的内容 78 | 79 | > local.properties 配置 80 | 81 | ``` 82 | # nexus 地址 (可选,如果不配置的话则发布到 project 下的 build/repo 目录) 83 | # XXX 为填充区域 84 | nexusURL = XXX 85 | nexusName = XXX 86 | nexusPsw = XXX 87 | ``` 88 | 89 | 90 | uploadMaven 也支持通过命令参数来输入: 91 | > ./gradlew :android-lib:upload -Pname=${nexusName} -Ppsw=${nexusPsw} -Purl=${nexusURL} 92 | 93 | 例如要打包 android-lib 模块,用户名和密码都是 admin,则命令行为: 94 | > ./gradlew :android-lib:upload -Pname=admin -Ppsw=admin -Purl=http://localhost:8081/repository/android/ 95 | 96 | 97 | 98 | 通用配置: 99 | ``` 100 | upload { 101 | // 模块下的依赖是否打入 pom : (可选,默认会打入) 102 | hasPomDepend = true 103 | // 模块是否打入 source 源码: (可选,默认会打入) 104 | sourceJar = true 105 | } 106 | ``` 107 | 108 | -------------------------------------------------------------------------------- /plugin/uploadPlugin/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'groovy' 2 | apply plugin: 'kotlin' 3 | apply plugin: 'java-gradle-plugin' 4 | apply plugin: 'maven-publish' 5 | 6 | version = "2.0.0" 7 | group = "com.github.MRwangqi" 8 | 9 | 10 | dependencies { 11 | implementation gradleApi() 12 | implementation localGroovy() 13 | api "com.android.tools.build:gradle-api:$apgVersion" 14 | api "com.android.tools.build:gradle:$apgVersion" 15 | implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 16 | implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '6.1.0.202203080745-r' 17 | 18 | } 19 | 20 | gradlePlugin { 21 | plugins { 22 | nexus { 23 | id = 'uploadMaven' 24 | implementationClass = 'com.codelang.upload.UploadMaven' 25 | } 26 | github { 27 | id = 'uploadGithub' 28 | implementationClass = 'com.codelang.upload.UploadGithub' 29 | } 30 | } 31 | } 32 | 33 | 34 | afterEvaluate { 35 | publishing { 36 | publications { 37 | maven(MavenPublication) { 38 | from components.java 39 | groupId = "com.github.MRwangqi" 40 | artifactId = "uploadPlugin" 41 | version = "1.0.0" 42 | } 43 | } 44 | 45 | repositories { 46 | maven { 47 | url = "../../build/Maven" 48 | } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /plugin/uploadPlugin/src/main/java/com/codelang/upload/UploadMaven.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.upload 2 | 3 | 4 | import com.codelang.upload.config.UploadConfig 5 | import org.gradle.api.Project 6 | import java.net.URI 7 | import java.util.* 8 | 9 | class UploadMaven : BaseUploadPlugin() { 10 | 11 | private val PARAMS_URL = "url" 12 | private val PARAM_NAME = "name" 13 | private val PARAM_PSW = "psw" 14 | 15 | override fun isSupportUpload(uploadConfig: UploadConfig, project: Project): Boolean { 16 | val properties = Properties() 17 | properties.load(project.rootProject.file("local.properties").inputStream()) 18 | 19 | val nexusUrl = properties.getProperty("nexusURL")?:"" 20 | if (nexusUrl.isNotEmpty()){ 21 | uploadConfig.nexusURL = nexusUrl 22 | } 23 | val nexusName = properties.getProperty("nexusName")?:"" 24 | if (nexusUrl.isNotEmpty()){ 25 | uploadConfig.nexusName = nexusName 26 | } 27 | 28 | val nexusPsw = properties.getProperty("nexusPsw")?:"" 29 | if (nexusUrl.isNotEmpty()){ 30 | uploadConfig.nexusPsw = nexusPsw 31 | } 32 | 33 | 34 | // ./gradlew upload -Pname=admin -Ppsw=admin -Purl=http://localhost:8081/repository/android/ 35 | val params = project.gradle.startParameter.projectProperties 36 | 37 | if (params.containsKey(PARAM_NAME)) { 38 | uploadConfig.nexusName = params[PARAM_NAME] ?: "" 39 | } 40 | if (params.containsKey(PARAM_PSW)) { 41 | uploadConfig.nexusPsw = params[PARAM_PSW] ?: "" 42 | } 43 | if (params.containsKey(PARAMS_URL)) { 44 | uploadConfig.nexusURL = params[PARAMS_URL] ?: "" 45 | } 46 | 47 | if (uploadConfig.nexusURL.isEmpty() || 48 | uploadConfig.nexusName.isEmpty() || 49 | uploadConfig.nexusPsw.isEmpty()) { 50 | 51 | println("upload 配置的 nexus 有空值:") 52 | println("nexusURL=${uploadConfig.nexusURL}") 53 | println("nexusName=${uploadConfig.nexusName}") 54 | println("nexusPsw=${uploadConfig.nexusPsw}") 55 | 56 | println("upload 采取降级发布到本地目录}") 57 | } 58 | return true 59 | } 60 | 61 | override fun isCredentials(uploadConfig: UploadConfig): Boolean { 62 | if (uploadConfig.nexusURL.startsWith("http") 63 | || uploadConfig.nexusURL.startsWith("https")) { 64 | return true 65 | } 66 | return false 67 | } 68 | 69 | override fun uploadComplete(uploadConfig: UploadConfig, mavenUrl: String, project: Project) { 70 | println(""" 71 | 已上传到仓库, maven 镜像源为: 72 | 73 | maven{ 74 | url "$mavenUrl" 75 | } 76 | 77 | 可添加依赖使用: 78 | 79 | implementation '${uploadConfig.groupId}:${uploadConfig.artifactId}:${uploadConfig.version}' 80 | """.trimIndent()) 81 | } 82 | } -------------------------------------------------------------------------------- /plugin/uploadPlugin/src/main/java/com/codelang/upload/config/UploadConfig.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.upload.config 2 | 3 | open class UploadConfig { 4 | var version: String = "" 5 | var artifactId: String = "" 6 | var groupId: String = "" 7 | var sourceJar: Boolean = true 8 | var hasPomDepend: Boolean = true 9 | 10 | 11 | // github 相关 12 | var githubURL: String = "" 13 | var githubBranch: String = "" 14 | 15 | // nexus 相关 16 | var nexusURL: String = "" 17 | var nexusName: String = "" 18 | var nexusPsw: String = "" 19 | 20 | 21 | override fun toString(): String { 22 | return "UploadConfig(version='$version', artifactId='$artifactId', groupId='$groupId', sourceJar=$sourceJar, githubURL='$githubURL', githubBranch='$githubBranch', hasPomDepend=$hasPomDepend, nexusURL='$nexusURL', nexusName='$nexusName', nexusPsw='$nexusPsw')" 23 | } 24 | 25 | 26 | } -------------------------------------------------------------------------------- /plugin/uploadPlugin/src/main/java/com/codelang/upload/task/SourceJarTask.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.upload.task 2 | 3 | import com.android.build.gradle.LibraryExtension 4 | import org.gradle.api.Project 5 | import org.gradle.api.Task 6 | import org.gradle.api.plugins.JavaPluginConvention 7 | import org.gradle.api.tasks.TaskProvider 8 | import org.gradle.api.tasks.bundling.Jar 9 | 10 | /** 11 | * @author wangqi 12 | * @since 2022/3/19. 13 | */ 14 | 15 | fun Project.emptySourcesJar(): Task = tasks.create("emptySourcesJar", Jar::class.java) 16 | 17 | fun Project.androidSourcesJar(): Task { 18 | return tasks.create("androidSourcesJar", Jar::class.java) { 19 | val androidExtension = extensions.getByType(LibraryExtension::class.java) 20 | 21 | val set = androidExtension.sourceSets.filter { 22 | it.name == "main" 23 | }.map { 24 | it.java.srcDirs 25 | }.toSet() 26 | 27 | it.classifier = "sources" 28 | it.version = "" 29 | it.from(set) 30 | } 31 | } 32 | 33 | fun Project.javaSourcesJar(): Task { 34 | return tasks.create("javaSourcesJar", Jar::class.java) { 35 | val javaPlugin = convention.getPlugin(JavaPluginConvention::class.java) 36 | 37 | val set = javaPlugin.sourceSets.filter { 38 | it.name == "main" 39 | }.map { 40 | it.java.srcDirs 41 | }.toSet() 42 | 43 | it.classifier = "sources" 44 | it.version = "" 45 | it.from(set) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /plugin/uploadPlugin/src/main/java/com/codelang/upload/utils/FileUtils.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.upload.utils 2 | 3 | import java.io.File 4 | 5 | /** 6 | * @author wangqi 7 | * @since 2022/3/19. 8 | */ 9 | object FileUtils { 10 | fun copyFolder(src: File, dest: File) { 11 | if (src.isDirectory) { 12 | if (!dest.exists()) { 13 | dest.mkdir(); 14 | } 15 | src.list()?.forEach { 16 | val srcFile = File(src, it) 17 | val destFile = File(dest, it) 18 | // 递归复制 19 | copyFolder(srcFile, destFile); 20 | } 21 | } else { 22 | src.runCatching { 23 | inputStream().use { input -> 24 | dest.apply { 25 | outputStream().use { output -> 26 | input.copyTo(output) 27 | } 28 | } 29 | } 30 | }.onFailure { 31 | println("error: " + it.message) 32 | } 33 | } 34 | } 35 | 36 | 37 | } -------------------------------------------------------------------------------- /plugin/uploadPlugin/src/main/java/com/codelang/upload/utils/Util.kt: -------------------------------------------------------------------------------- 1 | package com.codelang.upload.utils 2 | 3 | import com.android.tools.build.apkzlib.sign.SigningExtension 4 | import org.gradle.api.Project 5 | import org.gradle.api.publish.PublishingExtension 6 | 7 | object Util { 8 | 9 | fun isApplication(project: Project): Boolean { 10 | return project.plugins.hasPlugin("com.android.application") 11 | } 12 | 13 | fun isAndroidModule(project: Project): Boolean { 14 | return project.hasProperty("android") 15 | } 16 | 17 | //publishing 18 | fun publishingExtension(project: Project): PublishingExtension? { 19 | return project.extensions.findByType(PublishingExtension::class.java) 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | // repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 3 | repositories { 4 | google() 5 | mavenCentral() 6 | maven { url 'https://jitpack.io' } 7 | maven { 8 | allowInsecureProtocol = true 9 | url "http://localhost:8081/repository/android/" 10 | } 11 | maven{ 12 | url "https://raw.githubusercontent.com/MRwangqi/Maven/main" 13 | } 14 | } 15 | } 16 | rootProject.name = "pluginDemo" 17 | include ':app' 18 | include ':java-lib' 19 | 20 | includeBuild("./plugin") 21 | 22 | include ':android-lib2' 23 | include ':android-lib' 24 | 25 | 26 | --------------------------------------------------------------------------------