You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by matthiasblaesing <gi...@git.apache.org> on 2017/10/08 12:12:48 UTC

[GitHub] incubator-netbeans pull request #97: Add support for specifying classifier a...

GitHub user matthiasblaesing opened a pull request:

    https://github.com/apache/incubator-netbeans/pull/97

    Add support for specifying classifier and extension for maven binaries

    Some modules not only load plain artifacts from maven, but also need
    additional parts. In maven the primary artifact can be accompanied by
    additional files, that have the same base name, but are seperated by
    a classifier (javadoc and sources for example).
    
    What is more it is possible to publish artifacts with different
    extensions than "jar".
    
    This commit introduces support for this. The format for maven
    coordinates is expanded from:
    
    group:artifact:version
    
    to
    
    group:artifact:version:classifier@extension
    
    Both classifier and extension are optional and the default for extension
    is "jar", so this change is compatible.
    
    The format follows the short version of gradle dependencies:
    
    https://docs.gradle.org/4.2.1/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html
    
    Section "External dependencies"
    
    -------------
    
    A sample where this is needed can be found in the libs.jaxb module:
    https://github.com/apache/incubator-netbeans/blob/master/libs.jaxb/external/binaries-list
    
    jaxb-api-doc.zip would then replaced by javax.xml.bind:jaxb-api:2.2.5:javadoc

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/matthiasblaesing/incubator-netbeans maven_classifier_extension

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-netbeans/pull/97.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #97
    
----
commit 5c773910524b785e35c5b45d73c5ac42534669d3
Author: Matthias Bläsing <mb...@doppel-helix.eu>
Date:   2017-10-08T12:07:24Z

    Add support for specifying classifier and extension for maven binaries
    
    Some modules not only load plain artifacts from maven, but also need
    additional parts. In maven the primary artifact can be accompanied by
    additional files, that have the same base name, but are seperated by
    a classifier (javadoc and sources for example).
    
    What is more it is possible to publish artifacts with different
    extensions than "jar".
    
    This commit introduces support for this. The format for maven
    coordinates is expanded from:
    
    group:artifact:version
    
    to
    
    group:artifact:version:classifier@extension
    
    Both classifier and extension are optional and the default for extension
    is "jar", so this change is compatible.
    
    The format follows the short version of gradle dependencies:
    
    https://docs.gradle.org/4.2.1/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html
    
    Section "External dependencies"

----


---

[GitHub] incubator-netbeans issue #97: Add support for specifying classifier and exte...

Posted by matthiasblaesing <gi...@git.apache.org>.
Github user matthiasblaesing commented on the issue:

    https://github.com/apache/incubator-netbeans/pull/97
  
    The external files directory does not directly correspond with installed binaries. They are copied over and can be renamed when doing this. I had a look in libs.jaxb and would say, with the download task modified, this changeset should cover the external binaries:
    
    ```patch
    # This patch file was generated by NetBeans IDE
    # It uses platform neutral UTF-8 encoding and \n newlines.
    --- a/libs.jaxb/external/binaries-list
    +++ b/libs.jaxb/external/binaries-list
    @@ -14,7 +14,7 @@
     # KIND, either express or implied.  See the License for the
     # specific language governing permissions and limitations
     # under the License.
    -387BE740EAEF52B3F6E6EE2F140757E7632584CE jaxb-impl.jar
    -F4DB465F207907A2406B0BF5C8FFEE22A5C3E4E3 jaxb1-impl.jar
    -C3787DAB0DDFBD9E98086ED2F219859B0CB77EF7 jaxb-xjc.jar
    -27FAE927B5B9AE53A5B0ED825575DD8217CE7042 jaxb-api-doc.zip
    +387BE740EAEF52B3F6E6EE2F140757E7632584CE com.sun.xml.bind:jaxb-impl:2.2.5-2
    +F4DB465F207907A2406B0BF5C8FFEE22A5C3E4E3 com.sun.xml.bind:jaxb1-impl:2.2.5-2
    +C3787DAB0DDFBD9E98086ED2F219859B0CB77EF7 com.sun.xml.bind:jaxb-xjc:2.2.5-2
    +DEA09C627DA5AA8FB0E6B1E39F85B2AE6AE9C3E7 javax.xml.bind:jaxb-api:2.2.5:javadoc
    # This patch file was generated by NetBeans IDE
    # It uses platform neutral UTF-8 encoding and \n newlines.
    --- a/libs.jaxb/nbproject/project.properties
    +++ b/libs.jaxb/nbproject/project.properties
    @@ -26,11 +26,11 @@
     # pack200 bug in JDK 7 (#7131266)
     pack200.excludes=modules/ext/jaxb/jaxb-xjc.jar
     
    -release.external/jaxb-impl.jar=modules/ext/jaxb/jaxb-impl.jar
    -release.external/jaxb1-impl.jar=modules/ext/jaxb/jaxb1-impl.jar
    -release.external/jaxb-xjc.jar=modules/ext/jaxb/jaxb-xjc.jar
    +release.external/jaxb-impl-2.2.5-2.jar=modules/ext/jaxb/jaxb-impl.jar
    +release.external/jaxb1-impl-2.2.5-2.jar=modules/ext/jaxb/jaxb1-impl.jar
    +release.external/jaxb-xjc-2.2.5-2.jar=modules/ext/jaxb/jaxb-xjc.jar
     
     # JAXB Javadoc
    -release.external/jaxb-api-doc.zip=docs/jaxb-api-doc.zip
    +release.external/jaxb-api-2.2.5-javadoc.jar=docs/jaxb-api-doc.zip
     
     sigtest.gen.fail.on.error=false
    ```


---

[GitHub] incubator-netbeans issue #97: Add support for specifying classifier and exte...

