本文整理汇总了Java中org.eclipse.aether.artifact.Artifact.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java Artifact.getFile方法的具体用法?Java Artifact.getFile怎么用?Java Artifact.getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.aether.artifact.Artifact
的用法示例。
在下文中一共展示了Artifact.getFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveToTargetDir
import org.eclipse.aether.artifact.Artifact; //导入方法依赖的package包/类
/**
* move artifact to target directory, return the moved artifact file path
*
* @param targetDirectory
* @param artifact
*
* @return
*/
private Path moveToTargetDir(Path targetDirectory, Artifact artifact) {
final File artifactFile = artifact.getFile();
final String artifactFileName = artifactFile.getName();
final Path targetFile = targetDirectory.resolve(artifactFileName);
log.debug("copy {} to {}", artifactFileName, targetFile);
if (!targetDirectory.toFile().exists()) {
targetDirectory.toFile().mkdirs();
}
try {
Files.copy(artifactFile.toPath(), targetFile, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
final String message = String.format(
"dependency %s:%s:%s resolved but cannot be moved to target dir: %s",
artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion(),
e.getMessage()
);
throw new DependencyResolveException(message, e);
}
return targetFile;
}
示例2: resolveModel
import org.eclipse.aether.artifact.Artifact; //导入方法依赖的package包/类
@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
throws UnresolvableModelException {
Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "", "pom", version);
try {
ArtifactRequest request = new ArtifactRequest(pomArtifact, repositories, null);
pomArtifact = system.resolveArtifact(session, request).getArtifact();
} catch (org.eclipse.aether.resolution.ArtifactResolutionException ex) {
throw new UnresolvableModelException(ex.getMessage(), groupId, artifactId, version, ex);
}
File pomFile = pomArtifact.getFile();
return new FileModelSource(pomFile);
}
示例3: serialize
import org.eclipse.aether.artifact.Artifact; //导入方法依赖的package包/类
@Override
public void serialize(Artifact value, JsonGenerator generator, SerializerProvider provider) throws IOException {
generator.writeStartObject();
generator.writeStringField(GROUP_ID, value.getGroupId());
generator.writeStringField(ARTIFACT_ID, value.getArtifactId());
generator.writeStringField(CLASSIFIER, value.getClassifier());
generator.writeStringField(EXTENSION, value.getExtension());
generator.writeStringField(VERSION, value.getVersion());
if (value.getFile() != null) {
generator.writeStringField(FILE, value.getFile().getPath());
}
if (value.getProperties() != null) {
generator.writeFieldName(PROPERTIES);
generator.writeStartObject();
for (Map.Entry<String, String> entry : value.getProperties().entrySet()) {
generator.writeStringField(entry.getKey(), entry.getValue());
}
generator.writeEndObject();
}
generator.writeEndObject();
}
示例4: read
import org.eclipse.aether.artifact.Artifact; //导入方法依赖的package包/类
@Override
public Page<Artifact, Artifact> read()
throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
MDC.remove(PATIENT);
Page<Artifact, Artifact> page = super.read();
while (page != null) {
Artifact patient = page.getKey().get();
if (patient.getFile() == null) {
LOGGER.info("Skip {} as it is not fetched", patient);
page = super.read();
continue;
}
if (!patient.getExtension().equals("jar")) {
LOGGER.info("Skip {} as it is not packaged as jar", patient);
page = super.read();
continue;
}
if (patient.isSnapshot()) {
LOGGER.info("Skip {} as it is snapshot", patient);
page = super.read();
continue;
}
LOGGER.info("Processing {}...", patient);
MDC.put(PATIENT, patient.toString());
return page;
}
return null;
}
示例5: visitEnter
import org.eclipse.aether.artifact.Artifact; //导入方法依赖的package包/类
public boolean visitEnter(final DependencyNode node) {
final Artifact artifact = node.getArtifact();
final File artifact_file = artifact.getFile();
return files.add(artifact_file);
}
示例6: isOsgiReady
import org.eclipse.aether.artifact.Artifact; //导入方法依赖的package包/类
private boolean isOsgiReady(Artifact artifact) throws Exception {
JarFile jar = new JarFile(artifact.getFile());
Attributes attrs = jar.getManifest().getMainAttributes();
return attrs.getValue("Bundle-SymbolicName") != null &&
attrs.getValue("Bundle-Version") != null;
}