forked from apache/netbeans
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NETBEANS-2373] Better than nothing support for Gradle Distribution d…
…irs.
- Loading branch information
Showing
15 changed files
with
674 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
21 changes: 21 additions & 0 deletions
21
extide/gradle.dists/src/org/netbeans/modules/gradle/dists/Bundle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
55 changes: 55 additions & 0 deletions
55
extide/gradle.dists/src/org/netbeans/modules/gradle/dists/DistribitionSourceWatchList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
113 changes: 113 additions & 0 deletions
113
extide/gradle.dists/src/org/netbeans/modules/gradle/dists/DistributionNodeFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.