Skip to content

Commit

Permalink
Fix #3287: Introduce Kotlin script to extract license texts (#3450)
Browse files Browse the repository at this point in the history
* Generate maven_install.json

* Add fail_if_repin_required attribute

* Update rules_jvm_external version in versions.bzl and use fail_if_repin_required attribute in maven_install()

* Fix bazel lint error.

* Update code ownership for maven_install.json

* Fix #3290: Add support for generic regex pattern matching

* Apply review suggestions for proto location

* Delete main directory

* Implment script logic and tests

* CI setup part 1

* syntax fix in yaml file

* import nits in dummy file

* Use regex patterns from script in script test

* Make PR suggestions into effect

* Make PR suggestions into effect

* Make PR suggestions into effect

* Improve naming of script_assets variables

* Make PR suggestions into effect

* Create maven_dependencies_list.kts and complete the parsing of the maven_install.json

* Make PR suggestions

* Make PR suggestions

* Improve naming in script and add KDocs for data classes.

* Add EOF for all classes.

* Change data structure to store backup dependencies.

* Revamp testing approach

* nit fixes

* Add maven re-pin command.

* Add BUILD.bazel file and Test file for script.creatre-script-to-compile-list-of-maven-dependencies

* Fix test build error.

* Improve code.

* Make nit suggestions

* Try changing location of maven_install.json

* Convert .kts to .kt

* Save work.

* Rename data classes.

* Remove kscript.

* Fix lints.

* Apply review suggestions on PR

* Refactor PR as per feedback recieved

* Implement review suggestions

* Set different output_base for bazel query command

* nits

* Nit fixes

* nit fix

* Change maven_install_json attribute

* Move maven_install.json to third_party

* Remove maven_install code ownership from CODEOWNERS

* Save changes.

* remove class

* Fix errors

* Review suggestions part 1

* Implement review suggestions part 2

* Fix broken script

* nit fixes

* update static_checks

* add test to repository file

* nit fix

* nit fix

* Validate all Links.

* nit fix

* Implement review suggestions

* bazel files nit fix

* Introduce a library for the regex assets

* Change structure of the script.

* Make directory structure same as that of #3374

* diable ktlint max-line-length

* disable ktlint-max-line

* disable ktlint max-length

* save changes.

* commit

* nit fix

* Add bazel pipeline to app module

* save.

* save.

* save.

* save.

* save.

* save.

* nit fix

* fix broken script

* Fix bug of printing enum values in output.

* Fix bug of printing enum values in output.

* Apply review suggestions

* ktlint fix

* nit fix

* Remove script constants

* nit fix

* Make script to call out the dependencies and licenses for which manual work needs to be completed.

* add todo

* Complete first script

* Add first script to scripts package

* Remove unwanted files

* Remove extra files and fix formatting

* Fix lints.

* Remove unnecessary lines of code

* Add comments for proto

* Add test file.

* Fix lints.

* Add second script

* Remove unwanted dependencies.

* Add suggested changes.

* Add test file

* nit fixes

* Fix lint.

* add testOnly

* Add pipeline to print actual dependencies' names

* Fix nits

* Add suggested changes.

* Add suggested changes

* add function to write license texts.

* Update text proto

* Update textproto

* Update maven_dependencies.textproto

* Update Licenses writing function

* Write license name array

* Always force https over http

* Always force https over http

* Correct origin type

* Complete script

* Fix lints.

* Add support for escape characters.

* Fix nits

* Use common/BazelClient

* Fix lints

* Save progress

* create test_maven_install.json

* Add test cases

* Create function to add license

* Add more test cases

* Fix lints

* Correct typo

* Add one more test case

* Restructure script

* Break script in two parts

* Add DependencyListsProvider

* Add DependencyListsProvider

* correct query command

* Correct structure of the script

* Correct structure of the script

* Fix not suggestions

* Use

* Add test file for NetworkAndBazelUtilsImpl.kt

* Delete unwanted files

* Delete unwanted files

* Add library for GenerateLicenseTexts.kt

* Add suggested changes

* Add data classes to exemptions.textproto

* Remove commented out code

* Add KDocs for helper functions in GenerateLicenseTextsTest.kt

* Remove unused variables

* Delete unwanted proto file

* Use createCDATASection instead of manually constructing it

* Add suggested changes

* Add suggested changes

* Correct test case

* Fix nit

* Add changes as per the UI

* Fix script to preserve text format of licenses

* Remove extra lines of code

* Add KDoc

* Add suggested changes

* Omit version from the dependency names in xml

* Add suggested changes

* Add suggested changes

* Correct KDoc

* Correct file paths in exemptions file

* Revert unwanted chang.

* Refactor 'data_lib' to 'data'

* Add suggested changes

* Fix lints

* Correct deps in BUILD.bazel

* Correct deps in BUILD.bazel

* Nit fix

* Nit fix

* Nit fix

* Nit fix

* Use .map