Posted by geertjanw <gi...@git.apache.org>.
Github user geertjanw commented on the issue:

    https://github.com/apache/incubator-netbeans/pull/97
  
    Can someone merge this, I need it.


---

[GitHub] incubator-netbeans issue #97: Add support for specifying classifier and exte...

Posted by JaroslavTulach <gi...@git.apache.org>.
Github user JaroslavTulach commented on the issue:

    https://github.com/apache/incubator-netbeans/pull/97
  
    Feel free to proceed with integration. +1


---

[GitHub] incubator-netbeans pull request #97: Add support for specifying classifier a...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-netbeans/pull/97


---

[GitHub] incubator-netbeans issue #97: Add support for specifying classifier and exte...

Posted by matthiasblaesing <gi...@git.apache.org>.
Github user matthiasblaesing commented on the issue:

    https://github.com/apache/incubator-netbeans/pull/97
  
    Merged - thanks for looking into this.
    
    @vieiro @geertjanw you both asked for it - the change is now in master.


---

[GitHub] incubator-netbeans pull request #97: Add support for specifying classifier a...

Posted by JaroslavTulach <gi...@git.apache.org>.
Github user JaroslavTulach commented on a diff in the pull request:

    https://github.com/apache/incubator-netbeans/pull/97#discussion_r143400960
  
    --- Diff: nbbuild/antsrc/org/netbeans/nbbuild/extlibs/DownloadBinaries.java ---
    @@ -415,16 +406,113 @@ private String hash(InputStream is) throws IOException {
             return String.format("%040X", new BigInteger(1, digest.digest()));
         }
     
    -    static boolean isMavenFile(String... hashAndId) {
    -        return hashAndId[1].split(":").length > 2;
    -    }
    -    static String mavenFileName(String... hashAndId) {
    -        assert isMavenFile(hashAndId);
    -        String[] artifactGroupVersion = hashAndId[1].split(":");
    -        return artifactGroupVersion[1] + "-" + artifactGroupVersion[2] + ".jar";
    -    }
    +    static class MavenCoordinate {
    +        private final String groupId;
    +        private final String artifactId;
    +        private final String version;
    +        private final String extension;
    +        private final String classifier;
     
    +        private MavenCoordinate(String groupId, String artifactId, String version, String extension, String classifier) {
    +            this.groupId = groupId;
    +            this.artifactId = artifactId;
    +            this.version = version;
    +            this.extension = extension;
    +            this.classifier = classifier;
    +        }
    +        
    +        public boolean hasClassifier() {
    +            return (! classifier.isEmpty());
    +        }
    +
    +        public String getGroupId() {
    +            return groupId;
    +        }
    +
    +        public String getArtifactId() {
    +            return artifactId;
    +        }
    +
    +        public String getVersion() {
    +            return version;
    +        }
     
    +        public String getExtension() {
    +            return extension;
    +        }
    +
    +        public String getClassifier() {
    +            return classifier;
    +        }
    +        
    +        /**
    +         * @return filename of the artifact by maven convention: 
    +         *         {@code artifact-version[-classifier].extension}
    +         */
    +        public String toArtifactFilename() {
    +            return String.format("%s-%s%s.%s",
    +                    getArtifactId(),
    +                    getVersion(),
    +                    hasClassifier() ? ("-" + getClassifier()) : "",
    +                    getExtension()
    +            );
    +        }
    +        
    +        /**
    +         * @return The repository path for an artifact by maven convention: 
    +         *         {@code group/artifact/version/artifact-version[-classifier].extension}.
    +         *         In the group part all dots are replaced by a slash. 
    +         */        
    +        public String toMavenPath() {
    +            return String.format("%s/%s/%s/%s",
    +                    getGroupId().replace(".", "/"),
    +                    getArtifactId(),
    +                    getVersion(),
    +                    toArtifactFilename()
    +                    );
    +        }
    +        
    +        public static boolean isMavenFile(String gradleFormat) {
    +            return gradleFormat.split(":").length > 2;
    +        }
    +        
    +        /**
    +         * The maven coordinate is supplied in the form:
    +         * 
    +         * <p>{@code group:name:version:classifier@extension}</p>
    +         * 
    +         * <p>For the DownloadBinaries task the parts group, name and version
    +         * are requiered. classifier and extension are optional. The extension
    +         * has a default value of "jar".
    --- End diff --
    
    Nice.


---

[GitHub] incubator-netbeans issue #97: Add support for specifying classifier and exte...

Posted by vieiro <gi...@git.apache.org>.
Github user vieiro commented on the issue:

    https://github.com/apache/incubator-netbeans/pull/97
  
    That's not a download task! That's magic!
    Looks perfect to me 👍 


---

[GitHub] incubator-netbeans issue #97: Add support for specifying classifier and exte...

Posted by vieiro <gi...@git.apache.org>.
Github user vieiro commented on the issue:

    https://github.com/apache/incubator-netbeans/pull/97
  
    I'd suggest trying to keep the original filename somehow (i.e., the "jaxb-api-doc.zip" name), as this is referenced to elsewhere:
    
    - In the list of artifacts to be included in the jnlp file [https://github.com/apache/incubator-netbeans/blob/master/libs.jaxb/nbproject/project.properties](https://github.com/apache/incubator-netbeans/blob/master/libs.jaxb/nbproject/project.properties)
    - In the library descriptor (if the module is installed as a NetBeans Library) [https://github.com/apache/incubator-netbeans/blob/master/libs.jaxb/src/org/netbeans/libs/jaxb/jaxb.xml](https://github.com/apache/incubator-netbeans/blob/master/libs.jaxb/src/org/netbeans/libs/jaxb/jaxb.xml).
    
    It would be perfect if we could download stuff from Maven and then rename it to the old name. That way these references won't have to be changed.
    



---