@Documented @Target(value={}) @Retention(value=RUNTIME) @MirroredAnnotation public @interface Dependency
value() is the main descriptor used for the dependency;
for Dependency.DependencyType.RELATIVE and Dependency.DependencyType.ABSOLUTE,
artifactId() is where you will specify the filename you wish to locate.
When using Dependency.DependencyType.MAVEN, you will specify all three fields
as a normal dependency, value() is the artifactId,
while groupId() and version() are exactly what you expect.
Any property ${keys} found in any of the annotation values will be replaced
with whatever X_Properties.getProperty(String, String) returns
(if there is no property set, you will get "keys" as the value for ${keys}).
The PropertiesService defaults to using System.properties, though you are free
to inject your own property provider.
Note that Dependency.DependencyType.RELATIVE will check groupId() for a value
to use as the base of the relative uri; special values like DIR_TEMP,
DIR_BIN, DIR_GEN or DIR_LAUNCH
can be used as groupId() to specify where the resource must be found.
Providing no groupId() when using a Dependency.DependencyType.RELATIVE Dependency
will case all of the special dirs to be searched in the following order:
Note that changing the version() will cause the default compilers
to discard the classloader / existing runtime environment.
| Modifier and Type | Fields and Description |
|---|---|
static String |
DIR_BIN
The bin directory; whatever directory we can ascertain that the
Dependency
was launched from. |
static String |
DIR_GEN
The gen directory; must be set as a system property (or in whatever PropertyService
is used by X_Properties).
|
static String |
DIR_LAUNCH
The directory in which the current process was launched, new File(".")
|
static String |
DIR_SOURCE
The bin directory; whatever directory we can ascertain that the
Dependency
was launched from. |
static String |
DIR_TARGET
The gen directory; must be set as a system property (or in whatever PropertyService
is used by X_Properties).
|
static String |
DIR_TEMP
The temporary directory; default is OS-temp directory (/tmp)
|
static String |
DIR_WAR
The war directory; must be set as a system property (or in whatever PropertyService
is used by X_Properties).
|
| Modifier and Type | Required Element and Description |
|---|---|
String |
value |
| Modifier and Type | Optional Element and Description |
|---|---|
String |
classifier |
Dependency.DependencyType |
dependencyType |
String |
groupId |
String |
version |
public static final String DIR_TEMP
public static final String DIR_LAUNCH
public static final String DIR_BIN
Dependency
was launched from.
try {
return getClassloader().findResource(toClassLocation(Dependency.class.getName()));
} catch (Exception e) {
return Dependency.class.getProtectionDomain().getCodesource().getLocation();
}public static final String DIR_SOURCE
Dependency
was launched from.
try {
return getClassloader().findResource(toJavaLocation(Dependency.class.getName()));
// toJavaLocation = name.replace(packageName, packageName.replace('.', '/')
// + getSimpleName.split("$")[0] + ".java"
} catch (Exception e) {
return Dependency.class.getProtectionDomain().getCodesource().getLocation();
}public static final String DIR_GEN
public static final String DIR_TARGET
public static final String DIR_WAR
public abstract String value
public abstract String groupId
public abstract String version
public abstract String classifier
public abstract Dependency.DependencyType dependencyType
Copyright © December 07, 2012–2015 The Internet Party. All rights reserved.