Search in sources :

Example 1 with Project

use of org.guvnor.ala.build.Project in project kie-wb-common by kiegroup.

the class MavenProjectConfigExecutorTest method testAPI.

@Test
public void testAPI() {
    final SourceRegistry sourceRegistry = new InMemorySourceRegistry();
    final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
    final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Git Source", new MyGitConfig()).addConfigStage("Maven Project", new MavenProjectConfigImpl()).addConfigStage("Maven Build Config", new MavenBuildConfigImpl()).addConfigStage("Maven Build", new MavenBuildExecConfigImpl()).buildAs("my pipe");
    final PipelineExecutor executor = new PipelineExecutor(asList(new GitConfigExecutor(sourceRegistry), new MavenProjectConfigExecutor(sourceRegistry), new MavenBuildConfigExecutor(), new MavenBuildExecConfigExecutor(buildRegistry)));
    executor.execute(new Input() {

        {
            put("repo-name", "drools-workshop-pipe");
            put("create-repo", "true");
            put("branch", "master");
            put("out-dir", tempPath.getAbsolutePath());
            put("origin", gitUrl);
        }
    }, pipe, System.out::println);
    List<Repository> allRepositories = sourceRegistry.getAllRepositories();
    assertEquals(1, allRepositories.size());
    Repository repo = allRepositories.get(0);
    List<Project> allProjects = sourceRegistry.getAllProjects(repo);
    assertEquals(1, allProjects.size());
    List<Binary> allBinaries = buildRegistry.getAllBinaries();
    assertEquals(1, allBinaries.size());
    assertMavenBinary(allBinaries.get(0), allProjects.get(0));
    final String tempDir = sourceRegistry.getAllProjects(repo).get(0).getTempDir();
    executor.execute(new Input() {

        {
            put("project-temp-dir", tempDir);
            put("repo-name", "drools-workshop-pipe");
            put("branch", "master");
        }
    }, pipe, System.out::println);
    allRepositories = sourceRegistry.getAllRepositories();
    assertEquals(1, allRepositories.size());
    repo = allRepositories.get(0);
    allProjects = sourceRegistry.getAllProjects(repo);
    assertEquals(2, allProjects.size());
    allBinaries = buildRegistry.getAllBinaries();
    assertEquals(1, allBinaries.size());
    assertMavenBinary(allBinaries.get(0), allProjects.get(1));
}
Also used : InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenProjectConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) SourceRegistry(org.guvnor.ala.registry.SourceRegistry) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) Pipeline(org.guvnor.ala.pipeline.Pipeline) Project(org.guvnor.ala.build.Project) MavenProject(org.apache.maven.project.MavenProject) GitConfigExecutor(org.guvnor.ala.source.git.executor.GitConfigExecutor) Input(org.guvnor.ala.pipeline.Input) Repository(org.guvnor.ala.source.Repository) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) MavenBuildExecConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl) BuildRegistry(org.guvnor.ala.registry.BuildRegistry) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenBuildConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl) Binary(org.guvnor.ala.build.Binary) MavenBinary(org.guvnor.ala.build.maven.model.MavenBinary) Test(org.junit.Test)

Example 2 with Project

use of org.guvnor.ala.build.Project in project kie-wb-common by kiegroup.

the class InMemorySourceRegistry method getAllProjects.

@Override
public List<Project> getAllProjects(final Repository repository) {
    Path repoPath = pathByRepositoryId.get(repository.getId());
    List<Project> allProjects = new ArrayList<>();
    for (Source s : projectBySource.keySet()) {
        if (projectBySource.get(s).getRootPath().equals(repoPath)) {
            allProjects.add(projectBySource.get(s));
        }
    }
    return allProjects;
}
Also used : Path(org.uberfire.java.nio.file.Path) Project(org.guvnor.ala.build.Project) ArrayList(java.util.ArrayList) Source(org.guvnor.ala.source.Source)

Example 3 with Project

use of org.guvnor.ala.build.Project in project kie-wb-common by kiegroup.

the class MavenBuildExecConfigExecutor method apply.

@Override
public Optional<BinaryConfig> apply(final MavenBuild mavenBuild, final MavenBuildExecConfig mavenBuildExecConfig) {
    final Project project = mavenBuild.getProject();
    final MavenProject mavenProject = build(project, mavenBuild.getGoals(), mavenBuild.getProperties());
    final Path path = FileSystems.getFileSystem(URI.create("file://default")).getPath(project.getTempDir() + "/target/" + project.getExpectedBinary());
    final MavenBinary binary = new MavenProjectBinaryImpl(path, project, mavenProject.getGroupId(), mavenProject.getArtifactId(), mavenProject.getVersion());
    buildRegistry.registerBinary(binary);
    return Optional.of(binary);
}
Also used : Path(org.uberfire.java.nio.file.Path) Project(org.guvnor.ala.build.Project) MavenProject(org.apache.maven.project.MavenProject) MavenProject(org.apache.maven.project.MavenProject) MavenProjectBinaryImpl(org.guvnor.ala.build.maven.model.impl.MavenProjectBinaryImpl) MavenBinary(org.guvnor.ala.build.maven.model.MavenBinary)

