Example usage for org.apache.maven.repository RepositorySystem DEFAULT_LOCAL_REPO_ID

List of usage examples for org.apache.maven.repository RepositorySystem DEFAULT_LOCAL_REPO_ID

Introduction

In this page you can find the example usage for org.apache.maven.repository RepositorySystem DEFAULT_LOCAL_REPO_ID.

Prototype

String DEFAULT_LOCAL_REPO_ID

To view the source code for org.apache.maven.repository RepositorySystem DEFAULT_LOCAL_REPO_ID.

Click Source Link

Usage

From source file:org.fusesource.mop.MOPRepository.java

License:Open Source License

/**
 * Adds some default remote repositories
 * /*from   ww w .  j  a  v  a2 s.c o  m*/
 * @param repositorySystem
 */
protected List<ArtifactRepository> createRemoteRepositories(RepositorySystem repositorySystem) {

    List<ArtifactRepository> rc = new ArrayList<ArtifactRepository>();

    String mavenRepositoryDir = System.getProperty("user.home", ".") + "/.m2/repository";
    rc.add(createLocalRepository(repositorySystem, RepositorySystem.DEFAULT_LOCAL_REPO_ID, mavenRepositoryDir,
            true));

    DefaultRepositoryLayout layout = new DefaultRepositoryLayout();
    ArtifactRepositoryPolicy repositoryPolicy = new ArtifactRepositoryPolicy();

    if (online) {
        repositoryPolicy.setUpdatePolicy(updatePolicy);
    } else {
        repositoryPolicy.setUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER);
    }

    for (Map.Entry<String, String> entry : remoteRepositories.entrySet()) {
        String repoUrl = entry.getValue();

        //Let's strip the username password out so that it doesn't get displayed:
        Authentication auth = null;
        try {
            URL url = new URL(entry.getValue().toString());
            String userInfo = url.getUserInfo();
            if (userInfo != null) {
                StringTokenizer tok = new StringTokenizer(userInfo, ":");
                if (tok.countTokens() == 1) {
                    auth = new Authentication(userInfo, null);
                } else if (tok.countTokens() == 2) {
                    auth = new Authentication(tok.nextToken(), tok.nextToken());
                } else if (tok.countTokens() > 2) {
                    auth = new Authentication(tok.nextToken(), userInfo.substring(userInfo.indexOf(":") + 1));
                }

                repoUrl = url.getProtocol() + "://" + repoUrl.substring(repoUrl.indexOf("@") + 1);
            }
        } catch (MalformedURLException e) {
            warn("Invalid Repository url for: " + entry.getKey() + ": " + entry.getValue());
        }

        ArtifactRepository ar = repositorySystem.createArtifactRepository(entry.getKey(), repoUrl, layout,
                repositoryPolicy, repositoryPolicy);
        if (auth != null) {
            ar.setAuthentication(auth);
        }

        rc.add(ar);

    }

    return rc;
}

From source file:org.fusesource.mop.MOPRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public PlexusContainer getContainer() {
    if (container == null) {
        try {/*  ww w  .j a va  2  s.c om*/
            //Map commons logging to plexus log level:
            int plexusLogLevel = org.codehaus.plexus.logging.Logger.LEVEL_DISABLED;
            if (Logger.isDebug()) {
                plexusLogLevel = org.codehaus.plexus.logging.Logger.LEVEL_DEBUG;
            }

            ClassWorld classWorld = new ClassWorld("plexus.core",
                    Thread.currentThread().getContextClassLoader());
            ContainerConfiguration configuration = new DefaultContainerConfiguration()
                    .setClassWorld(classWorld);
            container = new DefaultPlexusContainer(configuration);
            container.getLoggerManager().setThreshold(plexusLogLevel);

            try {
                ArtifactTransformationManager transformer;
                transformer = (ArtifactTransformationManager) getContainer()
                        .lookup(ArtifactTransformationManager.class);
                LocalSnapshotArtifactTransformation transform = new LocalSnapshotArtifactTransformation();
                transform.setLocalRepoId(RepositorySystem.DEFAULT_LOCAL_REPO_ID);
                transformer.getArtifactTransformations().add(transform);
            } catch (ComponentLookupException e) {
                warn("Error setting local snaphost resolution transformer, your .m2 snapshot updates may not be resolved correctly!",
                        e);
            }

        } catch (PlexusContainerException e) {
            throw new RuntimeException(e);
        }
    }
    return container;
}