本文整理了Java中org.apache.maven.artifact.Artifact.getFile()
方法的一些代码示例,展示了Artifact.getFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Artifact.getFile()
方法的具体详情如下:
包路径:org.apache.maven.artifact.Artifact
类名称:Artifact
方法名:getFile
暂无
代码示例来源:origin: apache/maven
private boolean hasFile( Artifact artifact )
{
return artifact != null && artifact.getFile() != null && artifact.getFile().exists();
}
代码示例来源:origin: apache/maven
private void addArtifactPath( Artifact artifact, List<String> classpath )
{
File file = artifact.getFile();
if ( file != null )
{
classpath.add( file.getPath() );
}
}
代码示例来源:origin: simpligility/android-maven-plugin
public File getJarFileForApk( Artifact artifact )
{
final String fileName = artifact.getFile().getName();
final String modifiedFileName = fileName.substring( 0, fileName.lastIndexOf( "." ) ) + ".jar";
return new File( artifact.getFile().getParentFile(), modifiedFileName );
}
代码示例来源:origin: simpligility/android-maven-plugin
libraryJars.add( createProguardInput( rtJar.getPath() ) );
if ( jsseJar != null )
libraryJars.add( createProguardInput( jsseJar.getPath() ) );
if ( jceJar != null )
libraryJars.add( createProguardInput( jceJar.getPath() ) );
if ( artifact.getArtifactId().equals( "android" ) && parsedIncludeJdkLibs )
libraryJars.add(
createProguardInput( artifact.getFile().getAbsolutePath(), ANDROID_LIBRARY_EXCLUDED_FILTER )
);
libraryJars.add( createProguardInput( artifact.getFile().getAbsolutePath() ) );
libraryJars.add( createProguardInput( artifact.getFile().getAbsolutePath() ) );
代码示例来源:origin: vipshop/Saturn
@SuppressWarnings({ "unchecked" })
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (!CommonUtils.initSaturnHome())
throw new MojoExecutionException("The ${user.home}/.saturn/caches is not exists");
Log log = getLog();
MavenProject project = (MavenProject) getPluginContext().get("project");
String version = getSaturnVersion(project);
log.info("Packing the saturn job into a zip file: version:" + version);
List<File> runtimeLibFiles = new ArrayList<File>();
List<Artifact> runtimeArtifacts = project.getRuntimeArtifacts();
for (Artifact artifact : runtimeArtifacts) {
runtimeLibFiles.add(artifact.getFile());
}
runtimeLibFiles.add(new File(project.getBuild().getDirectory(),
project.getBuild().getFinalName() + "." + project.getPackaging()));
File zipFile = new File(project.getBuild().getDirectory(),
project.getArtifactId() + "-" + project.getVersion() + "-" + "app.zip");
try {
CommonUtils.zip(runtimeLibFiles, null, zipFile);
} catch (Exception e) {
e.printStackTrace();
throw new MojoExecutionException("zip " + zipFile + " failed", e);
}
projectHelper.attachArtifact(project, "zip", "executor", zipFile);
}
代码示例来源:origin: simpligility/android-maven-plugin
if ( projectOutputDirectory.exists() || !getJack().isEnabled() )
computeDuplicateFiles( artifact.getFile() );
getLog().warn( "Cannot compute duplicates files from " + artifact.getFile().getAbsolutePath(), e );
jarFiles.add( artifact.getFile() );
final File innerJar = new File( jarFile, filename );
getLog().debug( "Adding resources from innerJar : " + innerJar );
apkBuilder.addResourcesFromJar( innerJar );
代码示例来源:origin: apache/karaf
private Map<String,String> configureTranslatedUrls() {
Map<String, String> urls = new HashMap<>();
List<Artifact> artifacts = new ArrayList<>(project.getAttachedArtifacts());
artifacts.add(project.getArtifact());
for (Artifact artifact : artifacts) {
if (artifact.getFile() != null && artifact.getFile().exists()) {
String mvnUrl = artifactToMvn(artifact);
urls.put(mvnUrl, artifact.getFile().toURI().toString());
}
}
urls.putAll(translatedUrls);
return urls;
}
代码示例来源:origin: fabric8io/docker-maven-plugin
private File ensureThatArtifactFileIsSet(MavenProject project) {
Artifact artifact = project.getArtifact();
if (artifact == null) {
return null;
}
File oldFile = artifact.getFile();
if (oldFile != null) {
return oldFile;
}
Build build = project.getBuild();
if (build == null) {
return null;
}
String finalName = build.getFinalName();
String target = build.getDirectory();
if (finalName == null || target == null) {
return null;
}
File artifactFile = new File(target, finalName + "." + project.getPackaging());
if (artifactFile.exists() && artifactFile.isFile()) {
setArtifactFile(project, artifactFile);
}
return null;
}
代码示例来源:origin: jooby-project/jooby
appcp.add(new File(buildOutputDirectory));
if (!"pom".equals(artifact.getType())) {
appcp.add(new File(artifact.getFile().getAbsolutePath()));
watchDirs.add(mavenProject.getBasedir());
watchDirs.addAll(refbasedir);
if (this.watchDirs != null) {
this.watchDirs.forEach(f -> watchDirs.add(new File(f)));
cmds.add(runapp);
代码示例来源:origin: apache/maven
public CacheKey( Artifact artifact, boolean resolveManagedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
{
File file = artifact.getFile();
this.artifact = ArtifactUtils.copyArtifact( artifact );
if ( "pom".equals( artifact.getType() ) && file != null )
{
pomHash = file.getPath().hashCode() + file.lastModified();
}
else
{
pomHash = 0;
}
this.resolveManagedVersions = resolveManagedVersions;
this.repositories.add( localRepository );
this.repositories.addAll( remoteRepositories );
int hash = 17;
hash = hash * 31 + artifactHashCode( artifact );
hash = hash * 31 + ( resolveManagedVersions ? 1 : 2 );
hash = hash * 31 + repositoriesHashCode( repositories );
this.hashCode = hash;
}
代码示例来源:origin: net.jangaroo/jangaroo-maven-plugin
/**
* Unpack the artifact and add the extraction path to the list of packagePaths, return the extraction path.
* If a pkg file is present as a sibling file of the jar file, it is preferred, otherwise the jar file is used.
*/
File unpackPkg(Artifact artifact, File remotePackagesDir) throws MojoExecutionException {
File jarFile = artifact.getFile();
String targetDirName = String.format("%s__%s__%s", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
File targetDir = new File(remotePackagesDir, targetDirName);
unpackPkg(jarFile.exists() ? jarFile : jarFile, artifact, targetDir);
return targetDir;
}
代码示例来源:origin: apache/maven
File getTouchfile( Artifact artifact )
{
StringBuilder sb = new StringBuilder( 128 );
sb.append( artifact.getArtifactId() );
sb.append( '-' ).append( artifact.getBaseVersion() );
if ( artifact.getClassifier() != null )
{
sb.append( '-' ).append( artifact.getClassifier() );
}
sb.append( '.' ).append( artifact.getType() ).append( LAST_UPDATE_TAG );
return new File( artifact.getFile().getParentFile(), sb.toString() );
}
代码示例来源:origin: konsoletyper/teavm
} else {
artifacts.add(repositorySystem.createArtifactWithClassifier(artifact.getGroupId(),
artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), "sources"));
ArtifactResolutionResult result = repositorySystem.resolve(request);
for (Artifact resolvedArtifact : result.getArtifacts()) {
if (resolvedArtifact.getFile() != null) {
File file = resolvedArtifact.getFile();
if (!file.isDirectory()) {
builder.addSourcesJar(file.getAbsolutePath());
builder.addSourcesDirectory(new File(sourceRoot).getAbsolutePath());
代码示例来源:origin: org.apache.maven/maven-project
String refId = getProjectReferenceId( pluginArtifact.getGroupId(), pluginArtifact.getArtifactId(), pluginArtifact.getVersion() );
MavenProject ref = (MavenProject) getProjectReferences().get( refId );
if ( ref != null )
if ( ref.getArtifact().getFile() != null && ref.getArtifact().getFile().exists() )
if ( attached != null )
if ( attached.getFile() != null && attached.getFile().exists() )
代码示例来源:origin: hcoles/pitest
public ReportOptions convert() {
final List<String> classPath = new ArrayList<>();
try {
classPath.addAll(this.mojo.getProject().getTestClasspathElements());
} catch (final DependencyResolutionRequiredException e1) {
this.log.info(e1);
}
addOwnDependenciesToClassPath(classPath);
classPath.addAll(this.mojo.getAdditionalClasspathElements());
for (Object artifact : this.mojo.getProject().getArtifacts()) {
final Artifact dependency = (Artifact) artifact;
if (this.mojo.getClasspathDependencyExcludes().contains(
dependency.getGroupId() + ":" + dependency.getArtifactId())) {
classPath.remove(dependency.getFile().getPath());
}
}
ReportOptions option = parseReportOptions(classPath);
return updateFromSurefire(option);
}
代码示例来源:origin: simpligility/android-maven-plugin
for ( Artifact artifact : pluginDependencies )
getLog().debug( "pluginArtifact: " + artifact.getFile() );
if ( ( "proguard".equals( artifact.getArtifactId() ) ) || ( "proguard-base"
.equals( artifact.getArtifactId() ) ) )
getLog().debug( "proguardArtifact: " + proguardArtifact.getFile() );
return proguardArtifact.getFile().getAbsoluteFile().toString();
代码示例来源:origin: jooby-project/jooby
private List<URL> jars(final Iterable<Artifact> artifacts) throws MalformedURLException {
List<URL> result = new ArrayList<URL>();
for (Artifact artifact : artifacts) {
if (!"pom".equals(artifact.getType())) {
result.add(artifact.getFile().toURI().toURL());
}
}
return result;
}
代码示例来源:origin: apache/maven
plugin.setArtifactId( extension.getArtifactId() );
plugin.setVersion( extension.getVersion() );
extensionPlugins.add( plugin );
extensionPlugins.add( plugin );
final List<Artifact> artifacts = recordRealm.getArtifacts();
extensionRealms.add( extensionRealm );
if ( extensionDescriptor != null )
if ( !plugin.isExtensions() && artifacts.size() == 2 && artifacts.get( 0 ).getFile() != null
&& "plexus-utils".equals( artifacts.get( 1 ).getArtifactId() ) )
代码示例来源:origin: geotools/geotools
try {
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
urls.add( artifact.getFile().toURI().toURL() );
urls.add( new File(project.getBuild().getOutputDirectory()).toURI().toURL() );
代码示例来源:origin: geotools/geotools
if ( !schemaSourceDirectory.exists() ) {
getLog().error( schemaSourceDirectory.getAbsolutePath() + " does not exist" );
return null;
if ( !schemaLocation.exists() ) {
artifacts.add(
artifactFactory.createArtifact(
"org.geotools", "gt2-xml-gml2", "2.7-SNAPSHOT", "compile", "jar"
artifacts.add(
artifactFactory.createArtifact(
"org.geotools", "gt2-xml-gml3", "2.7-SNAPSHOT", "compile", "jar"
artifacts.add(
artifactFactory.createArtifact(
"org.geotools", "gt2-xml-filter", "2.7-SNAPSHOT", "compile", "jar"
urls.add( resolvedArtifact.getFile().toURI().toURL() );
File file = new File( schemaLocation );
if ( file.exists() ) {
getLog().debug( "Resolving " + schemaLocation + " to " + schemaLocation );
String fileName = new File( schemaLocation ).getName();
内容来源于网络,如有侵权,请联系作者删除!