當前位置: 首頁>>代碼示例>>Java>>正文


Java Artifact類代碼示例

本文整理匯總了Java中org.axway.grapes.commons.datamodel.Artifact的典型用法代碼示例。如果您正苦於以下問題:Java Artifact類的具體用法?Java Artifact怎麽用?Java Artifact使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Artifact類屬於org.axway.grapes.commons.datamodel包,在下文中一共展示了Artifact類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLicenses

import org.axway.grapes.commons.datamodel.Artifact; //導入依賴的package包/類
/**
 * Returns the license of a dependency
 *
 * @param dependency Dependency
 * @return String
 */
public String getLicenses(final Dependency dependency){
    final Artifact target = dependency.getTarget();
    final List<String> licensesList = target.getLicenses();

    final StringBuilder sb = new StringBuilder();

    if(licensesList != null){
        Collections.sort(licensesList);
        for(String license : licensesList){
            sb.append(license);
            sb.append( " " );
        }
    }

    return sb.toString();
}
 
開發者ID:Axway,項目名稱:grapes-jenkins-plugin,代碼行數:23,代碼來源:GrapesBuildAction.java

示例2: getGrapesArtifact

import org.axway.grapes.commons.datamodel.Artifact; //導入依賴的package包/類
/**
 * Generate Grapes Artifact from a maven pom file
 *
 * @param pomFile Model
 * @return Artifact
 */
public static Artifact getGrapesArtifact(final Model pomFile) {

    final Artifact artifact =  DataModelFactory.createArtifact(
            pomFile.getGroupId(),
            pomFile.getArtifactId(),
            pomFile.getVersion(),
            null,
            "pom",
            "xml");

    final Long artifactSize = FileUtils.getSize(pomFile.getPomFile());
    if(artifactSize != null){
        artifact.setSize(String.valueOf(artifactSize));
    }

    return  artifact;
}
 
開發者ID:Axway,項目名稱:grapes-maven-plugin,代碼行數:24,代碼來源:GrapesTranslator.java

示例3: generateModule

import org.axway.grapes.commons.datamodel.Artifact; //導入依賴的package包/類
@Test
public void generateModule(){
    final String mainArtifactGid = "org.axway.grapes.test";
    final String mainArtifactId = "mainArtifactId";
    final String moduleVersion = "1.1.2-3";

    final org.apache.maven.artifact.Artifact artifact = mock(org.apache.maven.artifact.Artifact.class);
    when(artifact.getGroupId()).thenReturn(mainArtifactGid);
    when(artifact.getArtifactId()).thenReturn(mainArtifactId);

    final MavenProject project = mock(MavenProject.class);
    when(project.getArtifact()).thenReturn(artifact);
    when(project.getVersion()).thenReturn(moduleVersion);

    final Module module = GrapesTranslator.getGrapesModule(project);
    assertEquals(mainArtifactGid + ":" + mainArtifactId, module.getName());
    assertEquals(moduleVersion, module.getVersion());
}
 
開發者ID:Axway,項目名稱:grapes-maven-plugin,代碼行數:19,代碼來源:GrapesTranslatorTest.java

示例4: getLastVersion

import org.axway.grapes.commons.datamodel.Artifact; //導入依賴的package包/類
/**
 * Returns the last version of a dependency
 *
 *
 * @param grapesClient
 * @param dependency Dependency
 * @return String
 */
public String getLastVersion(final GrapesClient grapesClient, final Dependency dependency){
    final Logger logger = LogManager.getLogManager().getLogger("hudson.WebAppMain");
    try{
        final Artifact target = dependency.getTarget();
        return grapesClient.getArtifactLastVersion(target.getGavc());
    } catch (GrapesCommunicationException e) {
        logger.info("Failed to get last version of : " + dependency.getTarget().getGavc());
    }
     return "";
}
 
開發者ID:Axway,項目名稱:grapes-jenkins-plugin,代碼行數:19,代碼來源:GrapesBuildAction.java

