diff --git a/apisupport/apisupport.project/nbproject/project.properties b/apisupport/apisupport.project/nbproject/project.properties index 73392e5cce82..5973ad149243 100644 --- a/apisupport/apisupport.project/nbproject/project.properties +++ b/apisupport/apisupport.project/nbproject/project.properties @@ -16,7 +16,7 @@ # under the License. javac.compilerargs=-Xlint -Xlint:-serial -javac.source=1.6 +javac.source=1.8 javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml diff --git a/groovy/gradle.java/nbproject/project.properties b/groovy/gradle.java/nbproject/project.properties index af45086cefc8..97e9a499d5bb 100644 --- a/groovy/gradle.java/nbproject/project.properties +++ b/groovy/gradle.java/nbproject/project.properties @@ -20,7 +20,10 @@ 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 + release.external/org.jacoco.core-0.8.3.jar=modules/gradle/org.jacoco.core.jar release.external/asm-7.0.jar=modules/gradle/asm.jar release.external/asm-commons-7.0.jar=modules/gradle/asm-commons.jar -release.external/asm-tree-7.0.jar=modules/gradle/asm-tree.jar \ No newline at end of file +release.external/asm-tree-7.0.jar=modules/gradle/asm-tree.jar diff --git a/groovy/gradle.java/nbproject/project.xml b/groovy/gradle.java/nbproject/project.xml index b2c293fb0487..a6dcc6d73c5a 100644 --- a/groovy/gradle.java/nbproject/project.xml +++ b/groovy/gradle.java/nbproject/project.xml @@ -312,13 +312,41 @@ org.netbeans.libs.junit4 + + org.netbeans.modules.apisupport.project + + + + + org.netbeans.modules.gradle + + + org.netbeans.modules.nbjunit - org.netbeans.modules.gradle + org.netbeans.modules.projectapi.nb + + + + org.netbeans.modules.projectui + + + + org.openide.filesystems + + + + + org.openide.util.lookup + + + + + org.openide.util.ui diff --git a/groovy/gradle.java/test/unit/src/org/netbeans/modules/gradle/java/classpath/GradleSourcesImplTest.java b/groovy/gradle.java/test/unit/src/org/netbeans/modules/gradle/java/classpath/GradleSourcesImplTest.java new file mode 100644 index 000000000000..d6ccbab325d0 --- /dev/null +++ b/groovy/gradle.java/test/unit/src/org/netbeans/modules/gradle/java/classpath/GradleSourcesImplTest.java @@ -0,0 +1,89 @@ +/* + * 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.java.classpath; + +import java.io.File; +import static junit.framework.TestCase.assertNotNull; +import org.netbeans.api.java.project.JavaProjectConstants; +import org.netbeans.api.project.Project; +import org.netbeans.api.project.ProjectManager; +import org.netbeans.api.project.ProjectUtils; +import org.netbeans.api.project.SourceGroup; +import org.netbeans.api.project.Sources; +import org.netbeans.junit.NbTestCase; +import org.netbeans.modules.apisupport.project.InstalledFileLocatorImpl; +import org.netbeans.modules.project.uiapi.ProjectOpenedTrampoline; +import org.netbeans.spi.project.ui.ProjectOpenedHook; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.filesystems.test.TestFileUtils; + +/** + * + * @author lkishalmi + */ +public class GradleSourcesImplTest extends NbTestCase { + + public GradleSourcesImplTest(String name) { + super(name); + } + + private FileObject d; + /** Represents destination directory with NetBeans (always available). */ + protected File destDirF; + + @Override + protected void setUp() throws Exception { + super.setUp(); + clearWorkDir(); + d = FileUtil.toFileObject(getWorkDir()); + destDirF = getTestNBDestDir(); + } + + public void testGeneratedSources() throws Exception { // #187595 + InstalledFileLocatorImpl.registerDestDir(destDirF); + + TestFileUtils.writeFile(d, + "build.gradle", + "apply plugin: 'java'\n" + + "sourceSets { main { java { srcDirs = [ 'src', 'build/gen-src' ] }}}"); + FileObject src = FileUtil.createFolder(d, "src/"); + FileObject gsrc = FileUtil.createFolder(d, "build/gen-src"); + FileObject source = src.createData("Whatever.java"); + FileObject generated = gsrc.createData("WhateverGen.java"); + Project prj = ProjectManager.getDefault().findProject(d); + assertNotNull(prj); + ProjectOpenedTrampoline.DEFAULT.projectOpened(prj.getLookup().lookup(ProjectOpenedHook.class)); + Sources srcs = ProjectUtils.getSources(prj); + SourceGroup[] groups = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); + assertEquals(2, groups.length); + assertTrue(groups[0].contains(source)); + assertFalse(groups[0].contains(generated)); + assertTrue(groups[1].contains(generated)); + assertFalse(groups[1].contains(source)); + } + + private static File getTestNBDestDir() { + String destDir = System.getProperty("test.netbeans.dest.dir"); + // set in project.properties as test-unit-sys-prop.test.netbeans.dest.dir + assertNotNull("test.netbeans.dest.dir property has to be set when running within binary distribution", destDir); + return new File(destDir); + } + +} diff --git a/platform/openide.util.ui/nbproject/project.properties b/platform/openide.util.ui/nbproject/project.properties index 593de45d0090..5ba993f13de2 100644 --- a/platform/openide.util.ui/nbproject/project.properties +++ b/platform/openide.util.ui/nbproject/project.properties @@ -16,8 +16,8 @@ # under the License. javac.compilerargs=-Xlint -Xlint:-serial -Xlint:-processing -javac.source=1.6 -javac.target=1.7 +javac.source=1.8 +javac.target=1.8 module.jar.dir=lib diff --git a/platform/openide.util/nbproject/project.properties b/platform/openide.util/nbproject/project.properties index f14ab805c377..b9492cf30909 100644 --- a/platform/openide.util/nbproject/project.properties +++ b/platform/openide.util/nbproject/project.properties @@ -14,7 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -javac.source=1.6 +javac.source=1.8 javac.compilerargs=-Xlint -Xlint:-serial javadoc.arch=${basedir}/arch.xml module.jar.dir=lib