You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/05/25 12:18:34 UTC

[GitHub] [netbeans] sdedic opened a new pull request, #4149: Initial implementation of Project Dependency API

sdedic opened a new pull request, #4149:
URL: https://github.com/apache/netbeans/pull/4149

   We have API to get inter-**project** dependencies, but we do not have an API to get a view on dependencies incl. external resources. There's a possibility to get a ClassPath (for Java) enumerating all necessary resources as a flat list, but if one would like to get structure information ... there's probably no way.
   
   This PR is an attempt to define some abstractions, which could eventually become part of `project.api`. They probably won't fit to good old ANT projects (but if someone finds a suitable adjustment that would make `ArtifactSpec` more Ant-like, please share your thoughts !!), but for example NetBeans modules (although ant-based) could make it.
   
   The initial goal is to provide a structured view, a dependency tree, such as `maven dependency:tree` or `gradle dependencies`. The project may start to report its product (artifact, or artifacts ?) and later a project-type-neutral way can be offered to map a resource (e.g. jar) to an artifact known to a project. All this is TBD.
   
   The API is initially implemented as private; `implementation dependency` is reuquired to use/implement it. This will change after the constructs are validated on more project types.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on a diff in pull request #4149: Initial implementation of Project Dependency API

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4149:
URL: https://github.com/apache/netbeans/pull/4149#discussion_r881792777