示例5: getGrapesDependency

import org.axway.grapes.commons.datamodel.Artifact; //導入依賴的package包/類
/**
 * Generate a Grapes dependency from a Maven dependency
 *
 * @param dependency Dependency
 * @return org.axway.grapes.commons.datamodel.Dependency
 * @throws MojoExecutionException
 */
public static final org.axway.grapes.commons.datamodel.Dependency getGrapesDependency(final org.apache.maven.artifact.Artifact dependency, final String scope) throws MojoExecutionException {
    try {

        final Artifact target = getGrapesArtifact(dependency);
        return DataModelFactory.createDependency(target, scope);

    } catch (UnsupportedScopeException e) {
        throw new MojoExecutionException("Failed to create the dependency" + dependency.toString() , e);
    }
}
 
開發者ID:Axway,項目名稱:grapes-maven-plugin,代碼行數:18,代碼來源:GrapesTranslator.java

示例6: generateDependency

import org.axway.grapes.commons.datamodel.Artifact; //導入依賴的package包/類
@Test
public void generateDependency() throws MojoExecutionException {
    final String groupId = "org.axway.grapes.test" ;
    final String artifactId = "artifactId" ;
    final String version = "1.0.0" ;
    final String classifier = "linux" ;
    final String type = "test-jar" ;
    final String extension = "jar" ;
    final String scope = "TEST" ;

    final DefaultArtifactHandler handler = new DefaultArtifactHandler();
    handler.setExtension(extension);

    final org.apache.maven.artifact.Artifact mavenArtifact = new DefaultArtifact(
            groupId,
            artifactId,
            version,
            "COMPILE",
            type,
            classifier ,
            handler);

    final Dependency dependency = GrapesTranslator.getGrapesDependency(mavenArtifact, scope);
    assertEquals(groupId, dependency.getTarget().getGroupId());
    assertEquals(artifactId, dependency.getTarget().getArtifactId());
    assertEquals(classifier, dependency.getTarget().getClassifier());
    assertEquals(version, dependency.getTarget().getVersion());
    assertEquals(type, dependency.getTarget().getType());
    assertEquals(extension, dependency.getTarget().getExtension());
    assertEquals(scope, dependency.getScope().toString());

}
 
開發者ID:Axway,項目名稱:grapes-maven-plugin,代碼行數:33,代碼來源:GrapesTranslatorTest.java

示例7: testSimpleProjectWithOneModuleOneArtifactAndOneLicense

import org.axway.grapes.commons.datamodel.Artifact; //導入依賴的package包/類
/**
 * @throws Exception
 */
public void testSimpleProjectWithOneModuleOneArtifactAndOneLicense() throws Exception {
    File pom = getTestFile( "src/test/resources/materials/simple-project/pom.xml" );
    assertNotNull( pom );
    assertTrue( pom.exists() );

    final GenerateMojo generateMojo = (GenerateMojo) lookupMojo( "generate", pom );
    final MavenProject simpleProject = (MavenProject) getVariableValueFromObject( generateMojo, "project" );

    /* Fake artifact resolution */
    final RepositorySystem repositorySystemMock = mock(RepositorySystem.class);
    final ArtifactResolutionResult result = mock(ArtifactResolutionResult.class);
    when(repositorySystemMock.resolve(any(ArtifactResolutionRequest.class))).thenReturn(result);
    when(result.isSuccess()).thenReturn(true);

    setVariableValueToObject(generateMojo, "repositorySystem", repositorySystemMock);
    /* End */

    // Runs Mojo on the project
    generateMojo.execute();

    // Get generated Grapes module
    final String serializedModule = FileUtils.read(new File(simpleProject.getBasedir(), "target/grapes/"+GrapesMavenPlugin.MODULE_JSON_FILE_NAME));
    final Module simpleProjectModule = JsonUtils.unserializeModule(serializedModule);

    // Checks
    assertEquals(simpleProject.getGroupId() + ":" + simpleProject.getArtifactId() , simpleProjectModule.getName());
    assertEquals(simpleProject.getVersion() , simpleProjectModule.getVersion());
    assertEquals(0 , simpleProjectModule.getSubmodules().size());
    assertEquals(2 , simpleProjectModule.getArtifacts().size());

    final Artifact grapesArtifact = simpleProjectModule.getArtifacts().iterator().next();
    assertEquals(simpleProject.getArtifact().getGroupId() , grapesArtifact.getGroupId());
    assertEquals(simpleProject.getArtifact().getArtifactId() , grapesArtifact.getArtifactId());
    assertEquals(simpleProject.getArtifact().getVersion() , grapesArtifact.getVersion());
    assertEquals(simpleProject.getLicenses().get(0).getName(), grapesArtifact.getLicenses().get(0));

}
 
