Skip to content

Commit

Permalink
[NETBEANS-2373] Better than nothing support for Gradle Distribution d…
Browse files Browse the repository at this point in the history
…irs.
  • Loading branch information
lkishalmi committed May 21, 2021
1 parent 1ea9a57 commit 408a348
Show file tree
Hide file tree
Showing 15 changed files with 674 additions and 2 deletions.
26 changes: 26 additions & 0 deletions extide/gradle.dists/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project basedir="." default="build" name="extide/gradle.dists">
<description>Builds, tests, and runs the project org.netbeans.modules.gradle.dists</description>
<import file="../../nbbuild/templates/projectized.xml"/>
</project>

5 changes: 5 additions & 0 deletions extide/gradle.dists/manifest.mf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.modules.gradle.dists
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/gradle/dists/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0
25 changes: 25 additions & 0 deletions extide/gradle.dists/nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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.

is.eager=true
javac.source=1.8
javac.compilerargs=-Xlint -Xlint:-serial

nbm.module.author=Laszlo Kishalmi

test-unit-sys-prop.test.netbeans.dest.dir=${netbeans.dest.dir}
test-unit-sys-prop.java.awt.headless=true
108 changes: 108 additions & 0 deletions extide/gradle.dists/nbproject/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>org.netbeans.modules.gradle.dists</code-name-base>
<module-dependencies>
<dependency>
<code-name-base>org.netbeans.modules.gradle</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>2</release-version>
<specification-version>2.12</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.projectapi</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.80</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.100</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.filesystems</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>9.23</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.loaders</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.81</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.nodes</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.57</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>9.19</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util.lookup</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>8.46</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util.ui</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>9.20</specification-version>
</run-dependency>
</dependency>
</module-dependencies>
<test-dependencies/>
<public-packages/>
</data>
</configuration>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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.

OpenIDE-Module-Display-Category=Gradle
OpenIDE-Module-Name=Gradle Projects Distributions
OpenIDE-Module-Short-Description=Better than nothing support of Gradle distribution plugin.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.gradle.dists;

import java.io.File;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.netbeans.api.project.Project;
import org.netbeans.modules.gradle.dists.api.GradleDistProject;
import org.netbeans.modules.gradle.spi.WatchedResourceProvider;

/**
*
* @author lkishalmi
*/
public class DistribitionSourceWatchList implements WatchedResourceProvider {

final Project project;

public DistribitionSourceWatchList(Project project) {
this.project = project;
}


@Override
public Set<File> getWatchedResources() {
Set<File> ret = Collections.emptySet();
GradleDistProject gdp = GradleDistProject.get(project);
if ((gdp != null) && !gdp.getDistributions().isEmpty()) {
ret = new HashSet<>();
for (String distribution : gdp.getDistributions()) {
ret.add(gdp.getDistributionSource(distribution));
}
}
return ret;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* 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.gradle.dists;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.api.project.SourceGroup;
import org.netbeans.api.project.Sources;
import org.netbeans.modules.gradle.api.NbGradleProject;
import org.netbeans.modules.gradle.spi.nodes.AbstractGradleNodeList;
import org.netbeans.spi.project.ui.support.NodeFactory;
import org.netbeans.spi.project.ui.support.NodeList;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;

/**
*
* @author lkishalmi
*/
@NodeFactory.Registration(projectType = NbGradleProject.GRADLE_PROJECT_TYPE, position = 150)
public class DistributionNodeFactory implements NodeFactory {

@Override
public NodeList<?> createNodes(Project project) {
return new NList(project);
}

private static class NList extends AbstractGradleNodeList<SourceGroup> {
private final Project project;
private NList(Project prj) {
project = prj;
}

@Override
public List<SourceGroup> keys() {
Sources srcs = ProjectUtils.getSources(project);
List<SourceGroup> ret = new ArrayList<>(2);
ret.addAll(Arrays.asList(srcs.getSourceGroups(DistributionSourcesImpl.DISTRIBUTION_SOURCES)));
ret.sort(Comparator.comparing(SourceGroup::getName));
return ret;
}

@Override
public Node node(SourceGroup key) {
return DistributionFolderNode.createResourcesFolderNode(key);
}

}

private static class DistributionFolderNode extends FilterNode {

final SourceGroup group;

private DistributionFolderNode(SourceGroup group, Node original) {
super(original);
this.group = group;
}

@Override
public String getName() {
return group.getName();
}

@Override
public String getDisplayName() {
return group.getDisplayName();
}

static Node createResourcesFolderNode(SourceGroup group) {
try {
DataObject root = DataObject.find(group.getRootFolder());
return new DistributionFolderNode(group, root.getNodeDelegate());
} catch(DataObjectNotFoundException ex) {
//Shall not happen...
}
return null;
}

@Override
public boolean canRename() {
return false;
}

@Override
public boolean canCut() {
return false;
}

}

}
Loading

0 comments on commit 408a348

Please sign in to comment.