Как отфильтровать определенную часть команды ./gradlew project: dependencies? (версия 2) - PullRequest
1 голос
/ 11 декабря 2019

Я отправил Как отфильтровать определенную часть проекта ./gradlew: команда зависимостей? некоторое время назад и реализовал принятый ответ. Однако, похоже, что он дает мне неверную информацию.

У меня есть следующее (упрощенное) build.gradle file

dependencies {
    implementation("com.myco.security:security-service-client:1.0.199")
}

Когда я запускаю команду

$ ./gradlew :project:dependencies | tee deps.txt

Я видел следующее в файле deps.txt, сокращенно отображающем только нужный мне артефакт.

compileClasspath - Compile classpath for source set 'main'.
+--- com.myco.security:security-service-client:1.0.199 -> 1.0.148
+--- com.myco.security:security-service-client:1.0.148 (*)
default - Configuration for default artifacts.
+--- com.myco.security:security-service-client:1.0.199 -> 1.0.148
+--- com.myco.security:security-service-client:1.0.148 (*)
+--- com.myco.security:security-service-client:1.0.148 (*)
implementation - Implementation only dependencies for source set 'main'. (n)
+--- com.myco.security:security-service-client:1.0.199 (n)
+--- com.myco.security:security-service-client:1.0.148 (n)
runtimeClasspath - Runtime classpath of source set 'main'.
+--- com.myco.security:security-service-client:1.0.199 -> 1.0.148
testCompileClasspath - Compile classpath for source set 'test'.
+--- com.myco.security:security-service-client:1.0.199 -> 1.0.148
+--- com.myco.security:security-service-client:1.0.148 (*)
testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- com.myco.security:security-service-client:1.0.199 -> 1.0.148
+--- com.myco.security:security-service-client:1.0.148 (*)

IOW, зависимость в моем файле build.gradle появляется несколько раз. Теперь, если я применю ответ в своем исходном связанном посте, я получу

com.myco.security:security-service-client:1.0.199
com.myco.security:security-service-client:1.0.148

в качестве артефакта, а не просто следующее, что я и хочу сопоставить с зависимостью в моем файле build.gradle.

com.myco.security:security-service-client:1.0.199

Как мне улучшить команду awk в моем связанном посте? IOW

cat deps.txt | awk '/^\+.*com\.myco/ && !seen[$2]++{print $2}' | some_other_cmd

Должен только дать мне

com.myco.security:security-service-client:1.0.199
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...