Example 4 with Project

use of org.guvnor.ala.build.Project in project kie-wb-common by kiegroup.

the class MavenProjectConfigExecutorTest method testReuseTmpDirectoryAPI.

@Test
public void testReuseTmpDirectoryAPI() {
    final SourceRegistry sourceRegistry = new InMemorySourceRegistry();
    final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
    final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Git Source", new MyGitConfig()).addConfigStage("Maven Project", new MavenProjectConfigImpl()).addConfigStage("Maven Build Config", new MavenBuildConfigImpl()).addConfigStage("Maven Build", new MavenBuildExecConfigImpl()).buildAs("my pipe");
    final PipelineExecutor executor = new PipelineExecutor(asList(new GitConfigExecutor(sourceRegistry), new MavenProjectConfigExecutor(sourceRegistry), new MavenBuildConfigExecutor(), new MavenBuildExecConfigExecutor(buildRegistry)));
    executor.execute(new Input() {

        {
            put("repo-name", "drools-workshop-pipe2");
            put("create-repo", "true");
            put("branch", "master");
            put("out-dir", tempPath.getAbsolutePath());
            put("origin", gitUrl);
        }
    }, pipe, System.out::println);
    List<Repository> allRepositories = sourceRegistry.getAllRepositories();
    assertEquals(1, allRepositories.size());
    Repository repo = allRepositories.get(0);
    List<Project> allProjects = sourceRegistry.getAllProjects(repo);
    assertEquals(1, allProjects.size());
    List<Binary> allBinaries = buildRegistry.getAllBinaries();
    assertEquals(1, allBinaries.size());
    assertMavenBinary(allBinaries.get(0), allProjects.get(0));
    final String tempDir = sourceRegistry.getAllProjects(repo).get(0).getTempDir();
    executor.execute(new Input() {

        {
            put("project-temp-dir", tempDir);
            put("repo-name", "drools-workshop-pipe2");
            put("branch", "master");
        }
    }, pipe, System.out::println);
    allRepositories = sourceRegistry.getAllRepositories();
    assertEquals(1, allRepositories.size());
    repo = allRepositories.get(0);
    allProjects = sourceRegistry.getAllProjects(repo);
    assertEquals(2, allProjects.size());
    allBinaries = buildRegistry.getAllBinaries();
    assertEquals(1, allBinaries.size());
    assertMavenBinary(allBinaries.get(0), allProjects.get(1));
}
Also used : InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenProjectConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) SourceRegistry(org.guvnor.ala.registry.SourceRegistry) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) Pipeline(org.guvnor.ala.pipeline.Pipeline) Project(org.guvnor.ala.build.Project) MavenProject(org.apache.maven.project.MavenProject) GitConfigExecutor(org.guvnor.ala.source.git.executor.GitConfigExecutor) Input(org.guvnor.ala.pipeline.Input) Repository(org.guvnor.ala.source.Repository) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) MavenBuildExecConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl) BuildRegistry(org.guvnor.ala.registry.BuildRegistry) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenBuildConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl) Binary(org.guvnor.ala.build.Binary) MavenBinary(org.guvnor.ala.build.maven.model.MavenBinary) Test(org.junit.Test)

Aggregations

Project (org.guvnor.ala.build.Project)4 MavenProject (org.apache.maven.project.MavenProject)3 MavenBinary (org.guvnor.ala.build.maven.model.MavenBinary)3 Binary (org.guvnor.ala.build.Binary)2 MavenBuildConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl)2 MavenBuildExecConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl)2 MavenProjectConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl)2 Input (org.guvnor.ala.pipeline.Input)2 Pipeline (org.guvnor.ala.pipeline.Pipeline)2 PipelineExecutor (org.guvnor.ala.pipeline.execution.PipelineExecutor)2 BuildRegistry (org.guvnor.ala.registry.BuildRegistry)2 SourceRegistry (org.guvnor.ala.registry.SourceRegistry)2 InMemoryBuildRegistry (org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry)2 InMemorySourceRegistry (org.guvnor.ala.registry.inmemory.InMemorySourceRegistry)2 Repository (org.guvnor.ala.source.Repository)2 GitConfigExecutor (org.guvnor.ala.source.git.executor.GitConfigExecutor)2 Test (org.junit.Test)2 Path (org.uberfire.java.nio.file.Path)2 ArrayList (java.util.ArrayList)1 MavenProjectBinaryImpl (org.guvnor.ala.build.maven.model.impl.MavenProjectBinaryImpl)1