当前位置: 首页>>代码示例>>Java>>正文


Java Artifact.getFile方法代码示例

本文整理汇总了Java中org.apache.maven.artifact.Artifact.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java Artifact.getFile方法的具体用法?Java Artifact.getFile怎么用?Java Artifact.getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.artifact.Artifact的用法示例。


在下文中一共展示了Artifact.getFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCompileCPI

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private ClassPathImplementation createCompileCPI(MavenProject project, File binary) {
    List<PathResourceImplementation> items = new ArrayList<PathResourceImplementation>();
    //according to jglick this could be posisble to leave out on compilation CP..
    items.add(ClassPathSupport.createResource(FileUtil.urlForArchiveOrDir(binary)));
    if (project != null) {
        for (Artifact s : project.getCompileArtifacts()) {
            File file = s.getFile();
            if (file == null) continue;
            URL u = FileUtil.urlForArchiveOrDir(file);
            if(u != null) {
                items.add(ClassPathSupport.createResource(u));
            } else {
                LOG.log(Level.FINE, "Could not retrieve URL for artifact file {0}", new Object[] {file}); // NOI18N
            }
        }
    }
    return ClassPathSupport.createClassPathImplementation(items);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:RepositoryMavenCPProvider.java

示例2: resolveArtifactSources

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private File resolveArtifactSources( Artifact artifact )
{
    DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
    coordinate.setGroupId( artifact.getGroupId() );
    coordinate.setArtifactId( artifact.getArtifactId() );
    coordinate.setVersion( artifact.getVersion() );
    coordinate.setExtension( "jar" );
    coordinate.setClassifier( "sources" );
    
    Artifact resolvedArtifact = null;
    try
    {
        resolvedArtifact =
            artifactResolver.resolveArtifact( session.getProjectBuildingRequest(), coordinate ).getArtifact();
    }
    catch ( ArtifactResolverException e )
    {
        getLog().warn( "Could not get sources for " + artifact );
    }

    if ( resolvedArtifact.isResolved() )
    {
        return resolvedArtifact.getFile();
    }
    return null;
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:27,代码来源:ShadeMojo.java

示例3: createContextAwareInstance

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
public @Override Action createContextAwareInstance(final Lookup context) {
    return new AbstractAction(BTN_Open_Project()) {
        public @Override void actionPerformed(ActionEvent e) {
            Set<Project> projects = new HashSet<Project>();
            for (Artifact art : context.lookupAll(Artifact.class)) {
                File f = art.getFile();
                if (f != null) {
                    Project p = FileOwnerQuery.getOwner(org.openide.util.Utilities.toURI(f));
                    if (p != null) {
                        projects.add(p);
                    }
                }
            }
            OpenProjects.getDefault().open(projects.toArray(new NbMavenProjectImpl[projects.size()]), false, true);
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DependencyNode.java

示例4: testDestFileOverwriteIfNewer

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
public void testDestFileOverwriteIfNewer()
    throws MojoExecutionException, IOException, ArtifactFilterException
{
    DestFileFilter filter = new DestFileFilter( outputFolder );

    fact.setCreateFiles( true );
    Artifact artifact = fact.getSnapshotArtifact();
    File artifactFile = artifact.getFile();
    artifactFile.setLastModified( artifactFile.lastModified() );
    filter.overWriteIfNewer = true;

    // should pass because the file doesn't exist yet.
    assertTrue( filter.isArtifactIncluded( artifact) );

    // create the file in the destination
    File destFile = createFile( artifact, false, false, false );

    // set the last modified timestamp to be older than the source
    destFile.setLastModified( artifactFile.lastModified() - 1000 );
    assertTrue( filter.isArtifactIncluded( artifact ) );

    // now set the last modified timestamp to be newer than the source
    destFile.setLastModified( artifactFile.lastModified() + 1000 );

    assertFalse( filter.isArtifactIncluded( artifact ) );
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:27,代码来源:TestDestFileFilter.java

示例5: makeBundle

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private boolean makeBundle(Artifact artifact, File targetFile) {
	Properties properties = new Properties();
	properties.put("Bundle-SymbolicName", artifact.getArtifactId());
	properties.put("Bundle-Version", Version.semantic(artifact.getVersion()));
	properties.put("Original-Version", artifact.getVersion());

	try (FileInputStream fileStream = new FileInputStream(artifact.getFile());
			InputStream bndStream = BndUtils.createBundle(fileStream, properties, artifact.getFile().getName(),
					OverwriteMode.FULL);
			OutputStream outStream = new FileOutputStream(targetFile);) {

		byte[] buffer = new byte[8 * 1024];
		int bytesRead;
		while ((bytesRead = bndStream.read(buffer)) != -1) {
			outStream.write(buffer, 0, bytesRead);
		}

		if (logger.isDebugEnabled()) {
			logger.debug("'{}' wrapped in module '{}'", artifact.getFile(), targetFile);
		} else if (Flag.verbose()) {
			logger.info("'{}' wrapped in module '{}'", artifact.getFile(), targetFile);
		}
		return true;

	} catch (IOException e) {
		logger.warn("Failed to convert '{}' to module ", artifact, e);
		return false;
	}
}
 
开发者ID:commsen,项目名称:EM,代码行数:30,代码来源:ExportMojo.java

示例6: isOSGiBundle

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
public boolean isOSGiBundle (Artifact artifact) {
	try (JarFile jarFile = new JarFile(artifact.getFile()))  {
		Manifest manifest = jarFile.getManifest();
		if (manifest == null) return false;
		return manifest.getMainAttributes().getValue("Bundle-SymbolicName") != null;
	} catch (IOException e) {
		logger.warn("Failed to check if " + artifact.getFile() + " is OSGi bundle!", e);
	}
	return false;
}
 
开发者ID:commsen,项目名称:EM,代码行数:11,代码来源:Dependencies.java

示例7: execute

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    Generator generator = new Generator();
    try {
        generator.parse(input);
    } catch (Exception e) {
        e.printStackTrace();
        throw new MojoExecutionException("Error during GCM parse stage", e);
    }

    final String[] gcVersion = {""};
    project.getPluginArtifacts().forEach(artifact -> {
        if (artifact.getGroupId().equals("com.datathings") && artifact.getArtifactId().equals("greycat-mavenplugin")) {
            gcVersion[0] = artifact.getVersion();
        }
    });
    final List<File> cps = new ArrayList<File>();
    if (project != null) {
        for (Artifact a : project.getArtifacts()) {
            File file = a.getFile();
            if (file != null) {
                if (file.isFile()) {
                    cps.add(file);
                }
            }
        }
    }
    generator.generate(packageName, pluginName, targetGen, targetGenJS, generateJava, generateJS, gcVersion[0], project.getVersion(), cps);
    project.addCompileSourceRoot(targetGen.getAbsolutePath());
}
 
开发者ID:datathings,项目名称:greycat,代码行数:31,代码来源:GeneratorPlugin.java

示例8: prepareClassLoader

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
protected final ClassLoader prepareClassLoader() throws MojoExecutionException {
    try {
        List<URL> theURLs = new ArrayList<>();
        StringBuilder theClassPath = new StringBuilder();
        for (Artifact artifact : project.getArtifacts()) {
            if (!isSupportedScope(artifact.getScope())) {
                continue;
            }
            File file = artifact.getFile();
            if (theClassPath.length() > 0) {
                theClassPath.append(':');
            }
            theClassPath.append(file.getPath());
            theURLs.add(file.toURI().toURL());
        }
        if (theClassPath.length() > 0) {
            theClassPath.append(':');
        }
        theClassPath.append(classFiles.getPath());
        theURLs.add(classFiles.toURI().toURL());

        return new URLClassLoader(theURLs.toArray(new URL[theURLs.size()]),
                this.getClass().getClassLoader());
    } catch (MalformedURLException e) {
        throw new MojoExecutionException("Cannot create classloader", e);
    }
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:28,代码来源:BytecoderMavenMojo.java

示例9: createExecuteCPI

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private ClassPathImplementation createExecuteCPI(MavenProject project, File binary) {
    List<PathResourceImplementation> items = new ArrayList<PathResourceImplementation>(); 
    items.add(ClassPathSupport.createResource(FileUtil.urlForArchiveOrDir(binary)));
    if (project != null) {
        for (Artifact s : project.getRuntimeArtifacts()) {
            if (s.getFile() == null) continue;
            items.add(ClassPathSupport.createResource(FileUtil.urlForArchiveOrDir(s.getFile())));
        }
    }
    return ClassPathSupport.createClassPathImplementation(items);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:RepositoryMavenCPProvider.java

示例10: addKnownOwners

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private void addKnownOwners(Set<Pair> resultset) {
    Set<Artifact> artifacts = project.getLookup().lookup(NbMavenProject.class).getMavenProject().getArtifacts();
    for (Artifact ar : artifacts) {
        File f = ar.getFile();
        if (f != null) {
            Project p = MavenFileOwnerQueryImpl.getInstance().getOwner(Utilities.toURI(f));
            if (p == project) {
                continue;
            }
            if (p != null) {
                resultset.add(new Pair(p, ar));
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:DependencyProviderImpl.java

示例11: addKnownOwners

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private void addKnownOwners(Set<Project> resultset) {
    List<Artifact> compileArtifacts = project.getLookup().lookup(NbMavenProject.class).getMavenProject().getCompileArtifacts();
    for (Artifact ar : compileArtifacts) {
        File f = ar.getFile();
        if (f != null) {
            Project p = MavenFileOwnerQueryImpl.getInstance().getOwner(Utilities.toURI(f));
            if (p != null) {
                resultset.add(p);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:SubprojectProviderImpl.java

示例12: addKnownOwners

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private void addKnownOwners(Set<Project> resultset) {
    Set<Artifact> artifacts = project.getLookup().lookup(NbMavenProject.class).getMavenProject().getArtifacts();
    for (Artifact ar : artifacts) {
        File f = ar.getFile();
        if (f != null) {
            Project p = MavenFileOwnerQueryImpl.getInstance().getOwner(Utilities.toURI(f));
            if (p == project) {
                continue;
            }
            if (p != null) {
                resultset.add(p);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:DependencyProviderImpl2.java

示例13: removeSpecificallyIncludedClasses

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
private void removeSpecificallyIncludedClasses( MavenProject project, List<SimpleFilter> simpleFilters )
    throws IOException
{
    // remove classes specifically included in filters
    Clazzpath checkCp = new Clazzpath();
    for ( Artifact dependency : project.getArtifacts() )
    {
        File jar = dependency.getFile();

        for ( SimpleFilter simpleFilter : simpleFilters )
        {
            if ( simpleFilter.canFilter( jar ) )
            {
                ClazzpathUnit depClazzpathUnit = addDependencyToClasspath( checkCp, dependency );
                if ( depClazzpathUnit != null )
                {
                    Set<Clazz> clazzes = depClazzpathUnit.getClazzes();
                    Iterator<Clazz> j = removable.iterator();
                    while ( j.hasNext() )
                    {
                        Clazz clazz = j.next();

                        if ( clazzes.contains( clazz ) //
                            && simpleFilter.isSpecificallyIncluded( clazz.getName().replace( '.', '/' ) ) )
                        {
                            log.info( clazz.getName() + " not removed because it was specifically included" );
                            j.remove();
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:35,代码来源:MinijarFilter.java

示例14: createPath

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
@Override
URI[] createPath() {
    List<URI> lst = new ArrayList<>();
    MavenProject mavenProject = getMavenProject().getOriginalMavenProject();
    //TODO we shall add the test class output as well. how?
    // according the current 2.1 sources this is almost the same as getCompileClasspath()
    //except for the fact that multiproject references are not redirected to their respective
    // output folders.. we lways retrieve stuff from local repo..
    List<Artifact> arts = mavenProject.getTestArtifacts();
    boolean broken = false;
    for (Artifact art : arts) {
        if (art.getFile() != null) {
            lst.add(Utilities.toURI(art.getFile()));
            broken |= !art.getFile().exists();
        } else { //NOPMD
            //null means dependencies were not resolved..
            broken = true;
        }
    }
    if(testScoped) {
        List<URI> cmplst = new ArrayList<>();
        broken |= CompileClassPathImpl.getCompileArtifacts(mavenProject, cmplst);
        lst.removeAll(cmplst);
    }
    if (incomplete != broken) {
        incomplete = broken;
        firePropertyChange(PROP_FLAGS, null, null);
    }
    if(addTestOutDir) {
        lst.add(0, Utilities.toURI(getMavenProject().getProjectWatcher().getOutputDirectory(true)));            
    }
    lst.add(0, Utilities.toURI(getMavenProject().getProjectWatcher().getOutputDirectory(false)));
    URI[] uris = new URI[lst.size()];
    uris = lst.toArray(uris);
    return uris;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:TestCompileClassPathImpl.java

示例15: normalizePath

import org.apache.maven.artifact.Artifact; //导入方法依赖的package包/类
static void normalizePath(Artifact a) {
    if (a != null) {
        File f = a.getFile();
        if (f != null) {
            a.setFile(FileUtil.normalizeFile(f));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:MavenEmbedder.java


注:本文中的org.apache.maven.artifact.Artifact.getFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。