16 Şubat 2023 Perşembe

Dependency Scopes

1. compile
Kendi kodumuz görebilir Açıklaması şöyle
Leaks into consumers' compile time?  yes
Leaks into consumers' runtime?     yes
Included in Artifact?     yes
2. runtime
Dependency paketlerini kendi kodumuz göremez Dolayısıyla kullanmayız. Açıklaması şöyle
Leaks into consumers' compile time?  no
Leaks into consumers' runtime?     yes
Included in Artifact?     yes
Örnek
Şöyle yaparız
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.28</version>
    <scope>runtime</scope>
</dependency>
3. test
Kendi kodumuz görebilir Açıklaması şöyle
Leaks into consumers' compile time?  no
Leaks into consumers' runtime?     no
Included in Artifact?     no
4. provided
Açıklaması şöyle
- Dependencies with this scope are required for compiling and running the application, but they are expected to be provided by the runtime environment.
- They are available on the classpath during the compile and test phases but are not packaged with the application.
5. system
Açıklaması şöyle
- Dependencies with this scope are similar to compile dependencies but are referenced using an explicit path on the local system.
- They are not available in any Maven repository.
Örnek
Şöyle yaparız
<scope>system</scope>
<systemPath>/path/to/dependency.jar</systemPath>
gradle implementation vs maven
Açıklaması şöyle
Q : What is the maven equivalent of implementation dependencies in gradle?
A : 
- Such dependency should have scope=compile when declared in your lib. This way it will be available during compilation of the lib.

- But it should have scope=runtime when declared in dependencyManagement section of other modules that depend on your lib. This way it won't be present in the classpath when compiling other modules.



Hiç yorum yok:

Yorum Gönder

Local Snapshot Kullanmak

Örnek Şöyle yaparız <repository> <id>snapshot-repository</id> <name>Maven2 Snapshot Repository</name> &l...