Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dependency add API (still private) for projects. #6849

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
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,9 @@ jobs:
- name: java/maven.indexer
run: ant $OPTS -f java/maven.indexer test

- name: java/maven.refactoring
run: ant $OPTS -f java/maven.refactoring test

- name: java/maven.junit
run: ant $OPTS -f java/maven.junit test

Expand Down Expand Up @@ -913,6 +916,9 @@ jobs:
- name: extide/gradle
run: ant $OPTS -f extide/gradle test

- name: java/gradle.dependencies
run: ant $OPTS -f java/gradle.dependencies test

- name: extide/o.apache.tools.ant.module
run: ant $OPTS -f extide/o.apache.tools.ant.module test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public Set<GradleConfiguration> getExtendsFrom() {
* @return direct dependencies
*/
public Collection<? extends GradleDependency> getConfiguredDependencies() {
return directChildren;
if (canBeResolved) {
return directChildren;
} else {
return unresolved;
}
}

/**
Expand All @@ -100,12 +104,13 @@ public Collection<? extends GradleDependency> getConfiguredDependencies() {
* @return configuration of origin or {@code null}.
*/
public GradleConfiguration getDependencyOrigin(GradleDependency d) {
if (!getDependencies().contains(d)) {
if (!getDependencies().contains(d) && !getConfiguredDependencies().contains(d)) {
return null;
}
// TODO: possibly create a dependency-to-config cache in this instance to speed up further queries
Set<GradleConfiguration> done = new HashSet<>();
Queue<GradleConfiguration> toProcess = new ArrayDeque<>(getExtendsFrom());
Queue<GradleConfiguration> toProcess = new ArrayDeque<>();
toProcess.add(this);

GradleConfiguration conf;
while ((conf = toProcess.poll()) != null) {
Expand Down
2 changes: 1 addition & 1 deletion ide/project.dependency/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
is.autoload=true
javac.source=1.8
javac.compilerargs=-Xlint -Xlint:-serial
spec.version.base=1.6.0
spec.version.base=1.7.0
49 changes: 49 additions & 0 deletions ide/project.dependency/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@
<specification-version>1.45</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.api.lsp</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.21</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.editor.document</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.32</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.projectapi</code-name-base>
<build-prerequisite/>
Expand All @@ -43,6 +60,22 @@
<specification-version>1.89</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.70</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.awt</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.91</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.filesystems</code-name-base>
<build-prerequisite/>
Expand All @@ -51,6 +84,22 @@
<specification-version>9.29</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.nodes</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.68</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.text</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.91</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util</code-name-base>
<build-prerequisite/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,31 @@ public static <V> ArtifactSpec<V> createVersionSpec(
}
return new ArtifactSpec<V>(VersionKind.REGULAR, groupId, artifactId, versionSpec, type, classifier, optional, uri, localFile, Collections.emptySet(), data);
}

/**
* Creates a partial artifact specification, usable as a description. The artifact does not contain all the metadata, but serves as a match
* for artifacts managed by the build system.
* @param groupId
* @param artifactId
* @return spec instance
* @since 1.7
*/
public static ArtifactSpec make(String groupId, String artifactId) {
return createVersionSpec(groupId, artifactId, null, null, null, false, null, null);
}

/**
* Creates a partial artifact specification, usable as a description. The artifact does not contain all the metadata, but serves as a match
* for artifacts managed by the build system.
* @param groupId group ID
* @param artifactId artifact ID
* @param versionSpec version
* @return spec instance
* @since 1.7
*/
public static ArtifactSpec make(String groupId, String artifactId, String versionSpec) {
return createVersionSpec(groupId, artifactId, null, null, versionSpec, false, null, null);
}

public static <V> ArtifactSpec<V> createSnapshotSpec(
@NullAllowed String groupId, @NullAllowed String artifactId,
Expand All @@ -335,6 +360,10 @@ public static <V> ArtifactSpec<V> createSnapshotSpec(
return new ArtifactSpec<V>(VersionKind.SNAPSHOT, groupId, artifactId, versionSpec, type, classifier, optional, uri, localFile, Collections.emptySet(), data);
}

public static final <T> Builder<T> describe(String group, String artifact) {
return new Builder(group, artifact, null, null);
}

public static final <T> Builder<T> builder(String group, String artifact, String version, T projectData) {
return new Builder(group, artifact, version, projectData);
}
Expand All @@ -343,7 +372,7 @@ public final static class Builder<T> {
private final T data;
private final String groupId;
private final String artifactId;
private final String versionSpec;
private String versionSpec;
private VersionKind kind = VersionKind.REGULAR;
private String type;
private String classifier;
Expand All @@ -358,6 +387,16 @@ public Builder(String groupId, String artifactId, String versionSpec, T data) {
this.versionSpec = versionSpec;
this.data = data;
}

public Builder versionKind(VersionKind kind) {
this.kind = kind;
return this;
}

public Builder version(String versionSpec) {
this.versionSpec = versionSpec;
return this;
}

public Builder type(String type) {
this.type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.netbeans.modules.project.dependency;

import java.util.Collections;
import java.util.List;
import org.netbeans.api.annotations.common.CheckForNull;

Expand Down Expand Up @@ -106,6 +107,16 @@ private static Dependency assignParent(Dependency d) {
return d;
}

/**
* A convenience method to make a dependency descriptor.
* @param spec artifact specification
* @param scope the dependency scope
* @return dependency instance
*/
public static Dependency make(ArtifactSpec spec, Scope scope) {
return create(spec, scope, Collections.emptyList(), null);
}

/**
* Creates an artifact dependency. The artifact need not physically exist on the filesystem, but its coordinates
* must be known.
Expand Down
Loading