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


Java Module类代码示例

本文整理汇总了Java中org.axway.grapes.commons.datamodel.Module的典型用法代码示例。如果您正苦于以下问题:Java Module类的具体用法?Java Module怎么用?Java Module使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createAutoInstance

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
@Override
public GrapesNotification createAutoInstance(AbstractBuild<?, ?> build) {
    GrapesMavenPluginNotification notification = null;
    try{
        final GrapesNotifier notifier = GrapesPlugin.getGrapesNotifier(build.getProject());
        if(notifier == null || !notifier.getManageGrapesMavenPlugin()){
            return null;
        }

        final FilePath moduleFilePath = GrapesPlugin.getBuildModuleFile(build);
        if(!moduleFilePath.exists()){
            return null;
        }

        final Module module = GrapesPlugin.getModule(moduleFilePath);

        notification = new GrapesMavenPluginNotification();
        notification.setModuleName(module.getName());
        notification.setModuleVersion(module.getVersion());
        notification.setModuleFilePath(moduleFilePath);
    } catch (Exception e) {
        GrapesPlugin.getLogger().log(Level.SEVERE, "[GRAPES] Failed to get build Maven Grapes report ", e);
    }

    return notification;
}
 
开发者ID:Axway,项目名称:grapes-jenkins-plugin,代码行数:27,代码来源:GrapesMavenPluginNotification.java

示例2: createAutoInstance

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
@Override
public GrapesNotification createAutoInstance(final AbstractBuild<?, ?> build) {
    try{
        final GrapesNotifier notifier = GrapesPlugin.getGrapesNotifier(build.getProject());
        if(notifier == null || !notifier.getManageBuildInfo()){
            return null;
        }

        final FilePath moduleFile = GrapesPlugin.getBuildModuleFile(build);
        final Module module = GrapesPlugin.getModule(moduleFile);

        final BuildInfoNotification notification = new BuildInfoNotification();
        notification.setModuleName(module.getName());
        notification.setModuleVersion(module.getVersion());
        notification.setMimePath(GrapesPlugin.getBuildBuildInfoFile(build));

        return notification;

    } catch (Exception e) {
        GrapesPlugin.getLogger().log(Level.SEVERE, "[GRAPES] Failed to get build Module buildInfo ", e);
    }

    return null;
}
 
开发者ID:Axway,项目名称:grapes-jenkins-plugin,代码行数:25,代码来源:BuildInfoNotification.java

示例3: aggregate

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
/**
 * Checks all the available reports and aggregates the existing ones
 *
 * @throws IOException
 * @throws MojoExecutionException
 */
public void aggregate() throws IOException, MojoExecutionException {
    final Map<String, File> subModules = getSubModuleReports();

    for(Map.Entry<String,File> submoduleReports : subModules.entrySet()){
        final MavenProject parentProject = getParentProject(submoduleReports.getKey());

        if(parentProject != null){
            final Module subModule = JsonUtils.unserializeModule(FileUtils.read(submoduleReports.getValue()));
            final Boolean updated = updateParent(parentProject, subModule);

            // removes the children that are taken into accounts into parent reports
            if(updated){
                final File subModuleFile = new File(workingFolder, GrapesMavenPlugin.getSubModuleFileName(submoduleReports.getKey()));
                subModuleFile.delete();
            }
        }
    }
}
 
开发者ID:Axway,项目名称:grapes-maven-plugin,代码行数:25,代码来源:ModuleAggregator.java

示例4: getSubModule

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
private Module getSubModule(final Module rootModule, final MavenProject parentProject) {
    final String parentSubModuleName = GrapesTranslator.generateModuleName(parentProject);

    for(Module subModule: rootModule.getSubmodules()){
        if(subModule.getName().equals(parentSubModuleName)){
            return subModule;
        }

        final Module result = getSubModule(subModule,parentProject);
        if(result != null){
            return result;
        }
    }

    return null;
}
 
开发者ID:Axway,项目名称:grapes-maven-plugin,代码行数:17,代码来源:ModuleAggregator.java

示例5: generateModule

import org.axway.grapes.commons.datamodel.Module; //导入依赖的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

示例6: getModule

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
/**
 * Un-serialize a Module from Json file
 *
 * @param moduleFile File
 * @return Module
 * @throws IOException
 * @throws InterruptedException
 */