Co-authored-by: Sparsh1212 <[email protected]>
  • Loading branch information
prayutsu and Sparsh1212 authored Aug 10, 2021
1 parent 3c09951 commit ee42f1d
Show file tree
Hide file tree
Showing 14 changed files with 1,048 additions and 11 deletions.
8 changes: 8 additions & 0 deletions scripts/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ kt_jvm_binary(
runtime_deps = ["//scripts/src/java/org/oppia/android/scripts/maven:generate_maven_dependencies_list_lib"],
)

kt_jvm_binary(
name = "retrieve_license_texts",
testonly = True,
data = MAVEN_ASSETS,
main_class = "org.oppia.android.scripts.maven.RetrieveLicenseTextsKt",
runtime_deps = ["//scripts/src/java/org/oppia/android/scripts/maven:retrieve_license_texts_lib"],
)

ACCESSIBILITY_LABEL_EXEMPTION_ASSETS = generate_accessibility_label_assets_list_from_text_protos(
name = "accessibility_label_exemption_assets",
accessibility_label_exemptions_name = ["accessibility_label_exemptions"],
Expand Down
8 changes: 5 additions & 3 deletions scripts/assets/test_file_exemptions.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,11 @@ exempted_file_path: "domain/src/main/java/org/oppia/android/domain/util/JsonAsse
exempted_file_path: "domain/src/test/java/org/oppia/android/domain/classify/InteractionObjectTestBuilder.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/common/CommandExecutor.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/common/CommandResult.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/maven/data/MavenListDependency.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/maven/data/MavenListDependencies.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/maven/data/MavenListDependencyTree.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/license/model/CopyrightLicense.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/license/model/Dependency.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/maven/model/MavenListDependency.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/maven/model/MavenListDependencies.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/maven/model/MavenListDependencyTree.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/maven/LicenseFetcher.kt"
exempted_file_path: "scripts/src/java/org/oppia/android/scripts/maven/LicenseFetcherImpl.kt"
exempted_file_path: "testing/src/main/java/org/oppia/android/testing/AccessibilityTestRule.kt"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Libraries corresponding to storing license details of the third-party dependencies.
"""

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")

kt_jvm_library(
name = "model",
testonly = True,
srcs = [
"CopyrightLicense.kt",
"Dependency.kt",
],
visibility = ["//scripts:oppia_script_library_visibility"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.oppia.android.scripts.license.model

/** Data class that stores the details related to a license. */
data class CopyrightLicense(
/** Name of the license. */
val licenseName: String,

/** Link of the license. */
val licenseLink: String,

/** License text corresponding to the license. */
val licenseText: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.oppia.android.scripts.license.model

/** Data class that stores the details related to a third-party dependency. */
data class Dependency(
/** Name of the third-party dependency. */
val name: String,

/** Version of the third-party dependency. */
val version: String,

/** List of licenses corresponding to the third-party dependency. */
val licenseList: List<CopyrightLicense>,
)
16 changes: 15 additions & 1 deletion scripts/src/java/org/oppia/android/scripts/maven/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,23 @@ kt_jvm_library(
deps = [
":license_fetcher",
"//scripts/src/java/org/oppia/android/scripts/common:bazel_client",
"//scripts/src/java/org/oppia/android/scripts/maven/data:data_lib",
"//scripts/src/java/org/oppia/android/scripts/maven/model",
"//scripts/src/java/org/oppia/android/scripts/proto:maven_dependencies_java_proto",
"//scripts/src/java/org/oppia/android/scripts/proto:maven_dependencies_java_proto_lite",
"//third_party:com_google_protobuf_protobuf-java",
],
)

kt_jvm_library(
name = "retrieve_license_texts_lib",
testonly = True,
srcs = ["RetrieveLicenseTexts.kt"],
visibility = ["//scripts:oppia_script_binary_visibility"],
deps = [
":license_fetcher",
"//scripts/src/java/org/oppia/android/scripts/license/model",
"//scripts/src/java/org/oppia/android/scripts/maven/model",
"//scripts/src/java/org/oppia/android/scripts/proto:maven_dependencies_java_proto",
"//scripts/src/java/org/oppia/android/scripts/proto:maven_dependencies_java_proto_lite",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import org.oppia.android.scripts.common.BazelClient
import org.oppia.android.scripts.common.CommandExecutor
import org.oppia.android.scripts.common.CommandExecutorImpl
import org.oppia.android.scripts.maven.data.MavenListDependency
import org.oppia.android.scripts.maven.data.MavenListDependencyTree
import org.oppia.android.scripts.maven.model.MavenListDependency
import org.oppia.android.scripts.maven.model.MavenListDependencyTree
import org.oppia.android.scripts.proto.License
import org.oppia.android.scripts.proto.MavenDependency
import org.oppia.android.scripts.proto.MavenDependencyList
Expand Down
Loading

0 comments on commit ee42f1d

Please sign in to comment.