當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。