Example usage for org.apache.maven.project MavenProject getContextValue

List of usage examples for org.apache.maven.project MavenProject getContextValue

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getContextValue.

Prototype

public Object getContextValue(String key) 

Source Link

Document

Returns context value of this project associated with the given key or null if this project has no such value.

Usage

From source file:org.sourcepit.b2.internal.maven.B2BootstrapParticipant.java

License:Apache License

public void afterBuild(MavenSession bootSession, MavenProject bootProject, MavenSession actualSession) {
    final String setScmIgnoresProp = bootProject.getProperties().getProperty("b2.scm.setScmIgnores",
            System.getProperty("b2.scm.setScmIgnores", "false"));

    final boolean isSetScmIgnores = Boolean.valueOf(setScmIgnoresProp).booleanValue();
    if (isSetScmIgnores) {
        final AbstractModule module = (AbstractModule) bootProject
                .getContextValue(AbstractModule.class.getName());
        final ModuleDirectory moduleDirectory = (ModuleDirectory) bootProject
                .getContextValue(ModuleDirectory.class.getName());
        if (module != null && moduleDirectory != null) {
            scm.doSetScmIgnores(moduleDirectory, module);
        }//w ww .  j a  va  2 s .com
    }
}

From source file:org.sourcepit.b2.internal.maven.ModelContextAdapterFactory.java

License:Apache License

public ModelContext adapt(MavenSession session, MavenProject project) {
    synchronized (project) {
        ModelContext context = (ModelContext) project.getContextValue(ModelContext.class.getName());
        if (context == null) {
            context = createModuleModelContext(session, project);
            project.setContextValue(ModelContext.class.getName(), context);
        }//from  w w w  .j av a 2 s.  co m
        return context;
    }
}

From source file:org.sourcepit.b2.internal.maven.ModelContextAdapterFactory.java

License:Apache License

public static ModelContext get(MavenProject project) {
    synchronized (project) {
        return (ModelContext) project.getContextValue(ModelContext.class.getName());
    }/* w ww . j  a  va  2s  . c  o m*/
}

From source file:org.sourcepit.b2.maven.core.B2MavenBridge.java

License:Apache License

@SuppressWarnings("unchecked")
private static <T> T getContextValue(MavenProject mavenProject, Class<T> type) {
    return (T) mavenProject.getContextValue(type.getName());
}

From source file:org.sourcepit.b2.maven.internal.wrapper.B2Bootstrapper.java

License:Apache License

@Override
protected void adjustActualSession(MavenSession bootSession, MavenSession actualSession) {
    final File baseDir;
    if (bootSession.getRequest().getPom() == null) {
        baseDir = new File(bootSession.getRequest().getBaseDirectory());
    } else {//  w  w  w  . j a  va  2  s . c o m
        baseDir = bootSession.getRequest().getPom().getParentFile();
    }

    MavenProject mainBootProject = null;
    for (MavenProject bootProject : bootSession.getProjects()) {
        if (baseDir.equals(bootProject.getBasedir())) {
            mainBootProject = bootProject;
            break;
        }
    }

    final File pom = (File) mainBootProject.getContextValue("pom");
    if (pom != null) {
        final MavenExecutionRequest request = actualSession.getRequest();
        request.setPom(pom);
    }
}

From source file:org.sourcepit.b2.release.B2ReleaseHelper.java

License:Apache License

public MavenProject adaptModuleProject(MavenProject reactorProject) {
    MavenProject moduleProject = (MavenProject) reactorProject.getContextValue("b2.moduleProject");
    if (moduleProject == null) {
        if (bridge.getModule(reactorProject) != null) {
            moduleProject = (MavenProject) reactorProject.clone();
            moduleProject.setFile(new File(reactorProject.getBasedir(), "module.xml"));
            reactorProject.setContextValue("b2.moduleProject", moduleProject);
        }/*from ww  w .j a  v a  2s. com*/
    }
    return moduleProject;
}

From source file:org.sourcepit.b2.release.B2ScmHelper.java

License:Apache License

private static Set<File> getCommitProposals(MavenProject mavenProject) {
    @SuppressWarnings("unchecked")
    Set<File> files = (Set<File>) mavenProject.getContextValue(CTX_KEY_COMMIT_PROPOSALS);
    if (files == null) {
        files = new LinkedHashSet<File>();
        mavenProject.setContextValue(CTX_KEY_COMMIT_PROPOSALS, files);
    }// w ww  .  java  2 s. c  o m
    return files;
}

From source file:org.sourcepit.maven.bootstrap.core.AbstractBootstrapper.java

License:Apache License

private List<?> discoverBootstrapParticipants(MavenSession bootSession, MavenProject bootProject,
        ClassRealm bootExtensionClassRealm) {
    final String key = BootstrapParticipant.class.getName() + "@" + bootExtensionClassRealm.getId();

    List<?> bootstrapParticipants = (List<?>) bootProject.getContextValue(key);
    if (bootstrapParticipants == null) {
        bootstrapParticipants = lookupBootstrapParticipants(bootSession, bootProject, bootExtensionClassRealm);
        bootProject.setContextValue(key, bootstrapParticipants);
    }//from  w w  w .j ava  2s  . co  m
    return bootstrapParticipants;
}

From source file:org.sourcepit.osgifier.maven.DeployOsgifiedArtifacts.java

License:Apache License

@Override
protected void doExecute() throws MojoExecutionException, MojoFailureException {
    final MavenProject project = buildContext.getSession().getCurrentProject();

    @SuppressWarnings("unchecked")
    final Collection<Artifact> artifacts = (Collection<Artifact>) project.getContextValue("osgified-artifacts");

    final RepositorySystemSession session = buildContext.getRepositorySession();

    final String id = repository.getId();
    final String url = repository.getUrl();
    final String layout = repository.getLayout();

    final RemoteRepository repo = newRemoteRepository(session, id, url, layout);

    deploy(session, repo, artifacts);/*from w w  w  .  java 2s  .c  o  m*/
}

From source file:org.sourcepit.osgifier.maven.InjectManifestMojo.java

License:Apache License

@Override
protected void doExecute() throws MojoExecutionException, MojoFailureException {
    final MavenProject project = buildContext.getSession().getCurrentProject();

    final ArtifactManifestBuilderResult result = (ArtifactManifestBuilderResult) project
            .getContextValue("osgifier.manifestBuilderResult");

    if (result != null) {
        final BundleManifest manifest = result.getBundleManifest();
        if (manifest != null) {
            repackager.injectManifest(project.getArtifact().getFile(), manifest,
                    result.getBundleLocalization());
        }/*  w  w w.j a v  a2s  . com*/

        final BundleManifest sourceManifest = result.getSourceBundleManifest();
        if (manifest != null) {
            final Artifact sourceArtifact = getAttachedArtifact(project, sourceClassifier);
            if (sourceArtifact != null) {
                repackager.injectManifest(sourceArtifact.getFile(), sourceManifest,
                        result.getSourceBundleLocalization());
            }
        }
    }
}