public static Module getModule(final FilePath moduleFile) throws IOException, InterruptedException {
    if (moduleFile.exists()) {
        final String serializedModule= moduleFile.readToString();
        return JsonUtils.unserializeModule(serializedModule);
    }

    getLogger().severe("[GRAPES] Wrong module report path: " + moduleFile.toURI().getPath());
    throw new IOException("[GRAPES] Failed to get report.");
}
 
开发者ID:Axway,项目名称:grapes-jenkins-plugin,代码行数:18,代码来源:GrapesPlugin.java

示例7: GrapesBuildAction

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
/**
 * Initiate the report
 *
 * @param module Module
 * @param grapesClient GrapesClient
 */
public GrapesBuildAction(final Module module, final GrapesClient grapesClient) {
   if(grapesClient == null ||
            module == null ){
        return;
    }

    title = "Dependency  report of " + module.getName() + " in version " + module.getVersion();

    // Init the report with Grapes server information
    try{
        final Organization organization = grapesClient.getModuleOrganization(module.getName(), module.getVersion());
        final List<String> corporateFilters = organization.getCorporateGroupIdPrefixes();
        dependencies = new HashMap<Dependency, String>();

        final List<Dependency> moduleDependencies = ModuleUtils.getCorporateDependencies(module, corporateFilters);
        for(Dependency dependency: moduleDependencies){
            final String lastVersion = getLastVersion(grapesClient, dependency);
            this.dependencies.put(dependency, lastVersion);
        }

        thirdParty = ModuleUtils.getThirdPartyLibraries(module, corporateFilters);
        ancestors = grapesClient.getModuleAncestors(module.getName(), module.getVersion());

        initOk = true;

    } catch (Exception e){
        GrapesPlugin.getLogger().log(Level.WARNING, "Failed to generate build dependency report for " + module.getName(), e);
    }

}
 
开发者ID:Axway,项目名称:grapes-jenkins-plugin,代码行数:37,代码来源:GrapesBuildAction.java

示例8: getModule

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
/**
 * Return a module from Json file in a targeted folder
 *
 * @param folder File
 * @param moduleJsonFileName String
 * @return Module
 * @throws MojoExecutionException
 * @throws IOException
 */
public static Module getModule(final File folder, final String moduleJsonFileName) throws MojoExecutionException, IOException {
    final File moduleFile = new File(folder, moduleJsonFileName);

    if(moduleFile.exists()){
        final String serializedModule = FileUtils.read(moduleFile);
        return JsonUtils.unserializeModule(serializedModule);
    }

    return null;
}
 
开发者ID:Axway,项目名称:grapes-maven-plugin,代码行数:20,代码来源:GrapesMavenPlugin.java

示例9: execute

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
public void execute() throws MojoExecutionException {
	if (isExecuteSkipped()) {
		return;
	}
    // Execute only one time
    if(project.equals(reactorProjects.get(0))){
        try {
            final File workingFolder = GrapesMavenPlugin.getGrapesPluginWorkingFolder(reactorProjects.get(0));
            final Module rootModule = GrapesMavenPlugin.getModule(workingFolder, GrapesMavenPlugin.MODULE_JSON_FILE_NAME);
            getLog().info("Sending " + rootModule.getName() + "...");

            getLog().info("Connection to Grapes");
            getLog().info("Host: " + host);
            getLog().info("Port: " + port);
            getLog().info("User: " + user);
            final GrapesClient client = new GrapesClient(host, port);

            if(!client.isServerAvailable()){
                throw new MojoExecutionException("Grapes is unreachable");
            }

            client.postModule(rootModule, user, password);

            getLog().info("Information successfully sent");

        } catch (Exception e) {
            if(failOnError){
                throw new MojoExecutionException("An error occurred during Grapes server Notification." , e);
            }
            else{
                getLog().debug("An error occurred during Grapes server Notification.", e);
                getLog().info("Failed to send information to Grapes");
            }
        }
    }
}
 
开发者ID:Axway,项目名称:grapes-maven-plugin,代码行数:37,代码来源:NotifyMojo.java

示例10: testSimpleProjectWithOneModuleOneArtifactAndOneLicense

import org.axway.grapes.commons.datamodel.Module; //导入依赖的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

示例11: send

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
/**
 * Sends a notification to Grapes server
 *
 * @param notification GrapesNotification
 * @throws GrapesCommunicationException
 */
