Search in sources :

Example 16 with Dependency

use of org.guvnor.common.services.project.model.Dependency in project kie-wb-common by kiegroup.

the class DependencyValidatorTest method testArtifactId.

@Test
public void testArtifactId() throws Exception {
    DependencyValidator dependencyValidator = new DependencyValidator(new Dependency(new GAV("groupId", null, "1.0")));
    assertFalse(dependencyValidator.validate());
    assertEquals("DependencyIsMissingAnArtifactId", dependencyValidator.getMessage());
}
Also used : Dependency(org.guvnor.common.services.project.model.Dependency) GAV(org.guvnor.common.services.project.model.GAV) Test(org.junit.Test)

Example 17 with Dependency

use of org.guvnor.common.services.project.model.Dependency in project kie-wb-common by kiegroup.

the class DependencyValidatorTest method testValid.

@Test
public void testValid() throws Exception {
    DependencyValidator dependencyValidator = new DependencyValidator(new Dependency(new GAV("groupId", "artifactId", "1.0")));
    assertTrue(dependencyValidator.validate());
}
Also used : Dependency(org.guvnor.common.services.project.model.Dependency) GAV(org.guvnor.common.services.project.model.GAV) Test(org.junit.Test)

Example 18 with Dependency

use of org.guvnor.common.services.project.model.Dependency in project kie-wb-common by kiegroup.

the class DependencyValidatorTest method testVersion.

@Test
public void testVersion() throws Exception {
    DependencyValidator dependencyValidator = new DependencyValidator(new Dependency(new GAV("groupId", "artifactId", null)));
    assertFalse(dependencyValidator.validate());
    assertEquals("DependencyIsMissingAVersion", dependencyValidator.getMessage());
}
Also used : Dependency(org.guvnor.common.services.project.model.Dependency) GAV(org.guvnor.common.services.project.model.GAV) Test(org.junit.Test)

Example 19 with Dependency

use of org.guvnor.common.services.project.model.Dependency in project kie-wb-common by kiegroup.

the class MavenArtifactResolver method resolve.

public URI resolve(final String groupId, final String artifactId, final String version) throws Exception {
    final POM projectPom = new POM(new GAV("resolver-dummy-group", "resolver-dummy-artifact", "resolver-dummy-version"));
    projectPom.getDependencies().add(new Dependency(new GAV(groupId, artifactId, version)));
    try {
        final String pomXML = pomContentHandler.toString(projectPom);
        final InputStream pomStream = new ByteArrayInputStream(pomXML.getBytes(StandardCharsets.UTF_8));
        final MavenProject mavenProject = MavenProjectLoader.parseMavenPom(pomStream);
        for (Artifact mavenArtifact : mavenProject.getArtifacts()) {
            if (groupId.equals(mavenArtifact.getGroupId()) && artifactId.equals(mavenArtifact.getArtifactId()) && version.equals(mavenArtifact.getVersion()) && mavenArtifact.getFile().exists()) {
                return mavenArtifact.getFile().toURI();
            }
        }
        return null;
    } catch (IOException e) {
        logger.error("Unable to get artifact: " + groupId + ":" + artifactId + ":" + version + " from maven repository", e);
        throw new Exception("Unable to get artifact: " + groupId + ":" + artifactId + ":" + version + " from maven repository", e);
    }
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Dependency(org.guvnor.common.services.project.model.Dependency) IOException(java.io.IOException) GAV(org.guvnor.common.services.project.model.GAV) Artifact(org.apache.maven.artifact.Artifact) IOException(java.io.IOException) POM(org.guvnor.common.services.project.model.POM)

Example 20 with Dependency

use of org.guvnor.common.services.project.model.Dependency in project kie-wb-common by kiegroup.

the class DependenciesItemPresenter method setup.

public DependenciesItemPresenter setup(final EnhancedDependency enhancedDependency, final WhiteList whiteList, final DependenciesPresenter dependenciesPresenter) {
    this.enhancedDependency = enhancedDependency;
    this.parentPresenter = dependenciesPresenter;
    final Dependency dependency = enhancedDependency.getDependency();
    view.init(this);
    view.setGroupId(dependency.getGroupId());
    view.setArtifactId(dependency.getArtifactId());
    view.setVersion(dependency.getVersion());
    view.setPackagesWhiteListedState(WhiteListedPackagesState.from(whiteList, enhancedDependency.getPackages()));
    view.setTransitiveDependency(enhancedDependency instanceof TransitiveEnhancedDependency);
    return this;
}
Also used : TransitiveEnhancedDependency(org.kie.workbench.common.services.shared.dependencies.TransitiveEnhancedDependency) Dependency(org.guvnor.common.services.project.model.Dependency) EnhancedDependency(org.kie.workbench.common.services.shared.dependencies.EnhancedDependency) TransitiveEnhancedDependency(org.kie.workbench.common.services.shared.dependencies.TransitiveEnhancedDependency)

Aggregations

Dependency (org.guvnor.common.services.project.model.Dependency)32 GAV (org.guvnor.common.services.project.model.GAV)17 Test (org.junit.Test)16 HashSet (java.util.HashSet)10 NormalEnhancedDependency (org.kie.workbench.common.services.shared.dependencies.NormalEnhancedDependency)8 EnhancedDependency (org.kie.workbench.common.services.shared.dependencies.EnhancedDependency)6 EnhancedDependencies (org.kie.workbench.common.services.shared.dependencies.EnhancedDependencies)4 POM (org.guvnor.common.services.project.model.POM)3 Set (java.util.Set)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Artifact (org.apache.maven.artifact.Artifact)1 MavenProject (org.apache.maven.project.MavenProject)1 Dependencies (org.guvnor.common.services.project.model.Dependencies)1 Before (org.junit.Before)1 Util.makeDependency (org.kie.workbench.common.screens.projecteditor.client.forms.dependencies.Util.makeDependency)1 DependencyValidator (org.kie.workbench.common.screens.projecteditor.client.forms.dependencies.validation.DependencyValidator)1 TransitiveEnhancedDependency (org.kie.workbench.common.services.shared.dependencies.TransitiveEnhancedDependency)1