Skip to content

Commit

Permalink
Require Java 8
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Jul 31, 2021
1 parent b022ab0 commit 00ff3ad
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 66 deletions.
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions appveyor.yml
Expand Up @@ -5,11 +5,10 @@ skip_tags: true
clone_depth: 10
environment:
matrix:
- JAVA_HOME: C:\Program Files\Java\jdk1.7.0
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- JAVA_HOME: C:\Program Files\Java\jdk11

build_script:
- mvn -B -V clean verify -Dhttps.protocols=TLSv1.2
- mvn -B -V clean verify
cache:
- C:\Users\appveyor\.m2
11 changes: 4 additions & 7 deletions pom.xml
Expand Up @@ -93,6 +93,7 @@
-->
<enforcerPluginVersion>1.4</enforcerPluginVersion>
<maven.version>2.0.9</maven.version>
<mojo.java.target>1.8</mojo.java.target>
<scmpublish.content>target/staging/${project.artifactId}</scmpublish.content>
<project.build.outputTimestamp>2021-02-06T08:02:09Z</project.build.outputTimestamp>
</properties>
Expand Down Expand Up @@ -210,10 +211,6 @@
<preBuildHookScript>setup</preBuildHookScript>
<postBuildHookScript>verify</postBuildHookScript>
<addTestClassPath>true</addTestClassPath>
<properties>
<!-- e.g. ensure that Java7 picks up TLSv1.2 when connecting with Central -->
<https.protocols>TLSv1.2</https.protocols>
</properties>
<filterProperties>
<enforcerPluginVersion>${enforcerPluginVersion}</enforcerPluginVersion>
</filterProperties>
Expand Down Expand Up @@ -249,9 +246,9 @@
<jdk>[12,)</jdk>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.release>7</maven.compiler.release>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.release>8</maven.compiler.release>
</properties>
</profile>
</profiles>
Expand Down
Expand Up @@ -146,7 +146,7 @@ final Set<String> getRolesFromProject( MavenProject mavenProject )
*/
Set<String> getRolesFromString( final String toSet )
{
final List<String> asList = Arrays.asList( StringUtils.split( toSet, "," ) );
final String[] asList = StringUtils.split( toSet, "," );
final Set<String> result = new HashSet<>();
for ( String role : asList )
{
Expand Down
Expand Up @@ -92,9 +92,8 @@ public void execute( EnforcerRuleHelper helper )
log.debug( "artifactId: " + artifact.getArtifactId() + " " + project.getArtifactId() );
if ( artifact.getArtifactId().equals( project.getArtifactId() ) )
{
StringBuilder buf = new StringBuilder( getErrorMessage() );
buf.append( "\n " ).append( artifact.getGroupId() ).append( ":" ).append( artifact.getArtifactId() ).append( "\n " );
throw new EnforcerRuleException( buf.toString() );
throw new EnforcerRuleException( getErrorMessage() + "\n " + artifact.getGroupId()
+ ":" + artifact.getArtifactId() + "\n " );
}
}
}
Expand Down
Expand Up @@ -134,7 +134,7 @@ protected void handleArtifacts( Set<Artifact> artifacts ) throws EnforcerRuleExc
{
if( getLog().isDebugEnabled() )
{
getLog().debug( "Skipping " + o.toString() + " due to scope" );
getLog().debug( "Skipping " + o + " due to scope" );
}
continue;
}
Expand All @@ -157,7 +157,7 @@ else if ( file.isDirectory() )
catch ( IOException e )
{
throw new EnforcerRuleException(
"Unable to process dependency " + o.toString() + " due to " + e.getLocalizedMessage(), e );
"Unable to process dependency " + o + " due to " + e.getLocalizedMessage(), e );
}
}
else if ( isJarFile( o ) )
Expand All @@ -177,7 +177,7 @@ else if ( isJarFile( o ) )
catch ( IOException e )
{
throw new EnforcerRuleException(
"Unable to process dependency " + o.toString() + " due to " + e.getLocalizedMessage(), e );
"Unable to process dependency " + o + " due to " + e.getLocalizedMessage(), e );
}
}
}
Expand Down Expand Up @@ -267,19 +267,18 @@ private void checkAndAddName( Artifact artifact, String pathToClassFile, Map<Str
{
Artifact previousArtifact = classesWithSameName.previous().getArtifactThisClassWasFoundIn();

StringBuilder buf = new StringBuilder( message == null ? "Duplicate class found:" : message );
buf.append( '\n' );
buf.append( "\n Found in:" );
buf.append( "\n " );
buf.append( previousArtifact );
buf.append( "\n " );
buf.append( artifact );
buf.append( "\n Duplicate classes:" );
buf.append( "\n " );
buf.append( pathToClassFile );
buf.append( '\n' );
buf.append( "There may be others but <findAllDuplicates> was set to false, so failing fast" );
throw new EnforcerRuleException( buf.toString() );
String buf = ( message == null ? "Duplicate class found:" : message ) + '\n'
+ "\n Found in:"
+ "\n "
+ previousArtifact
+ "\n "
+ artifact
+ "\n Duplicate classes:"
+ "\n "
+ pathToClassFile
+ '\n'
+ "There may be others but <findAllDuplicates> was set to false, so failing fast";
throw new EnforcerRuleException( buf );
}
}
}
Expand Up @@ -201,7 +201,7 @@ protected void handleArtifacts( Set<Artifact> artifacts )
{
buf.append( getErrorMessage( artifact ) );
}
message = buf.toString() + "Use 'mvn dependency:tree' to locate the source of the banned dependencies.";
message = buf + "Use 'mvn dependency:tree' to locate the source of the banned dependencies.";

throw new EnforcerRuleException( message );
}
Expand Down Expand Up @@ -432,7 +432,7 @@ public void setSearchTransitive( boolean theSearchTransitive )
*/
private Set<Artifact> filterArtifacts( Set<Artifact> dependencies )
{
if ( includes == null && excludes == null && ignoredScopes == null && ignoreOptionals == false )
if ( includes == null && excludes == null && ignoredScopes == null && !ignoreOptionals )
{
return dependencies;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/freebsd/file/FileEncoding.java
Expand Up @@ -387,7 +387,7 @@ private int looks_ucs16( byte[] buf, int nbytes )
{
return 0;
}
if ( ubuf[ ulen - 1 ] < 128 && text_chars[ (int) ubuf[ ulen - 1 ] ] != T )
if ( ubuf[ ulen - 1 ] < 128 && text_chars[ubuf[ ulen - 1 ]] != T )
{
return 0;
}
Expand Down
@@ -1,5 +1,6 @@
package org.apache.maven.plugins.enforcer;

import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -9,13 +10,9 @@
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.plugin.logging.Log;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class RequireEncodingTest {
@Rule
public ExpectedException exception = ExpectedException.none();

private EnforcerRuleHelper helper;
private RequireEncoding rule;
Expand All @@ -35,7 +32,6 @@ public void failUTF8() throws Exception {

rule.setIncludes("ascii.txt");

exception.expect(EnforcerRuleException.class);
rule.execute(helper);
assertThrows(EnforcerRuleException.class, () -> rule.execute(helper) );
}
}

0 comments on commit 00ff3ad

Please sign in to comment.