Skip to content
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
10 changes: 4 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version='1.0' encoding='UTF-8'?>

<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
Expand All @@ -18,14 +17,13 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
<version>35</version>
<version>39</version>
<relativePath />
</parent>

Expand All @@ -43,8 +41,8 @@ under the License.
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-ejb-plugin.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-ejb-plugin.git</developerConnection>
<url>https://github.com/apache/maven-ejb-plugin/tree/${project.scm.tag}</url>
<tag>HEAD</tag>
<url>https://github.com/apache/maven-ejb-plugin/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
<system>JIRA</system>
Expand Down Expand Up @@ -159,8 +157,8 @@ under the License.
<build>
<resources>
<resource>
<directory>src/main/filtered-resources</directory>
<filtering>true</filtering>
<directory>src/main/filtered-resources</directory>
</resource>
</resources>
</build>
Expand Down
54 changes: 21 additions & 33 deletions src/main/java/org/apache/maven/plugins/ejb/EjbHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.apache.maven.plugins.ejb;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -18,41 +16,38 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.plugins.ejb;

import java.io.File;

/**
* This class contains some helper methods which do not belong to {@link EjbMojo}.
*
*
* <pre>
* Think about this helper class, cause i've got the impression this can be made better.
* </pre>
*
*
* @author <a href="mailto:khmarbaise@apache.org">Karl Heinz Marbaise</a>
*/
public final class EjbHelper
{
private EjbHelper()
{
public final class EjbHelper {
private EjbHelper() {
// prevent instantiation
}

/**
* Check if a <code>classifier</code> is valid or not.
*
*
* @param classifier The classifier which should be checked.
* @return true in case of a valid <code>classifier</code> false otherwise which includes the case where
* <code>classifier</code> is {@code null}.
*/
public static boolean isClassifierValid( String classifier )
{
public static boolean isClassifierValid(String classifier) {
// @FIXME: Check classifier for trailing dash? "a-0" valid?
// What are the rules for a valid classifier? Somewhere documented? which can be used as a reference?
boolean result = false;

// The following check is only based on an educated guess ;-)
if ( hasClassifier( classifier ) && classifier.matches( "^[a-zA-Z]+[0-9a-zA-Z\\-]*" ) )
{
if (hasClassifier(classifier) && classifier.matches("^[a-zA-Z]+[0-9a-zA-Z\\-]*")) {
result = true;
}

Expand All @@ -62,15 +57,13 @@ public static boolean isClassifierValid( String classifier )
/**
* Check if the given classifier exists in the meaning of not being {@code null} and contain something else than
* only white spaces.
*
*
* @param classifier The classifier to be used.
* @return true in case when the given classifier is not {@code null} and contains something else than white spaces.
*/
public static boolean hasClassifier( String classifier )
{
public static boolean hasClassifier(String classifier) {
boolean result = false;
if ( classifier != null && classifier.trim().length() > 0 )
{
if (classifier != null && classifier.trim().length() > 0) {
result = true;
}
return result;
Expand All @@ -84,27 +77,22 @@ public static boolean hasClassifier( String classifier )
* @param classifier an optional classifier
* @return the file to generate
*/
public static File getJarFile( File basedir, String finalName, String classifier )
{
if ( basedir == null )
{
throw new IllegalArgumentException( "basedir is not allowed to be null" );
public static File getJarFile(File basedir, String finalName, String classifier) {
if (basedir == null) {
throw new IllegalArgumentException("basedir is not allowed to be null");
}
if ( finalName == null )
{
throw new IllegalArgumentException( "finalName is not allowed to be null" );
if (finalName == null) {
throw new IllegalArgumentException("finalName is not allowed to be null");
}

StringBuilder fileName = new StringBuilder( finalName );
StringBuilder fileName = new StringBuilder(finalName);

if ( hasClassifier( classifier ) )
{
fileName.append( "-" ).append( classifier );
if (hasClassifier(classifier)) {
fileName.append("-").append(classifier);
}

fileName.append( ".jar" );
fileName.append(".jar");

return new File( basedir, fileName.toString() );
return new File(basedir, fileName.toString());
}

}
Loading