1 Temmuz 2020 Çarşamba

jdeps komutu - Dependency Scan

Giriş
Açıklaması şöyle.
jdeps is a command-line tool that performs static analysis of your application's dependencies and libraries by accepting *.class files or *.jar as input. Starting with Java SE 8, it comes bundled with the JDK.
--jdk-internals seçeneği
Açıklaması şöyle.
...it will tell you which internal JDK API each of your classes depends on. This is a very important point because the internal API doesn't guarantee that it won't change in future versions of Java.
 --print-module-deps seçeneği
Örnek
Şöyle yaparız
unzip ./greetings/build/libs/greetings.jar -d temp

jdeps \
  --print-module-deps \
  --ignore-missing-deps \
  --recursive \
  --multi-release 17 \
  --class-path="./temp/BOOT-INF/lib/*" \
  --module-path="./temp/BOOT-INF/lib/*" \
  ./greetings/build/libs/greetings.jar

# The output will look like following
# java.base,java.compiler,java.desktop,java.instrument,java.management, # java.naming,java.prefs,java.rmi,java.scripting,java.security.jgss, # java.sql,jdk.httpserver,jdk.jfr,jdk.unsupported

rm -rf temp
Açıklaması şöyle
As you can see, we first extract the application jar file to a temporary directory before running the jdeps command with few configuration options. Finally, we remove the temporary directory.

Note: jdeps will not be able to print required modules used by Reflection. For example, if application contains spring security, we need to add jdk.crypto.ec and jdk.crypto.cryptoki module manually.


Hiç yorum yok:

Yorum Gönder