##########
ide/project.dependency/src/org/netbeans/modules/project/dependency/ArtifactSpec.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.project.dependency;
+
+import java.util.Objects;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.annotations.common.NullAllowed;
+
+/**
+ * Represents an artifact. Each artifact is identified by
+ * <ul>
+ * <li>group or organization id
+ * <li>artifact id
+ * <li>version
+ * <li>(optional) classifier; no classifier shall be interpreted as a
+ * regular build artifact
+ * <li>(optional) type; not type shall be interepreted as the default type
+ * for the processing compiler or builder
+ * </ul>
+ * The version specified is further classified by {@link VersionKind}, to 
+ * distinguish versions possibly from repositories, development versions and
+ * floating versions.
+ * 
+ * @author sdedic
+ */
+public final class ArtifactSpec<T> {
+    /**
+     * Kind of the artifact version
+     */
+    public enum VersionKind {
+        /**
+         * Regular publishable artifact
+         */
+        REGULAR, 
+        
+        /**
+         * Snapshot artifact
+         */
+        SNAPSHOT, 
+        
+        /**
+         * Regular artifact, floating version
+         */
+        LATEST
+    };
+    
+    private final VersionKind kind;
+    private final String type;
+    private final String groupId;
+    private final String artifactId;
+    private final String versionSpec;
+    private final String classifier;
+    private final boolean optional;
+    final T data;
+
+    ArtifactSpec(VersionKind kind, String groupId, String artifactId, String versionSpec, String type, String classifier, boolean optional, T impl) {
+        this.kind = kind;
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+        this.versionSpec = versionSpec;
+        this.classifier = classifier;
+        this.optional = optional;
+        this.data = impl;
+        this.type = type;
+    }
+
+    public VersionKind getKind() {
+        return kind;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public String getArtifactId() {
+        return artifactId;
+    }
+
+    public String getVersionSpec() {
+        return versionSpec;
+    }
+
+    public String getClassifier() {
+        return classifier;
+    }
+
+    public boolean isOptional() {
+        return optional;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 79 * hash + Objects.hashCode(this.kind);
+        hash = 79 * hash + Objects.hashCode(this.type);
+        hash = 79 * hash + Objects.hashCode(this.groupId);
+        hash = 79 * hash + Objects.hashCode(this.artifactId);
+        hash = 79 * hash + Objects.hashCode(this.versionSpec);
+        hash = 79 * hash + Objects.hashCode(this.classifier);
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final ArtifactSpec<?> other = (ArtifactSpec<?>) obj;
+        if (!Objects.equals(this.type, other.type)) {
+            return false;
+        }
+        if (!Objects.equals(this.groupId, other.groupId)) {
+            return false;
+        }
+        if (!Objects.equals(this.artifactId, other.artifactId)) {
+            return false;
+        }
+        if (!Objects.equals(this.versionSpec, other.versionSpec)) {
+            return false;
+        }
+        if (!Objects.equals(this.classifier, other.classifier)) {
+            return false;
+        }
+        return this.kind == other.kind;
+    }
+    
+    public String toString() {
+        StringBuilder sb = new StringBuilder(
+            String.format("%s:%s:%s", getGroupId(), getArtifactId(), getVersionSpec() == null ? "" : getVersionSpec())
+        );
+        if (classifier != null) {
+            sb.append(":").append(classifier);
+        }
+        if (type != null) {
+            sb.append("[").append(type).append("]");
+        }
+        if (optional) {
+            sb.append("?");
+        }
+        return sb.toString();
+    }
+    
+    /**
+     * Returns opaque project-specific data. If searching for
+     * a project-specific extension, use {@link ProjectDependencies#findAdapters} instead.
+     * 
+     * @return unspecified underlying project data
+     */
+    public T getProjectData() {
+        return data;
+    }
+    
+    public static <V> ArtifactSpec<V> createVersionSpec(
+            @NonNull String groupId, @NonNull String artifactId, 
+            @NullAllowed String type, @NullAllowed String classifier, 
+            @NonNull String versionSpec, boolean optional, @NonNull V data) {
+        return new ArtifactSpec<V>(VersionKind.REGULAR, groupId, artifactId, versionSpec, type, classifier, optional, data);
+    }
+
+    public static <V> ArtifactSpec<V> createSnapshotSpec(
+            @NonNull String groupId, @NonNull String artifactId, 
+            @NullAllowed String type, @NullAllowed String classifier, 
+            @NonNull String versionSpec, boolean optional, @NonNull V data) {
+        return new ArtifactSpec<V>(VersionKind.SNAPSHOT, groupId, artifactId, versionSpec, type, classifier, false, data);
+    }
+

Review Comment:
   will remove. Can be added later.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lkishalmi commented on pull request #4149: Initial implementation of Project Dependency API

Posted by GitBox <gi...@apache.org>.
lkishalmi commented on PR #4149:
URL: https://github.com/apache/netbeans/pull/4149#issuecomment-1139146730

   It's an interesting start. Too "mavenly" though at the moment. I'd let give it a go, though when applying to Gradle there would be some interesting questions how would could we handle includedBuild substitutes, and different outgoing variants. Also the question is there, should we handle these at all?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on pull request #4149: Initial implementation of Project Dependency API

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4149:
URL: https://github.com/apache/netbeans/pull/4149#issuecomment-1139368993

   > It's an interesting start. Too "mavenly" though at the moment. I'd let give it a go, though when applying to Gradle there would be some interesting questions how would could we handle includedBuild substitutes, and different outgoing variants. Also the question is there, should we handle these at all?
   
   I guess I may need your expertise in Gradle area here. Just OTOH (given the API), we might not even care, as the includedBuild (if I understood correctly) just replaces dependency with project dependency, but the project product artifact is still there. The dependency graph is also a snapshot of the final artifact resolution, so (IMHO) no change with included builds.
   
   I thouhgt about adding extension services for the additional queries (e.g. one could determine build segments / included builds), which could be project-type-dependent or (if we find a suitable abstraction) project independent - that's why raw (unspecified) data is exposed from ArtifactSpec / Dependency. I thought  about adding a `Lookup.Provider` to the `DependencyResult` to offer snapshot-bound additional services; but I was not able to see the details at the time of design.
   
   BTW - maybe the Maven Graph could be adapted to this API to see  graph dependency for Gradle too ;)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on a diff in pull request #4149: Initial implementation of Project Dependency API

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4149:
URL: https://github.com/apache/netbeans/pull/4149#discussion_r882614574


##########
java/java.lsp.server/vscode/package-lock.json:
##########
@@ -10,23 +10,23 @@
 			"license": "Apache 2.0",
 			"dependencies": {
 				"jsonc-parser": "3.0.0",
-				"vscode-debugadapter": "1.51.0",
-				"vscode-languageclient": "8.0.1"
+				"vscode-debugadapter": "1.42.1",
+				"vscode-languageclient": "7.0.0"

Review Comment:
   Changes removed (= same as `master`) in f3ee411faa



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] ppisl commented on a diff in pull request #4149: Initial implementation of Project Dependency API

Posted by GitBox <gi...@apache.org>.
ppisl commented on code in PR #4149:
URL: https://github.com/apache/netbeans/pull/4149#discussion_r881714767


##########
ide/project.dependency/src/org/netbeans/modules/project/dependency/ArtifactSpec.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.project.dependency;
+
+import java.util.Objects;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.annotations.common.NullAllowed;
+
+/**
+ * Represents an artifact. Each artifact is identified by
+ * <ul>
+ * <li>group or organization id
+ * <li>artifact id
+ * <li>version
+ * <li>(optional) classifier; no classifier shall be interpreted as a
+ * regular build artifact
+ * <li>(optional) type; not type shall be interepreted as the default type
+ * for the processing compiler or builder
+ * </ul>
+ * The version specified is further classified by {@link VersionKind}, to 
+ * distinguish versions possibly from repositories, development versions and
+ * floating versions.
+ * 
+ * @author sdedic
+ */
+public final class ArtifactSpec<T> {
+    /**
+     * Kind of the artifact version
+     */
+    public enum VersionKind {
+        /**
+         * Regular publishable artifact
+         */
+        REGULAR, 
+        
+        /**
+         * Snapshot artifact
+         */
+        SNAPSHOT, 
+        
+        /**
+         * Regular artifact, floating version
+         */
+        LATEST
+    };
+    
+    private final VersionKind kind;
+    private final String type;
+    private final String groupId;
+    private final String artifactId;
+    private final String versionSpec;
+    private final String classifier;
+    private final boolean optional;
+    final T data;
+
+    ArtifactSpec(VersionKind kind, String groupId, String artifactId, String versionSpec, String type, String classifier, boolean optional, T impl) {
+        this.kind = kind;
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+        this.versionSpec = versionSpec;
+        this.classifier = classifier;
+        this.optional = optional;
+        this.data = impl;
+        this.type = type;
+    }
+
+    public VersionKind getKind() {
+        return kind;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public String getArtifactId() {
+        return artifactId;
+    }
+
+    public String getVersionSpec() {
+        return versionSpec;
+    }
+
+    public String getClassifier() {
+        return classifier;
+    }
+
+    public boolean isOptional() {
+        return optional;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 79 * hash + Objects.hashCode(this.kind);
+        hash = 79 * hash + Objects.hashCode(this.type);
+        hash = 79 * hash + Objects.hashCode(this.groupId);
+        hash = 79 * hash + Objects.hashCode(this.artifactId);
+        hash = 79 * hash + Objects.hashCode(this.versionSpec);
+        hash = 79 * hash + Objects.hashCode(this.classifier);
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final ArtifactSpec<?> other = (ArtifactSpec<?>) obj;
+        if (!Objects.equals(this.type, other.type)) {
+            return false;
+        }
+        if (!Objects.equals(this.groupId, other.groupId)) {
+            return false;
+        }
+        if (!Objects.equals(this.artifactId, other.artifactId)) {
+            return false;
+        }
+        if (!Objects.equals(this.versionSpec, other.versionSpec)) {
+            return false;
+        }
+        if (!Objects.equals(this.classifier, other.classifier)) {
+            return false;
+        }
+        return this.kind == other.kind;
+    }
+    
+    public String toString() {
+        StringBuilder sb = new StringBuilder(
+            String.format("%s:%s:%s", getGroupId(), getArtifactId(), getVersionSpec() == null ? "" : getVersionSpec())
+        );
+        if (classifier != null) {
+            sb.append(":").append(classifier);
+        }
+        if (type != null) {
+            sb.append("[").append(type).append("]");
+        }
+        if (optional) {
+            sb.append("?");
+        }
+        return sb.toString();
+    }
+    
+    /**
+     * Returns opaque project-specific data. If searching for
+     * a project-specific extension, use {@link ProjectDependencies#findAdapters} instead.
+     * 
+     * @return unspecified underlying project data
+     */
+    public T getProjectData() {
+        return data;
+    }
+    
+    public static <V> ArtifactSpec<V> createVersionSpec(
+            @NonNull String groupId, @NonNull String artifactId, 
+            @NullAllowed String type, @NullAllowed String classifier, 
+            @NonNull String versionSpec, boolean optional, @NonNull V data) {
+        return new ArtifactSpec<V>(VersionKind.REGULAR, groupId, artifactId, versionSpec, type, classifier, optional, data);
+    }
+
+    public static <V> ArtifactSpec<V> createSnapshotSpec(
+            @NonNull String groupId, @NonNull String artifactId, 
+            @NullAllowed String type, @NullAllowed String classifier, 
+            @NonNull String versionSpec, boolean optional, @NonNull V data) {
+        return new ArtifactSpec<V>(VersionKind.SNAPSHOT, groupId, artifactId, versionSpec, type, classifier, false, data);
+    }
+

Review Comment:
   And VersionKind.Latest? We don't need it now?



##########
java/java.lsp.server/vscode/package-lock.json:
##########
@@ -10,23 +10,23 @@
 			"license": "Apache 2.0",
 			"dependencies": {
 				"jsonc-parser": "3.0.0",
-				"vscode-debugadapter": "1.51.0",
-				"vscode-languageclient": "8.0.1"
+				"vscode-debugadapter": "1.42.1",
+				"vscode-languageclient": "7.0.0"

Review Comment:
   Is it intended to downgrade the versions? There are downgraded versions for more modules. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on pull request #4149: Initial implementation of Project Dependency API

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4149:
URL: https://github.com/apache/netbeans/pull/4149#issuecomment-1139523899

   Just unreliable tests fail, merging.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on a diff in pull request #4149: Initial implementation of Project Dependency API

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4149:
URL: https://github.com/apache/netbeans/pull/4149#discussion_r881793411


##########
java/java.lsp.server/vscode/package-lock.json:
##########
@@ -10,23 +10,23 @@
 			"license": "Apache 2.0",
 			"dependencies": {
 				"jsonc-parser": "3.0.0",
-				"vscode-debugadapter": "1.51.0",
-				"vscode-languageclient": "8.0.1"
+				"vscode-debugadapter": "1.42.1",
+				"vscode-languageclient": "7.0.0"

Review Comment:
   Unintentional - seems as leftovers from local experiments were committed, no change to vscode should be made here. Will clean up.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] junichi11 commented on pull request #4149: Initial implementation of Project Dependency API

Posted by GitBox <gi...@apache.org>.
junichi11 commented on PR #4149:
URL: https://github.com/apache/netbeans/pull/4149#issuecomment-1138214853

   Maybe, Some files are missing the license header? (`.md`, `.xml`, `.properties`)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic commented on a diff in pull request #4149: Initial implementation of Project Dependency API

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4149:
URL: https://github.com/apache/netbeans/pull/4149#discussion_r882614075


##########
ide/project.dependency/src/org/netbeans/modules/project/dependency/ArtifactSpec.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.project.dependency;
+
+import java.util.Objects;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.annotations.common.NullAllowed;
+
+/**
+ * Represents an artifact. Each artifact is identified by
+ * <ul>
+ * <li>group or organization id
+ * <li>artifact id
+ * <li>version
+ * <li>(optional) classifier; no classifier shall be interpreted as a
+ * regular build artifact
+ * <li>(optional) type; not type shall be interepreted as the default type
+ * for the processing compiler or builder
+ * </ul>
+ * The version specified is further classified by {@link VersionKind}, to 
+ * distinguish versions possibly from repositories, development versions and
+ * floating versions.
+ * 
+ * @author sdedic
+ */
+public final class ArtifactSpec<T> {
+    /**
+     * Kind of the artifact version
+     */
+    public enum VersionKind {
+        /**
+         * Regular publishable artifact
+         */
+        REGULAR, 
+        
+        /**
+         * Snapshot artifact
+         */
+        SNAPSHOT, 
+        
+        /**
+         * Regular artifact, floating version
+         */
+        LATEST
+    };
+    
+    private final VersionKind kind;
+    private final String type;
+    private final String groupId;
+    private final String artifactId;
+    private final String versionSpec;
+    private final String classifier;
+    private final boolean optional;
+    final T data;
+
+    ArtifactSpec(VersionKind kind, String groupId, String artifactId, String versionSpec, String type, String classifier, boolean optional, T impl) {
+        this.kind = kind;
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+        this.versionSpec = versionSpec;
+        this.classifier = classifier;
+        this.optional = optional;
+        this.data = impl;
+        this.type = type;
+    }
+
+    public VersionKind getKind() {
+        return kind;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public String getArtifactId() {
+        return artifactId;
+    }
+
+    public String getVersionSpec() {
+        return versionSpec;
+    }
+
+    public String getClassifier() {
+        return classifier;
+    }
+
+    public boolean isOptional() {
+        return optional;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 7;
+        hash = 79 * hash + Objects.hashCode(this.kind);
+        hash = 79 * hash + Objects.hashCode(this.type);
+        hash = 79 * hash + Objects.hashCode(this.groupId);
+        hash = 79 * hash + Objects.hashCode(this.artifactId);
+        hash = 79 * hash + Objects.hashCode(this.versionSpec);
+        hash = 79 * hash + Objects.hashCode(this.classifier);
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final ArtifactSpec<?> other = (ArtifactSpec<?>) obj;
+        if (!Objects.equals(this.type, other.type)) {
+            return false;
+        }
+        if (!Objects.equals(this.groupId, other.groupId)) {
+            return false;
+        }
+        if (!Objects.equals(this.artifactId, other.artifactId)) {
+            return false;
+        }
+        if (!Objects.equals(this.versionSpec, other.versionSpec)) {
+            return false;
+        }
+        if (!Objects.equals(this.classifier, other.classifier)) {
+            return false;
+        }
+        return this.kind == other.kind;
+    }
+    
+    public String toString() {
+        StringBuilder sb = new StringBuilder(
+            String.format("%s:%s:%s", getGroupId(), getArtifactId(), getVersionSpec() == null ? "" : getVersionSpec())
+        );
+        if (classifier != null) {
+            sb.append(":").append(classifier);
+        }
+        if (type != null) {
+            sb.append("[").append(type).append("]");
+        }
+        if (optional) {
+            sb.append("?");
+        }
+        return sb.toString();
+    }
+    
+    /**
+     * Returns opaque project-specific data. If searching for
+     * a project-specific extension, use {@link ProjectDependencies#findAdapters} instead.
+     * 
+     * @return unspecified underlying project data
+     */
+    public T getProjectData() {
+        return data;
+    }
+    
+    public static <V> ArtifactSpec<V> createVersionSpec(
+            @NonNull String groupId, @NonNull String artifactId, 
+            @NullAllowed String type, @NullAllowed String classifier, 
+            @NonNull String versionSpec, boolean optional, @NonNull V data) {
+        return new ArtifactSpec<V>(VersionKind.REGULAR, groupId, artifactId, versionSpec, type, classifier, optional, data);
+    }
+
+    public static <V> ArtifactSpec<V> createSnapshotSpec(
+            @NonNull String groupId, @NonNull String artifactId, 
+            @NullAllowed String type, @NullAllowed String classifier, 
+            @NonNull String versionSpec, boolean optional, @NonNull V data) {
+        return new ArtifactSpec<V>(VersionKind.SNAPSHOT, groupId, artifactId, versionSpec, type, classifier, false, data);
+    }
+

Review Comment:
   Removed in 0221749c9a



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sdedic merged pull request #4149: Initial implementation of Project Dependency API

Posted by GitBox <gi...@apache.org>.
sdedic merged PR #4149:
URL: https://github.com/apache/netbeans/pull/4149


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists