Examples of DependencyDto


Examples of io.fabric8.deployer.dto.DependencyDTO

        String artifactId = "bar";
        String expectedProfileId = groupId + "-" + artifactId;
        String versionId = "1.0";

        ProjectRequirements requirements = new ProjectRequirements();
        DependencyDTO rootDependency = new DependencyDTO();
        requirements.setRootDependency(rootDependency);
        rootDependency.setGroupId(groupId);
        rootDependency.setArtifactId(artifactId);
        rootDependency.setVersion("1.0.0");
        List<String> parentProfileIds = Arrays.asList("karaf");
        List<String> features = Arrays.asList("cxf", "war");
        requirements.setParentProfiles(parentProfileIds);
        requirements.setFeatures(features);
        projectDeployer.deployProject(requirements);


        // now we should have a profile created
        Profile profile = assertProfileInFabric(expectedProfileId, versionId);
        assertBundleCount(profile, 1);
        assertEquals("parent ids", parentProfileIds, profile.getParentIds());
        assertFeatures(profile, features);

        String requirementsFileName = "dependencies/" + groupId + "/" + artifactId + "-requirements.json";
        byte[] jsonData = profile.getFileConfiguration(requirementsFileName);
        assertNotNull("should have found some JSON for: " + requirementsFileName, jsonData);
        String json = new String(jsonData);
        LOG.info("Got JSON: " + json);

        // lets replace the version, parent, features
        rootDependency.setVersion("1.0.1");
        projectDeployer.deployProject(requirements);
        profile = assertProfileInFabric(expectedProfileId, versionId);
        assertBundleCount(profile, 1);

View Full Code Here

