Skip to content

Commit

Permalink
#131: Fixed dependency crawling for artifact that are not on maven ce…
Browse files Browse the repository at this point in the history
…ntral (#133)

* #131: Fixed dependency crawling for artifact that are not on maven central
  • Loading branch information
jakobbraun authored Jun 9, 2021
1 parent 096b73e commit 5734827
Show file tree
Hide file tree
Showing 29 changed files with 194 additions and 156 deletions.
6 changes: 3 additions & 3 deletions dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@
[24]: http://junit.org
[39]: https://www.eclipse.org/legal/epl-2.0/
[13]: https://www.xmlunit.org/
[20]: https://maven.apache.org/ref/3.6.3/maven-core/
[37]: https://github.com/mockito/mockito/blob/main/LICENSE
[74]: http://zlika.github.io/reproducible-build-maven-plugin
[35]: http://www.opensource.org/licenses/mit-license.php
[6]: https://github.com/classgraph/classgraph
[37]: https://github.com/mockito/mockito/blob/release/3.x/LICENSE
[8]: https://github.com/eclipse-ee4j/jaxb-api
[26]: https://junit.org/junit5/
[46]: https://maven.apache.org/plugin-tools/maven-plugin-plugin
Expand All @@ -99,11 +98,11 @@
[80]: http://maven.apache.org/plugins/maven-resources-plugin/
[0]: https://maven.apache.org/plugin-tools/maven-plugin-annotations
[70]: http://www.sonatype.com/public-parent/nexus-maven-plugins/nexus-staging/nexus-staging-maven-plugin/
[20]: https://maven.apache.org/ref/3.8.1/maven-core/
[48]: https://maven.apache.org/surefire/maven-failsafe-plugin/
[76]: http://maven.apache.org/plugins/maven-dependency-plugin/
[7]: http://opensource.org/licenses/MIT
[25]: http://www.eclipse.org/legal/epl-v10.html
[2]: https://maven.apache.org/ref/3.6.3/maven-plugin-api/
[82]: http://maven.apache.org/plugins/maven-jar-plugin/
[12]: http://www.eclipse.org/org/documents/edl-v10.php
[1]: https://www.apache.org/licenses/LICENSE-2.0.txt
Expand All @@ -115,5 +114,6 @@
[40]: https://github.com/exasol/maven-plugin-integration-testing
[68]: http://maven.apache.org/plugins/maven-deploy-plugin/
[86]: http://maven.apache.org/plugins/maven-site-plugin/
[2]: https://maven.apache.org/ref/3.8.1/maven-plugin-api/
[58]: https://maven.apache.org/plugins/maven-javadoc-plugin/
[72]: https://github.com/exasol/error-code-crawler-maven-plugin
1 change: 1 addition & 0 deletions doc/changes/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changes

* [0.7.2](changes_0.7.2.md)
* [0.7.1](changes_0.7.1.md)
* [0.7.0](changes_0.7.0.md)
* [0.6.1](changes_0.6.1.md)
Expand Down
28 changes: 28 additions & 0 deletions doc/changes/changes_0.7.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Project keeper maven plugin 0.7.2, released 2021-06-09

Code name: Bug Fix: Dependency crawling for non maven central dependencies

## Bug Fixes

* #131: Fixed dependency crawling for artifact that are not on maven central

## Dependency Updates

### Compile Dependency Updates

* Updated `io.github.classgraph:classgraph:4.8.102` to `4.8.108`
* Updated `org.apache.maven:maven-core:3.6.3` to `3.8.1`
* Updated `org.apache.maven:maven-plugin-api:3.6.3` to `3.8.1`
* Updated `org.eclipse.jgit:org.eclipse.jgit:5.11.0.202103091610-r` to `5.11.1.202105131744-r`
* Updated `org.glassfish.jaxb:jaxb-runtime:3.0.0` to `3.0.1`

### Test Dependency Updates

* Updated `org.junit.jupiter:junit-jupiter-engine:5.7.1` to `5.7.2`
* Updated `org.junit.jupiter:junit-jupiter-params:5.7.1` to `5.7.2`
* Updated `org.mockito:mockito-core:3.8.0` to `3.11.0`

### Plugin Dependency Updates

* Updated `com.exasol:error-code-crawler-maven-plugin:0.1.1` to `0.4.0`
* Updated `com.exasol:project-keeper-maven-plugin:0.7.1` to `0.7.2`
4 changes: 4 additions & 0 deletions error_code_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error-tags:
PK:
packages:
- com.exasol.projectkeeper
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.exasol</groupId>
<artifactId>project-keeper-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>0.7.1</version>
<version>0.7.2</version>
<name>Project keeper maven plugin</name>
<description>This maven plugin checks and unifies a project's structure according to the Exasol integration team's
repository standards.
Expand Down Expand Up @@ -45,8 +45,8 @@
</scm>

<properties>
<maven.version>3.6.3</maven.version>
<junit.version>5.7.1</junit.version>
<maven.version>3.8.1</maven.version>
<junit.version>5.7.2</junit.version>
<java.version>11</java.version>
<junit.platform.version>1.6.2</junit.platform.version>
<jacoco.version>0.8.6</jacoco.version>
Expand All @@ -58,7 +58,7 @@
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<version>3.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -74,7 +74,7 @@
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>4.8.102</version>
<version>4.8.108</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
Expand All @@ -84,7 +84,7 @@
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
Expand All @@ -99,7 +99,7 @@
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.11.0.202103091610-r</version>
<version>5.11.1.202105131744-r</version>
</dependency>
<dependency>
<groupId>net.steppschuh.markdowngenerator</groupId>
Expand Down Expand Up @@ -165,7 +165,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.8.0</version>
<version>3.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -453,7 +453,7 @@
<plugin>
<groupId>com.exasol</groupId>
<artifactId>error-code-crawler-maven-plugin</artifactId>
<version>0.1.1</version>
<version>0.4.0</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
import org.apache.maven.project.ProjectBuilder;
import org.apache.maven.repository.RepositorySystem;

import com.exasol.projectkeeper.pom.DefaultMavenArtifactModelReader;
import com.exasol.projectkeeper.pom.DefaultMavenFileModelReader;
import com.exasol.projectkeeper.pom.MavenArtifactModelReader;
import com.exasol.projectkeeper.pom.DefaultMavenProjectFromFileReader;
import com.exasol.projectkeeper.pom.MavenModelFromRepositoryReader;
import com.exasol.projectkeeper.validators.DeletedFilesValidator;
import com.exasol.projectkeeper.validators.changesfile.ChangesFileValidator;
import com.exasol.projectkeeper.validators.dependencies.DependenciesValidator;
Expand Down Expand Up @@ -76,9 +75,9 @@ protected List<Validator> getValidators() {
final var brokenLinkReplacer = new BrokenLinkReplacer(this.linkReplacements);
final Set<ProjectKeeperModule> enabledModules = getEnabledModules();
final var excludedFilesMatcher = new ExcludedFilesMatcher(this.excludedFiles);
final var mavenModelReader = new DefaultMavenFileModelReader(this.mavenProjectBuilder, this.session);
final MavenArtifactModelReader artifactReader = new DefaultMavenArtifactModelReader(this.mavenProjectBuilder,
this.session, this.repositorySystem);
final var mavenModelReader = new DefaultMavenProjectFromFileReader(this.mavenProjectBuilder, this.session);
final MavenModelFromRepositoryReader artifactReader = new MavenModelFromRepositoryReader(
this.mavenProjectBuilder, this.session, this.repositorySystem);
final var pomFile = this.project.getModel().getPomFile();
return List.of(new ProjectFilesValidator(enabledModules, this.project.getBasedir(), excludedFilesMatcher),
new PomFileValidator(enabledModules, this.excludedPlugins, pomFile),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,35 @@
import java.io.File;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Model;
import org.apache.maven.project.*;

import com.exasol.errorreporting.ExaError;

/**
* Implementation of {@link MavenFileModelReader} using the {@link ProjectBuilder} that is injected by Maven core to
* Mojo.
* Implementation of {@link MavenProjectFromFileReader} using the {@link ProjectBuilder} that is injected by Maven core
* to Mojo.
*/
public class DefaultMavenFileModelReader implements MavenFileModelReader {
public class DefaultMavenProjectFromFileReader implements MavenProjectFromFileReader {
private final ProjectBuilder mavenProjectBuilder;
private final MavenSession session;

/**
* Create a new instance of {@link DefaultMavenFileModelReader}.
* Create a new instance of {@link DefaultMavenProjectFromFileReader}.
*
* @param mavenProjectBuilder maven project builder
* @param session maven session
*/
public DefaultMavenFileModelReader(final ProjectBuilder mavenProjectBuilder, final MavenSession session) {
public DefaultMavenProjectFromFileReader(final ProjectBuilder mavenProjectBuilder, final MavenSession session) {
this.mavenProjectBuilder = mavenProjectBuilder;
this.session = session;
}

@Override
public Model readModel(final File pomFile) throws ReadFailedException {
public MavenProject readProject(final File pomFile) throws ReadFailedException {
try {
final ProjectBuildingResult build = this.mavenProjectBuilder.build(pomFile,
this.session.getProjectBuildingRequest());
return build.getProject().getModel();
return build.getProject();
} catch (final ProjectBuildingException exception) {
throw new ReadFailedException(
ExaError.messageBuilder("E-PK-46").message("Failed to build maven model.").toString(), exception);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.exasol.projectkeeper.pom;

import java.util.List;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Model;
import org.apache.maven.project.*;
import org.apache.maven.repository.RepositorySystem;

/**
* Read a maven {@link Model} from an artifact of the maven repository using the {@link ProjectBuilder} that is injected
* by Maven core to Mojo.
*/
public class MavenModelFromRepositoryReader {
private final ProjectBuilder mavenProjectBuilder;
private final MavenSession session;
private final RepositorySystem repositorySystem;

/**
* Create a new instance of {@link MavenModelFromRepositoryReader}.
*
* @param mavenProjectBuilder maven project builder
* @param session maven session
* @param repositorySystem maven repository system
*/
public MavenModelFromRepositoryReader(final ProjectBuilder mavenProjectBuilder, final MavenSession session,
final RepositorySystem repositorySystem) {
this.mavenProjectBuilder = mavenProjectBuilder;
this.session = session;
this.repositorySystem = repositorySystem;
}

/**
* Read the {@link Model} of an artifact of the maven repository.
*
* @param artifactId maven artifact id
* @param groupId maven groupId
* @param version version
* @param remoteRepositories list of remote repositories
* @return read maven model
* @throws ProjectBuildingException if reading fails
*/
public Model readModel(final String artifactId, final String groupId, final String version,
final List<ArtifactRepository> remoteRepositories) throws ProjectBuildingException {
final Artifact artifactDescription = this.repositorySystem.createProjectArtifact(groupId, artifactId, version);
final ProjectBuildingRequest projectBuildingRequest = this.session.getProjectBuildingRequest();
projectBuildingRequest.setRemoteRepositories(remoteRepositories);
final ProjectBuildingResult build = this.mavenProjectBuilder.build(artifactDescription, projectBuildingRequest);
return build.getProject().getModel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

import java.io.File;

import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;

/**
* Interfaces for classes that read a maven {@link Model} from a pom.xml file.
* Interfaces for classes that read a {@link MavenProject} from a pom.xml file.
*/
public interface MavenFileModelReader {
public interface MavenProjectFromFileReader {
/**
* Read a maven model.
* Read a {@link MavenProject} from pom.xml file.
*
* @param pomFile pom.xml file to read
* @return read model
* @throws ReadFailedException if reading failed
*/
Model readModel(File pomFile) throws ReadFailedException;
MavenProject readProject(File pomFile) throws ReadFailedException;

/**
* Exception that is thrown if the reading failed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.exasol.errorreporting.ExaError;
import com.exasol.projectkeeper.ValidationFinding;
import com.exasol.projectkeeper.Validator;
import com.exasol.projectkeeper.pom.MavenFileModelReader;
import com.exasol.projectkeeper.pom.MavenProjectFromFileReader;

/**
* Validator that checks the existence of the doc/changes/changes_X.X.X.md file for the current project's version.
Expand All @@ -21,7 +21,7 @@ public class ChangesFileValidator implements Validator {
private final Path changesFileAbsolutePath;
private final Path projectDirectory;
private final String projectVersion;
private final MavenFileModelReader mavenModelReader;
private final MavenProjectFromFileReader mavenModelReader;

/**
* Create a new instance of {@link ChangesFileValidator}
Expand All @@ -32,7 +32,7 @@ public class ChangesFileValidator implements Validator {
* @param mavenModelReader reader for maven models
*/
public ChangesFileValidator(final String projectVersion, final String projectName, final Path projectDirectory,
final MavenFileModelReader mavenModelReader) {
final MavenProjectFromFileReader mavenModelReader) {
this.projectVersion = projectVersion;
this.relativePathToChangesFile = Path.of("doc", "changes", "changes_" + projectVersion + ".md");
this.projectName = projectName;
Expand Down
Loading

0 comments on commit 5734827

Please sign in to comment.