mockito / shipkit

Toolkit for shipping it used by Mockito library
http://shipkit.org
MIT License
158 stars 35 forks source link

Make license used for pom configurable #760

Open epeee opened 6 years ago

epeee commented 6 years ago

Very first draft (#755).

This pr extends shipkit configuration in a way that we have to configure the license used (incl url now).

shipkit {
    ...

    licenseInfo.license = "Eclipse Public License v2.0"
    licenseInfo.url = "http://www.eclipse.org/legal/epl-v20.html"
}

This will end up in a pom like

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  ...
  <licenses>
    <license>
      <name>Eclipse Public License v2.0</name>
      <url>http://www.eclipse.org/legal/epl-v20.html</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  ...

The downside of this approach is that we still have to configure the license used by gradle bintray plugin, e.g.:

        bintray {
            pkg {
                ...
                licenses = ['EPL-2.0']
        ...

We could add this one also to shipkit config and do the configuration in our gradle plugin. As a result we'd have the license config in one place.

Note: this is a breaking change and will cause builds without a shipkit.licenseInfo configuration to fail:

Execution failed for task ':api:generatePomFileForJavaLibraryPublication'.
> Could not apply withXml() to generated POM
   > Please configure 'shipkit.licenseInfo.license' value (String).
mstachniuk commented 6 years ago

@epeee Maybe you can read somehow Bintray plugin property to avoid duplication? @mockitoguy any hint?

jpkrohling commented 6 years ago

Any updates on this one?

jpkrohling commented 6 years ago

Bump?

mockitoguy commented 5 years ago

Looking at it. I met @epeee at CodeOne conference and he mentioned that his PR needs bump. @jpkrohling, sorry for slow turnaround! I'm on it.

mockitoguy commented 5 years ago

Hey @epeee, I will review and provide my feedback shortly. In the meantime, I commented on the ticket so that @jpkrohling is unblocked and can customize the pom.

mstachniuk commented 5 years ago

I found a hack how to get license info from bintray configuration. @epeee @mockitoguy WDYT?

        Object bintray = project.getExtensions().findByName("bintray");

        try {
            Method getPkg = bintray.getClass().getDeclaredMethod("getPkg");
            getPkg.setAccessible(true);
            Object pkg = getPkg.invoke(bintray);
            Field licensesField = pkg.getClass().getDeclaredField("licenses");
            licensesField.setAccessible(true);
            String[] licenses = (String[]) licensesField.get(pkg);
            for (String license : licenses) {
                LOG.lifecycle(" lic " + license);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
mockitoguy commented 5 years ago

I found a hack how to get license info from bintray configuration

Please no :) That's a lot of complexity for little benefit.

mstachniuk commented 5 years ago

It's a simple reflection ;-) But as you wish!

mockitoguy commented 5 years ago

Once we merge it, can we get the license value populated to the Bintray extension, too? Thanks!!! Nice change!

mockitoguy commented 5 years ago

Before merging, we need to add defaults (as my comment) or make it "lenient". I suggest to add defaults because it is simpler and more useful. Then we can merge :) Let me know when you're ready!