Skip to content

Commit

Permalink
Issue 1723: Make it possible to specify the license types of test art…
Browse files Browse the repository at this point in the history
…ifacts

Issue 1724: Make it possible to specify the license types of Maven test artifacts
  • Loading branch information
carlspring committed Apr 11, 2020
1 parent f773842 commit ac7fd83
Show file tree
Hide file tree
Showing 17 changed files with 2,645 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package org.carlspring.strongbox.artifact.generator;

import org.carlspring.strongbox.testing.artifact.LicenseConfig;

import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.nio.file.Path;

import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;

/**
* @author sbespalov
*
*/
public interface ArtifactGenerator
{
Expand Down Expand Up @@ -39,4 +44,13 @@ Path generateArtifact(URI uri,
long size)
throws IOException;

default void copyLicenseFile(LicenseConfig licenseConfig, OutputStream os)
throws IOException
{
ClassPathResource resource = new ClassPathResource(licenseConfig.license().getLicenseFileSourcePath(),
this.getClass().getClassLoader());

IOUtils.copy(resource.getInputStream(), os);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.carlspring.strongbox.testing.artifact;

import java.lang.annotation.*;

/**
* This annotation helps configure license details for test artifacts.
*
* @author carlspring
*/
@Target({ ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface LicenseConfig
{

LicenseType license() default LicenseType.NONE;

String destinationPath() default "LICENSE";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.carlspring.strongbox.testing.artifact;

/**
* This class contains some common licenses that can be used when generating test artifacts.
*
* @author carlspring
*/
public enum LicenseType
{

APACHE_2_0("Apache 2.0", "apache-2.0", "http://www.apache.org/licenses/LICENSE-2.0"),

AGPL_3_0("GNU Affero General Public License", "agpl-3.0", "https://www.gnu.org/licenses/agpl-3.0.en.html"),

BSL_1_0("Boost Software License 1.0", "bsl-1.0", "https://www.boost.org/users/license.html"),

EPL_2_0("Eclipse Public License 2.0", "epl-1.0", "https://www.eclipse.org/legal/epl-2.0/"),

GPL_3_0("GNU General Public License", "gpl-3.0", "https://www.gnu.org/licenses/gpl-3.0.en.html"),

LGPL_3_0("GNU Lesser General Public License version 3", "lgpl-3.0", "https://www.gnu.org/licenses/lgpl-3.0.en.html"),

MIT("MIT License", "mit", "https://opensource.org/licenses/MIT"),

MPL_2_0("Mozilla Public License Version 2.0", "mpl", "https://www.mozilla.org/en-US/MPL/2.0/"),

UNLICENSE("Unlicense", "unlicense", "https://unlicense.org/"),

NONE(null, null, null);

private String name;

private String shortName;

private String url;


LicenseType(String name, String shortName, String url)
{
this.name = name;
this.shortName = shortName;
this.url = url;
}

public String getName()
{
return name;
}

public String getShortName()
{
return shortName;
}

public String getUrl()
{
return url;
}

public String getLicenseFileSourcePath()
{
return "licenses/" + shortName + "/LICENSE.md";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
These licenses are only for the use with test generated artifacts.
They are not a replacement of the Strongbox project's license in any way.
Loading

0 comments on commit ac7fd83

Please sign in to comment.