Examples of io.fabric8.deployer.dto.DependencyDTO

            list.removeAll(values);
        }
    }

    private DeployResults resolveProfileDeployments(ProjectRequirements requirements, FabricService fabric, Profile profile, ProfileBuilder builder) throws Exception {
        DependencyDTO rootDependency = requirements.getRootDependency();
        ProfileService profileService = fabricService.get().adapt(ProfileService.class);

        if (rootDependency != null) {
            // as a hack lets just add this bundle in
            LOG.info("Got root: " + rootDependency);
            List<String> parentIds = profile.getParentIds();
            Profile overlay = profileService.getOverlayProfile(profile);

            String bundleUrl = rootDependency.toBundleUrlWithType();
            LOG.info("Using resolver to add extra features and bundles on " + bundleUrl);

            List<String> features = new ArrayList<String>();
            List<String> bundles = new ArrayList<String>();
            List<String> optionals = new ArrayList<String>();

            if (requirements.getFeatures() != null) {
                features.addAll(requirements.getFeatures());
            }
            if (requirements.getBundles() != null) {
                bundles.addAll(requirements.getBundles());
            }

            bundles.add(bundleUrl);
            LOG.info("Adding bundle: " + bundleUrl);

            // TODO we maybe should detect a karaf based container in a nicer way than this?
            boolean isKarafContainer = parentIds.contains("karaf") || parentIds.contains("containers-karaf");
            boolean addBundleDependencies = Objects.equal("bundle", rootDependency.getType()) || isKarafContainer;
            if (addBundleDependencies && requirements.isUseResolver()) {

                // lets build up a list of all current active features and bundles along with all discovered features
                List<Feature> availableFeatures = new ArrayList<Feature>();
                addAvailableFeaturesFromProfile(availableFeatures, fabric, overlay);

                Set<String> currentBundleLocations = new HashSet<>();
                currentBundleLocations.addAll(bundles);

                // lets add the current features
                DownloadManager downloadManager = DownloadManagers.createDownloadManager(fabric, executorService);
                Set<Feature> currentFeatures = AgentUtils.getFeatures(fabric, downloadManager, overlay);
                addBundlesFromProfile(currentBundleLocations, overlay);

                List<String> parentProfileIds = requirements.getParentProfiles();
                if (parentProfileIds != null) {
                    for (String parentProfileId : parentProfileIds) {
                        Profile parentProfile = profileService.getProfile(profile.getVersion(), parentProfileId);
                        Profile parentOverlay = profileService.getOverlayProfile(parentProfile);
                        Set<Feature> parentFeatures = AgentUtils.getFeatures(fabric, downloadManager, parentOverlay);
                        currentFeatures.addAll(parentFeatures);
                        addAvailableFeaturesFromProfile(availableFeatures, fabric, parentOverlay);
                        addBundlesFromProfile(currentBundleLocations, parentOverlay);
                    }
                }

                // lets add all known features from the known repositories
                for (DependencyDTO dependency : rootDependency.getChildren()) {
                    if ("test".equals(dependency.getScope()) || "provided".equals(dependency.getScope())) {
                        continue;
                    }
                    if ("jar".equals(dependency.getType())) {
                        String match = getAllServiceMixBundles().get(dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion());
View Full Code Here

Examples of io.fabric8.deployer.dto.DependencyDTO

            if (configurationFileName.startsWith("dependencies/") && configurationFileName.endsWith("-requirements.json")) {
                byte[] data = profile.getFileConfiguration(configurationFileName);
                try {
                    ProjectRequirements requirements = DtoHelper.getMapper().readValue(data, ProjectRequirements.class);
                    if (requirements != null) {
                        DependencyDTO rootDependency = requirements.getRootDependency();
                        if (rootDependency != null) {
                            addMavenDependencies(artifacts, rootDependency);
                        }
                    }
View Full Code Here

Examples of io.fabric8.deployer.dto.DependencyDTO

    }



    protected void addProjectArtifactBundle(ProjectRequirements requirements) throws MojoFailureException {
        DependencyDTO rootDependency = requirements.getRootDependency();
        if (rootDependency != null) {
            // we need url with type, so when we deploy war files the mvn url is correct
            StringBuilder urlBuffer = new StringBuilder(rootDependency.toBundleUrl());

            String apparentType = rootDependency.getType();
            String apparentClassifier = rootDependency.getClassifier();

            for (String omit : OMITTED_BUNDLE_TYPES) {
                if (omit.equals(apparentType)) {
                    apparentType = null;
                    break;
View Full Code Here

Examples of io.fabric8.deployer.dto.DependencyDTO

    }

    private DependencyDTO buildFrom(DependencyNode node) {
        Artifact artifact = node.getArtifact();
        if (artifact != null) {
            DependencyDTO answer = new DependencyDTO();
            answer.setGroupId(artifact.getGroupId());
            answer.setArtifactId(artifact.getArtifactId());
            answer.setVersion(artifact.getVersion());
            answer.setClassifier(artifact.getClassifier());
            String scope = artifact.getScope();
            answer.setScope(scope);
            answer.setType(artifact.getType());
            // there is a bug if we try to resolve the current projects artifact for a "jar" packaging
            // before we've installed it then this operation will force the jar not be installed
            // so lets ignore this for the maven project's artifact
            if (artifact.getClassifier() == null && "jar".equals(artifact.getType())) {
                if (project.getArtifact().equals(artifact)) {
                    getLog().debug("Ignoring bundle check on the maven project artifact: " + artifact + " as this causes issues with the maven-install-plugin and we can assume the project packaging is accurate");
                } else {
                    try {
                        ArtifactResolutionRequest request = new ArtifactResolutionRequest();
                        request.setArtifact(artifact);
                        request.setRemoteRepositories(remoteRepositories);
                        request.setLocalRepository(localRepository);
                        resolver.resolve(request);
                        JarInputStream jis = new JarInputStream(new FileInputStream(artifact.getFile()));
                        Manifest man = jis.getManifest();
                        String bsn = man.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
                        if (bsn != null) {
                            answer.setType("bundle");
                        } else {
                            // Try to find a matching servicemix bundle for it
                        /*
                        Map<String, String> bundles = getAllServiceMixBundles();
                        getLog().debug("Trying to find a matching bundle for " + artifact);
                        String match = bundles.get(artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion());
                        if (match != null) {
                            String[] parts = match.split(":");
                            answer.setGroupId(parts[0]);
                            answer.setArtifactId(parts[1]);
                            answer.setVersion(parts[2]);
                            getLog().info("Replacing artifact " + artifact + " with servicemix bundle " + match);
                        }
                        */
                        }
                    } catch (Exception e) {
                        getLog().debug("Error checking artifact type for " + artifact, e);
                    }
                }
            }
            answer.setOptional(artifact.isOptional());

            String type = answer.getType();
            if (type != null && type.equals("pom")) {
                getLog().debug("Ignoring pom.xml for " + answer);
                return null;
            }
            int state = node.getState();
            if (state != DependencyNode.INCLUDED) {
                getLog().debug("Ignoring " + node);
                return null;
            }
            if (isWarProject()) {
                if (scope != null && !scope.equals("provided")) {
                    getLog().debug("WAR packaging so ignoring non-provided scope " + scope + " for " + node);
                    return null;
                }
            }
            List children = node.getChildren();
            for (Object child : children) {
                if (child instanceof DependencyNode) {
                    DependencyNode childNode = (DependencyNode) child;
                    if (childNode.getState() == DependencyNode.INCLUDED) {
                        String childScope = childNode.getArtifact().getScope();
                        if (!"test".equals(childScope) && !"provided".equals(childScope)) {
                            DependencyDTO childDTO = buildFrom(childNode);
                            if (childDTO != null) {
                                answer.addChild(childDTO);
                            }
                        } else {
                            getLog().debug("Ignoring artifact " + childNode.getArtifact() + " with scope " + childScope);
View Full Code Here

Examples of io.fabric8.deployer.dto.DependencyDTO

    protected ProjectRequirements toProjectRequirements(UploadContext context) {
        ProjectRequirements requirements = new ProjectRequirements();

        requirements.setParentProfiles(Collections.<String>emptyList());

        DependencyDTO rootDependency = new DependencyDTO();
        rootDependency.setGroupId(context.getGroupId());
        rootDependency.setArtifactId(context.getArtifactId());
        rootDependency.setVersion(context.getVersion());
        rootDependency.setType(context.getType());
        requirements.setRootDependency(rootDependency);

        return requirements;
    }
View Full Code Here

Examples of io.fabric8.deployer.dto.DependencyDTO

    protected void generateZip() throws DependencyTreeBuilderException, MojoExecutionException, IOException,
            MojoFailureException {
        ProjectRequirements requirements = new ProjectRequirements();

        DependencyDTO rootDependency = null;
        if (isIncludeArtifact()) {
            rootDependency = loadRootDependency();
            requirements.setRootDependency(rootDependency);
        }
        configureRequirements(requirements);
View Full Code Here

Examples of io.fabric8.deployer.dto.DependencyDTO

        if (isIgnoreProject()) return;

        try {
            ProjectRequirements requirements = new ProjectRequirements();
            if (isIncludeArtifact()) {
                DependencyDTO rootDependency = loadRootDependency();
                requirements.setRootDependency(rootDependency);
            }
            configureRequirements(requirements);

            // validate requirements
View Full Code Here

Examples of io.fabric8.deployer.dto.DependencyDTO

    private String artifactClassifier = "profile";

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        try {
            DependencyDTO rootDependency = loadRootDependency();

            ProjectRequirements requirements = new ProjectRequirements();
            requirements.setRootDependency(rootDependency);
            configureRequirements(requirements);
            addProjectArtifactBundle(requirements);
View Full Code Here

Examples of org.sonar.api.design.DependencyDto

  public void saveDependency(Project project, Dependency dependency, Dependency parentDependency) {
    Snapshot fromSnapshot = resourcePersister.saveResource(project, dependency.getFrom());
    Snapshot toSnapshot = resourcePersister.saveResource(project, dependency.getTo());
    Snapshot projectSnapshot = resourcePersister.getSnapshotOrFail(project);

    DependencyDto model = new DependencyDto();
    model.setProjectSnapshotId(projectSnapshot.getId());
    model.setUsage(dependency.getUsage());
    model.setWeight(dependency.getWeight());

    model.setFromResourceId(fromSnapshot.getResourceId());
    model.setFromScope(fromSnapshot.getScope());
    model.setFromSnapshotId(fromSnapshot.getId());

    model.setToResourceId(toSnapshot.getResourceId());
    model.setToSnapshotId(toSnapshot.getId());
    model.setToScope(toSnapshot.getScope());

    if (parentDependency != null) {
      // assume that it has been previously saved
      model.setParentDependencyId(parentDependency.getId());
    }
    session.save(model);
    dependency.setId(model.getId());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.