public void send(final GrapesNotification notification, final AbstractBuild<?,?> build) throws GrapesCommunicationException {
    try{
        // perform the notification
        switch (notification.getNotificationAction()){
            case POST_MODULE:
                // Send the module
                final FilePath moduleFilePath = notification.getMimePath();
                final Module module = GrapesPlugin.getModule(moduleFilePath);
                client.postModule(module, user, password);

                // Generate build action with the dependency report
                final GrapesBuildAction buildAction = new GrapesBuildAction(module, client);

                // Add dependency report to the build
                if (buildAction.isInitOk()) {
                    build.addAction(buildAction);
                }
                break;
            case PROMOTE:
                client.promoteModule(notification.getModuleName(), notification.getModuleVersion(), user, password);
                break;
            case POST_MODULE_BUILD_INFO:
                final FilePath buildInfoPath = notification.getMimePath();
                final Map<String, String> buildInfo = GrapesPlugin.getBuildInfo(buildInfoPath);
                client.postBuildInfo(notification.getModuleName(), notification.getModuleVersion(), buildInfo, user, password);
                break;
            default:break;
        }

        //discard old resend action if matches moduleName moduleVersion notification type
        discardOldResend(notification, build.getProject());
    }

    catch (Exception e) {
        GrapesPlugin.getLogger().log(Level.SEVERE, "[GRAPES] An error occurred during notification sending ", e);
        discardOldResend(notification, build.getProject());
        saveNotification(notification, build);
        throw new GrapesCommunicationException(e.getMessage(), 500);

    }
}
 
开发者ID:Axway,项目名称:grapes-jenkins-plugin,代码行数:48,代码来源:NotificationHandler.java

示例12: getModule

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
public Module getModule() {
    return module;
}
 
开发者ID:Axway,项目名称:grapes-jenkins-plugin,代码行数:4,代码来源:GrapesBuildAction.java

示例13: execute

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
public void execute() throws MojoExecutionException {
	if (isExecuteSkipped()) {
		return;
	}
    try {
        final ModuleAggregator aggregator = new ModuleAggregator(reactorProjects);
        final ModuleBuilder moduleBuilder = new ModuleBuilder();
        final ArtifactResolver artifactResolver = new ArtifactResolver(repositorySystem, localRepository, getLog());
        final LicenseResolver licenseResolver = new LicenseResolver(repositorySystem, localRepository, getLog());

        getLog().info("Collecting dependency information of " + project.getName());
        final Module module = moduleBuilder.getModule(project, licenseResolver, artifactResolver);

        // Serialize the collected information
        final String serializedModule = JsonUtils.serialize(module);
        getLog().debug("Json module : " + serializedModule);

        // Write file
        final File grapesFolder = GrapesMavenPlugin.getGrapesPluginWorkingFolder(reactorProjects.get(0));
        getLog().info("Serializing the notification in " + grapesFolder.getPath());

        if(project.equals(reactorProjects.get(0))){
            FileUtils.serialize(grapesFolder, serializedModule, GrapesMavenPlugin.MODULE_JSON_FILE_NAME);
        }
        else{
            final String subModuleName = project.getBasedir().getName();
            FileUtils.serialize(grapesFolder, serializedModule, GrapesMavenPlugin.getSubModuleFileName(subModuleName));
        }

        getLog().info("Report consolidation...");
        aggregator.aggregate();

    } catch (Exception e) {

        if(failOnError){
            throw new MojoExecutionException("An error occurred during Grapes reporting." , e);
        }
        else{
            getLog().debug("An error occurred during Grapes reporting.", e);
            getLog().error("Failed to build Grapes report.");
        }
    }
}
 
开发者ID:Axway,项目名称:grapes-maven-plugin,代码行数:44,代码来源:GenerateMojo.java

示例14: getModule

import org.axway.grapes.commons.datamodel.Module; //导入依赖的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

示例15: contains

import org.axway.grapes.commons.datamodel.Module; //导入依赖的package包/类
/**
 * Checks if a module has a project as sub module
 *
 * @param rootModule Module
 * @param parentProject MavenProject
 * @return boolean
 */
private boolean contains(final Module rootModule, final MavenProject parentProject) {
    return getSubModule(rootModule, parentProject) != null;
}
 
开发者ID:Axway,项目名称:grapes-maven-plugin,代码行数:11,代码来源:ModuleAggregator.java


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