開發者ID:Axway,項目名稱:grapes-maven-plugin,代碼行數:41,代碼來源:GenerateMojoTest.java

示例8: getModule

import org.axway.grapes.commons.datamodel.Artifact; //導入依賴的package包/類
/**
 * Turn a maven project (Maven data model) into a module (Grapes data model)
 *
 * @param project MavenProject
 * @return Module
 */
public Module getModule(final MavenProject project, final LicenseResolver licenseResolver, final ArtifactResolver artifactResolver) throws MojoExecutionException {

    final Module module = GrapesTranslator.getGrapesModule(project);
    final List<License> licenses = licenseResolver.resolve(project);

    /* Manage Artifacts */
    final Artifact mainArtifact = GrapesTranslator.getGrapesArtifact(project.getArtifact());
    addLicenses(mainArtifact, licenses);
    module.addArtifact(mainArtifact);

    // Get pom file if main artifact is not already a pom file
    if(!mainArtifact.getType().equals("pom")){
        final Artifact pomArtifact = GrapesTranslator.getGrapesArtifact(project.getModel());
        addLicenses(pomArtifact, licenses);
        module.addArtifact(pomArtifact);
    }

    for(int i = 0 ; i < project.getAttachedArtifacts().size() ; i++){
        artifactResolver.resolveArtifact(project, project.getAttachedArtifacts().get(i));
        final Artifact attachedArtifact = GrapesTranslator.getGrapesArtifact(project.getAttachedArtifacts().get(i));
        // handle licenses
        addLicenses(attachedArtifact, licenses);
        module.addArtifact(attachedArtifact);
    }

    /* Manage Dependencies */
    for(int i = 0 ; i < project.getDependencies().size() ; i++){
        final Dependency dependency = GrapesTranslator.getGrapesDependency(
                artifactResolver.resolveArtifact(project, project.getDependencies().get(i)),
                    project.getDependencies().get(i).getScope());

        // handle licenses
        for(License license: licenseResolver.resolve(
                project,
                dependency.getTarget().getGroupId(),
                dependency.getTarget().getArtifactId(),
                dependency.getTarget().getVersion())){
            dependency.getTarget().addLicense(license.getName());
        }

        module.addDependency(dependency);
    }

    return module;
}
 
開發者ID:Axway,項目名稱:grapes-maven-plugin,代碼行數:52,代碼來源:ModuleBuilder.java

示例9: addLicenses

import org.axway.grapes.commons.datamodel.Artifact; //導入依賴的package包/類
/**
 * Fill the artifact with the licenses name of the license list
 * @param mainArtifact Artifact
 * @param licenses List<License>
 */
private void addLicenses(final Artifact mainArtifact, final List<License> licenses) {
    for(License license: licenses){
        mainArtifact.addLicense(license.getName());
    }
}
 
開發者ID:Axway,項目名稱:grapes-maven-plugin,代碼行數:11,代碼來源:ModuleBuilder.java


注:本文中的org.axway.grapes.commons.datamodel.Artifact類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。