Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves #809: Extract the apis and common services to a separate module #810

Merged
merged 1 commit into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<module>versions-maven-plugin</module>
<module>model-ruleset</module>
<module>model-report</module>
<module>versions-common</module>
</modules>

<scm>
Expand Down
123 changes: 123 additions & 0 deletions versions-common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>versions</artifactId>
<groupId>org.codehaus.mojo.versions</groupId>
<version>2.14.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>versions-common</artifactId>

<name>Versions Common</name>
<description>Common components for the Versions Maven Plugin</description>

<dependencies>
<dependency>
<groupId>org.codehaus.mojo.versions</groupId>
<artifactId>model-ruleset</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
<version>${wagonVersion}</version>
<scope>provided</scope>
</dependency>
<!-- woodstox only used for unit tests -->
<dependency>
<groupId>com.fasterxml.woodstox</groupId>
<artifactId>woodstox-core</artifactId>
<scope>test</scope>
</dependency>
<!-- wagon only used for unit tests -->
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<version>${wagonVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.authentication.AuthenticationException;
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.codehaus.mojo.versions.PluginUpdatesDetails;
import org.codehaus.mojo.versions.Property;
import org.codehaus.mojo.versions.model.IgnoreVersion;
import org.codehaus.mojo.versions.model.Rule;
import org.codehaus.mojo.versions.model.RuleSet;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.codehaus.mojo.versions;
package org.codehaus.mojo.versions.api;

/*
* Licensed to the Apache Software Foundation (ASF) under one
Expand All @@ -24,7 +24,6 @@

import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.model.Dependency;
import org.codehaus.mojo.versions.api.ArtifactVersions;

import static java.util.Optional.empty;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.codehaus.mojo.versions;
package org.codehaus.mojo.versions.api;

/*
* Licensed to the Apache Software Foundation (ASF) under one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.apache.maven.artifact.versioning.Restriction;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.project.MavenProject;
import org.codehaus.mojo.versions.Property;
import org.codehaus.mojo.versions.ordering.BoundArtifactVersion;
import org.codehaus.mojo.versions.ordering.InvalidSegmentException;
import org.codehaus.mojo.versions.ordering.VersionComparator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.mojo.versions.PluginUpdatesDetails;
import org.codehaus.mojo.versions.Property;
import org.codehaus.mojo.versions.ordering.VersionComparator;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;

Expand Down Expand Up @@ -188,7 +186,7 @@ ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePlug
*
* @param plugins The set of {@link Plugin} instances to look up.
* @param allowSnapshots Include snapshots in the list of updates.
* @return A map, keyed by plugin, with values of type {@link org.codehaus.mojo.versions.PluginUpdatesDetails}.
* @return A map, keyed by plugin, with values of type {@link org.codehaus.mojo.versions.api.PluginUpdatesDetails}.
* @throws ArtifactMetadataRetrievalException When things go wrong.
* @since 1.0-beta-1
*/
Expand Down Expand Up @@ -218,12 +216,12 @@ PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots

/**
* Returns a map of {@link org.codehaus.mojo.versions.api.PropertyVersions} values keyed by
* {@link org.codehaus.mojo.versions.Property} instances consisting of the properties defined in the project which
* {@link Property} instances consisting of the properties defined in the project which
* are associated with version information.
*
* @param request {@link VersionPropertiesMapRequest} instance containing the arguments
* @return a map of {@link org.codehaus.mojo.versions.api.PropertyVersions} values keyed by
* {@link org.codehaus.mojo.versions.Property} instances.
* {@link Property} instances.
* @throws MojoExecutionException if something goes wrong.
*/
Map<Property, PropertyVersions> getVersionPropertiesMap( VersionPropertiesMapRequest request )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
package org.codehaus.mojo.versions.filtering;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.List;
import java.util.Set;
import java.util.TreeSet;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.codehaus.mojo.versions.filtering;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

public class NullAwareWildcardMatcher extends WildcardMatcher
{
public static final String NULL_KEYWORD = "null";

public NullAwareWildcardMatcher( String pattern )
{
super( pattern );
}

@Override
public boolean test( String token )
{
if ( NULL_KEYWORD.equals( getPattern() ) )
{
return token == null;
}

return super.test( token );
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
package org.codehaus.mojo.versions.utils;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
Expand All @@ -9,8 +28,11 @@
import java.util.Properties;
import java.util.stream.Collectors;

import org.codehaus.mojo.versions.Property;
import org.codehaus.mojo.versions.api.Property;

/**
* Reader class for reading property files
*/
public class PropertiesVersionsFileReader
{

Expand All @@ -23,11 +45,19 @@ public class PropertiesVersionsFileReader

private String propertyFilePath;

/**
* Creates an instance of the object with the given path to the property file
* @param filePath path to the property file
*/
public PropertiesVersionsFileReader( String filePath )
{
propertyFilePath = filePath;
}

/**
* Reads the property file
* @throws IOException thrown if an I/O exception occurs during the read operation
*/
public void read() throws IOException
{
try ( InputStream input = Files.newInputStream( Paths.get( propertyFilePath ) ) )
Expand Down Expand Up @@ -55,11 +85,19 @@ public void read() throws IOException
}
}

/**
* Returns the string contents of the property file
* @return contents of the property file
*/
public String getProperties()
{
return propertiesCsv;
}

/**
* Returns the array of {@link Property} objects
* @return array of properties
*/
public Property[] getPropertiesConfig()
{
return propertiesConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Comparator;

import org.apache.commons.lang3.StringUtils;
import org.codehaus.mojo.versions.Property;
import org.codehaus.mojo.versions.api.Property;

/**
* A comparator used to sort {@link Property} instances.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.apache.maven.project.artifact.MavenMetadataSource;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.settings.Settings;
import org.codehaus.mojo.versions.Property;
import org.codehaus.mojo.versions.model.IgnoreVersion;
import org.codehaus.mojo.versions.model.Rule;
import org.codehaus.mojo.versions.model.RuleSet;
Expand Down
Loading