diff options
19 files changed, 68 insertions, 178 deletions
diff --git a/bundle-plugin/src/main/resources/META-INF/plexus/components.xml b/bundle-plugin/src/main/resources/META-INF/plexus/components.xml index c537baf0975..31e21eb18fd 100644 --- a/bundle-plugin/src/main/resources/META-INF/plexus/components.xml +++ b/bundle-plugin/src/main/resources/META-INF/plexus/components.xml @@ -12,8 +12,8 @@ <configuration> <phases> - <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources> <generate-sources>com.yahoo.vespa:bundle-plugin:generateSources</generate-sources> + <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources> <compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile> <process-test-resources> org.apache.maven.plugins:maven-resources-plugin:testResources, diff --git a/component/src/main/java/com/yahoo/component/Spec.java b/component/src/main/java/com/yahoo/component/Spec.java index d4fc68324b7..75a3523d032 100644 --- a/component/src/main/java/com/yahoo/component/Spec.java +++ b/component/src/main/java/com/yahoo/component/Spec.java @@ -1,8 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.component; -import static com.yahoo.container.util.Util.firstNonNull; - /** * Code common to ComponentId and ComponentSpecification * @@ -28,7 +26,7 @@ final class Spec<VERSION> { this.versionHandler = versionHandler; this.name = name; - this.version = firstNonNull(version, versionHandler.emptyVersion()); + this.version = version == null ? versionHandler.emptyVersion() : version; this.namespace = namespace; } diff --git a/component/src/main/java/com/yahoo/container/util/Util.java b/component/src/main/java/com/yahoo/container/util/Util.java deleted file mode 100644 index 605ae75643b..00000000000 --- a/component/src/main/java/com/yahoo/container/util/Util.java +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.util; - -/** - * TODO: What is this? - * - * @author Tony Vaagenes - */ -// TODO: Move to a a more appropriate package in vespajlib -// TODO: Fix name -public class Util { - - // TODO: What is this? - @SafeVarargs - public static <T> T firstNonNull(T... args) { - for (T arg : args) { - if (arg != null) - return arg; - } - return null; - } - - // TODO: What is this? - public static String quote(Object object) { - return "'" + object + "'"; - } -} diff --git a/component/src/main/java/com/yahoo/container/util/package-info.java b/component/src/main/java/com/yahoo/container/util/package-info.java deleted file mode 100644 index 717e21b8e6e..00000000000 --- a/component/src/main/java/com/yahoo/container/util/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -package com.yahoo.container.util; - -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/config-class-plugin/pom.xml b/config-class-plugin/pom.xml index 4809db247d4..08ae440e35d 100644 --- a/config-class-plugin/pom.xml +++ b/config-class-plugin/pom.xml @@ -11,7 +11,7 @@ <artifactId>config-class-plugin</artifactId> <packaging>maven-plugin</packaging> <version>7-SNAPSHOT</version> - <name>Vespa ConfigGen Plugin</name> + <name>config-class-plugin (Vespa ConfigGen Plugin)</name> <dependencies> <dependency> <groupId>org.apache.maven</groupId> diff --git a/config-class-plugin/src/main/java/com/yahoo/vespa/CloverChecker.java b/config-class-plugin/src/main/java/com/yahoo/vespa/CloverChecker.java deleted file mode 100644 index 5b9e1d9a408..00000000000 --- a/config-class-plugin/src/main/java/com/yahoo/vespa/CloverChecker.java +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa; - -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.project.MavenProject; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.function.Predicate; - -/** - * @author Tony Vaagenes - */ -class CloverChecker { - private final Log log; - - CloverChecker(Log log) { - this.log = log; - } - - @SuppressWarnings("unchecked") //getCompileSourceRoots() returns List instead of List<String> - public boolean isForkedCloverLifecycle(MavenProject project, Path outputDirectory) { - return "clover".equals(project.getArtifact().getClassifier()) && - project.getCompileSourceRoots().stream().anyMatch( - equalsPathAbsolutely(regularOutputDirectory(project, outputDirectory))); - } - - /* - * Regular output directory for generated classes, - * i.e. not the clover output directory. - * - * Example: - * If outputDirectory is target/clover/generated-sources/vespa-configgen-plugin, - * return target/generated-sources/vespa-configgen-plugin. - */ - private Path regularOutputDirectory(MavenProject project, Path outputDirectory) { - Path cloverTargetPath = Paths.get(project.getBuild().getDirectory()); - Path targetPath = cloverTargetPath.getParent(); - - if (!targetPath.endsWith("target")) { - log.warn("Guessing that target directory is " + targetPath + ", this might not be correct."); - } - - Path outputDirectoryRelativeToCloverDirectory = cloverTargetPath.relativize(outputDirectory); - return targetPath.resolve(outputDirectoryRelativeToCloverDirectory); - } - - private Predicate<String> equalsPathAbsolutely(Path path) { - Path absolutePath = path.toAbsolutePath(); - - return candidateStringPath -> Paths.get(candidateStringPath).toAbsolutePath().equals(absolutePath); - } -} diff --git a/config-class-plugin/src/main/java/com/yahoo/vespa/ConfigGenMojo.java b/config-class-plugin/src/main/java/com/yahoo/vespa/ConfigGenMojo.java index 9930d53ca6c..df2359a8129 100644 --- a/config-class-plugin/src/main/java/com/yahoo/vespa/ConfigGenMojo.java +++ b/config-class-plugin/src/main/java/com/yahoo/vespa/ConfigGenMojo.java @@ -19,7 +19,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; +import java.util.stream.Stream; import static com.yahoo.config.codegen.DefParser.DEFAULT_PACKAGE_PREFIX; @@ -36,8 +36,7 @@ public class ConfigGenMojo extends AbstractMojo { * Generate source to here. */ @Parameter(property = "plugin.configuration.outputDirectory", - defaultValue = "${project.build.directory}/generated-sources/vespa-configgen-plugin", - required = true) + defaultValue = "${project.build.directory}/generated-sources/vespa-configgen-plugin") private File outputDirectory; /** @@ -69,7 +68,7 @@ public class ConfigGenMojo extends AbstractMojo { * If true, the config sources are only intended for use during testing. * */ - @Parameter(property = "plugin.configuration.testConfig", defaultValue = "false", required = true) + @Parameter(property = "plugin.configuration.testConfig", defaultValue = "false") private boolean testConfig; /** @@ -103,11 +102,6 @@ public class ConfigGenMojo extends AbstractMojo { public void execute() throws MojoExecutionException { - if (new CloverChecker(getLog()).isForkedCloverLifecycle(project, outputDirectory.toPath())) { - getLog().info("Skipping config generation in forked clover lifecycle."); - return; - } - List<String> defFileNames = getDefFileNames(); // Silent failure when there are no def-files to process... @@ -115,13 +109,7 @@ public class ConfigGenMojo extends AbstractMojo { return; } - // append all def-file names together - StringBuilder configSpec = new StringBuilder(); - boolean notFirst = false; - for (String defFile : defFileNames) { - if (notFirst) { configSpec.append(","); } else { notFirst = true; } - configSpec.append(defFile); - } + String configSpec = String.join(",", defFileNames); boolean generateSources; // optionally create the output directory @@ -139,7 +127,7 @@ public class ConfigGenMojo extends AbstractMojo { getLog().debug("Will generate config class files"); try { MakeConfigProperties config = new MakeConfigProperties(outputDirectory.toString(), - configSpec.toString(), + configSpec, null, null, null, @@ -160,37 +148,33 @@ public class ConfigGenMojo extends AbstractMojo { } private boolean isSomeGeneratedFileStale(File outputDirectory, List<String> defFileNames) { - long oldestGeneratedModifiedTime = Long.MAX_VALUE; - try { - List<File> files = Files.walk(outputDirectory.toPath()) + long oldestGeneratedModifiedTime = walk(outputDirectory.toPath()) .filter(Files::isRegularFile) .map(Path::toFile) - .collect(Collectors.toList()); - for (File f : files) { - getLog().debug("Checking generated file " + f); - final long l = f.lastModified(); - if (l < oldestGeneratedModifiedTime) { - oldestGeneratedModifiedTime = l; - } - } - } catch (IOException e) { - throw new UncheckedIOException(e); - } - - long lastModifiedSource = 0; - for (String sourceFile : defFileNames) { - getLog().debug("Checking source file " + sourceFile); - File f = new File(sourceFile); - final long l = f.lastModified(); - if (l > lastModifiedSource) { - lastModifiedSource = l; - } - } + .peek(f -> getLog().debug("Checking generated file " + f)) + .mapToLong(File::lastModified) + .min() + .orElse(Long.MAX_VALUE); + + long lastModifiedSource = defFileNames.stream() + .peek(sourceFile -> getLog().debug("Checking source file " + sourceFile)) + .map(File::new) + .mapToLong(File::lastModified) + .max() + .orElse(0L); getLog().debug("lastModifiedSource: " + lastModifiedSource + ", oldestTGeneratedModified: " + oldestGeneratedModifiedTime); return lastModifiedSource > oldestGeneratedModifiedTime; } + private static Stream<Path> walk(Path path) { + try { + return Files.walk(path); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + private void addSourceRoot(String outputDirectory) { if (testConfig) { project.addTestCompileSourceRoot(outputDirectory); diff --git a/configgen/src/main/java/com/yahoo/config/codegen/MakeConfigProperties.java b/configgen/src/main/java/com/yahoo/config/codegen/MakeConfigProperties.java index da746bf3a01..7fb587ecce8 100644 --- a/configgen/src/main/java/com/yahoo/config/codegen/MakeConfigProperties.java +++ b/configgen/src/main/java/com/yahoo/config/codegen/MakeConfigProperties.java @@ -2,9 +2,14 @@ package com.yahoo.config.codegen; import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Encapsulates data extracted from system properties. @@ -14,10 +19,10 @@ import java.util.StringTokenizer; @SuppressWarnings("WeakerAccess") // Used by ConfigGenMojo public class MakeConfigProperties { - private static final List<String> legalLanguages = Arrays.asList("java", "cpp" ); + private static final List<String> legalLanguages = List.of("java", "cpp" ); final File destDir; - final File[] specFiles; + final List<File> specFiles; final String language; final String dirInRoot; // Where within fileroot to store generated class files final String javaPackagePrefix; @@ -81,20 +86,19 @@ public class MakeConfigProperties { return inputLang; } - private static File[] checkSpecificationFiles(String spec) throws PropertyException { - if (spec == null) - throw new PropertyException("Missing property: config.spec."); + private static List<File> checkSpecificationFiles(String spec) throws PropertyException { + if (spec == null || spec.isEmpty()) + throw new PropertyException("Missing property: config.spec"); - StringTokenizer st = new StringTokenizer(spec, ","); - if (st.countTokens() == 0) - throw new PropertyException("Missing property: config.spec."); - - File[] files = new File[st.countTokens()]; - for (int i = 0; st.hasMoreElements(); i++) { - files[i] = new File((String) st.nextElement()); - if (!files[i].isFile()) - throw new PropertyException("Could not read file " + files[i].getPath()); + var files = new ArrayList<File>(); + for (String token : spec.split(",", -1)) { + File file = new File(token); + if (!file.isFile()) { + throw new PropertyException("Could not read file " + file); + } + files.add(file); } + return files; } diff --git a/configgen/src/test/java/com/yahoo/config/codegen/MakeConfigTest.java b/configgen/src/test/java/com/yahoo/config/codegen/MakeConfigTest.java index 2a2b65e97a7..793986e1ae1 100644 --- a/configgen/src/test/java/com/yahoo/config/codegen/MakeConfigTest.java +++ b/configgen/src/test/java/com/yahoo/config/codegen/MakeConfigTest.java @@ -51,8 +51,8 @@ public class MakeConfigTest { assertEquals(p.destDir.getAbsolutePath(), dest.getAbsolutePath()); assertTrue(p.dumpTree); assertTrue(p.generateFrameworkCode); - assertEquals(p.specFiles.length, 1); - assertEquals(p.specFiles[0].getAbsolutePath(), new File("src/test/resources/configgen.allfeatures.def").getAbsolutePath()); + assertEquals(p.specFiles.size(), 1); + assertEquals(p.specFiles.get(0).getAbsolutePath(), new File("src/test/resources/configgen.allfeatures.def").getAbsolutePath()); System.setProperty("config.dumpTree", "false"); System.setProperty("config.useFramework", "false"); @@ -62,7 +62,7 @@ public class MakeConfigTest { assertEquals(p.destDir.getAbsolutePath(), dest.getAbsolutePath()); assertFalse(p.dumpTree); assertFalse(p.generateFrameworkCode); - assertEquals(p.specFiles.length, 2); + assertEquals(p.specFiles.size(), 2); } @Test diff --git a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java index ec80c568489..9c0951c1c95 100644 --- a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java +++ b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java @@ -21,7 +21,6 @@ import com.yahoo.jdisc.application.OsgiFramework; import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.service.ClientProvider; import com.yahoo.jdisc.service.ServerProvider; -import java.util.logging.Level; import com.yahoo.osgi.OsgiImpl; import com.yahoo.osgi.OsgiWrapper; import com.yahoo.statistics.Statistics; @@ -30,13 +29,13 @@ import org.osgi.framework.wiring.BundleWiring; import java.util.ArrayList; import java.util.Collection; +import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.Executors; +import java.util.logging.Level; import java.util.logging.Logger; -import java.util.Set; import static com.yahoo.collections.CollectionUtil.first; -import static com.yahoo.container.util.Util.quote; /** @@ -108,7 +107,7 @@ public class HandlersConfigurerDi { } else { Bundle bundle = getBundle(bundleSpec); if (bundle == null) - throw new RuntimeException("No bundle matching " + quote(bundleSpec)); + throw new RuntimeException("No bundle matching '" + bundleSpec + "'"); return new BundleClasses(bundle, OsgiUtil.getClassEntriesInBundleClassPath(bundle, packagesToScan)); } diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java index 14604d61c0a..6f360c8b456 100644 --- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java @@ -21,8 +21,6 @@ import java.io.IOException; import java.util.Optional; import java.util.logging.Level; -import static com.yahoo.container.util.Util.quote; - /** * The searcher which forwards queries to fdispatch nodes, using the fnet/fs4 * network layer. @@ -160,7 +158,7 @@ public class FastSearcher extends VespaBackEndSearcher { } private static Optional<String> quotedSummaryClass(String summaryClass) { - return Optional.of(summaryClass == null ? "[null]" : quote(summaryClass)); + return Optional.of(summaryClass == null ? "[null]" : "'" + summaryClass + "'"); } public String toString() { diff --git a/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java b/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java index 0c38b38179d..4b7d5dc766d 100644 --- a/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/federation/FederationSearcher.java @@ -58,7 +58,6 @@ import java.util.logging.Logger; import static com.google.common.base.Preconditions.checkNotNull; import static com.yahoo.collections.CollectionUtil.first; -import static com.yahoo.container.util.Util.quote; import static com.yahoo.search.federation.StrictContractsConfig.PropagateSourceProperties; /** @@ -105,7 +104,7 @@ public class FederationSearcher extends ForkingSearcher { ComponentRegistry<TargetSelector> targetSelectors) { if (selectorId.isEmpty()) return null; return checkNotNull(targetSelectors.getComponent(selectorId), - "Missing target selector with id" + quote(selectorId)); + "Missing target selector with id '" + selectorId + "'"); } // for testing diff --git a/container-search/src/main/java/com/yahoo/search/federation/sourceref/SourceRefResolver.java b/container-search/src/main/java/com/yahoo/search/federation/sourceref/SourceRefResolver.java index ee98d033440..bf4ca9c2a9e 100644 --- a/container-search/src/main/java/com/yahoo/search/federation/sourceref/SourceRefResolver.java +++ b/container-search/src/main/java/com/yahoo/search/federation/sourceref/SourceRefResolver.java @@ -1,17 +1,15 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.federation.sourceref; -import static com.yahoo.container.util.Util.quote; +import com.yahoo.component.ComponentSpecification; +import com.yahoo.prelude.IndexFacts; +import com.yahoo.processing.request.Properties; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import com.yahoo.component.ComponentSpecification; -import com.yahoo.prelude.IndexFacts; -import com.yahoo.processing.request.Properties; - /** * Maps a source reference to search chain invocation specs. * @@ -65,9 +63,9 @@ public class SourceRefResolver { return searchChainResolver.resolve(new ComponentSpecification(cluster), sourceToProviderMap); } catch (UnresolvedSearchChainException e) { - throw new UnresolvedSearchChainException("Failed to resolve cluster search chain " + quote(cluster) + - " when using source ref " + quote(sourceRef) + - " as a document name."); + throw new UnresolvedSearchChainException("Failed to resolve cluster search chain '" + cluster + + "' when using source ref '" + sourceRef + + "' as a document name."); } } diff --git a/container-search/src/main/java/com/yahoo/search/federation/sourceref/UnresolvedProviderException.java b/container-search/src/main/java/com/yahoo/search/federation/sourceref/UnresolvedProviderException.java index 5075b05454b..2ae923714c7 100644 --- a/container-search/src/main/java/com/yahoo/search/federation/sourceref/UnresolvedProviderException.java +++ b/container-search/src/main/java/com/yahoo/search/federation/sourceref/UnresolvedProviderException.java @@ -4,8 +4,6 @@ package com.yahoo.search.federation.sourceref; import com.yahoo.component.ComponentId; import com.yahoo.component.ComponentSpecification; -import static com.yahoo.container.util.Util.quote; - /** * @author Tony Vaagenes */ @@ -17,6 +15,6 @@ class UnresolvedProviderException extends UnresolvedSearchChainException { static UnresolvedSearchChainException createForMissingProvider(ComponentId source, ComponentSpecification provider) { - return new UnresolvedProviderException("No provider " + quote(provider) + " for source " + quote(source) + "."); + return new UnresolvedProviderException("No provider '" + provider + "' for source '" + source + "'."); } } diff --git a/container-search/src/main/java/com/yahoo/search/federation/sourceref/UnresolvedSourceRefException.java b/container-search/src/main/java/com/yahoo/search/federation/sourceref/UnresolvedSourceRefException.java index 233e92c1699..6f0549eaf93 100644 --- a/container-search/src/main/java/com/yahoo/search/federation/sourceref/UnresolvedSourceRefException.java +++ b/container-search/src/main/java/com/yahoo/search/federation/sourceref/UnresolvedSourceRefException.java @@ -3,8 +3,6 @@ package com.yahoo.search.federation.sourceref; import com.yahoo.component.ComponentSpecification; -import static com.yahoo.container.util.Util.quote; - /** * @author Tony Vaagenes */ @@ -16,6 +14,6 @@ class UnresolvedSourceRefException extends UnresolvedSearchChainException { static UnresolvedSearchChainException createForMissingSourceRef(ComponentSpecification source) { - return new UnresolvedSourceRefException("Could not resolve source ref " + quote(source) + "."); + return new UnresolvedSourceRefException("Could not resolve source ref '" + source + "'."); } } diff --git a/container-search/src/main/java/com/yahoo/search/query/ParameterParser.java b/container-search/src/main/java/com/yahoo/search/query/ParameterParser.java index 3addc1fdb4e..c0f0ee80730 100644 --- a/container-search/src/main/java/com/yahoo/search/query/ParameterParser.java +++ b/container-search/src/main/java/com/yahoo/search/query/ParameterParser.java @@ -3,8 +3,6 @@ package com.yahoo.search.query; import com.yahoo.processing.IllegalInputException; -import static com.yahoo.container.util.Util.quote; - /** * Wrapper class to avoid code duplication of common parsing requirements. * @@ -40,7 +38,7 @@ public class ParameterParser { double multiplier = parseUnit(time.substring(unitOffset)); return (long) (measure * multiplier); } catch (RuntimeException e) { - throw new IllegalInputException("Error parsing " + quote(time), e); + throw new IllegalInputException("Error parsing '" + time + "'", e); } } @@ -55,7 +53,7 @@ public class ParameterParser { } } if (unitOffset == 0) { - throw new IllegalInputException("Invalid number " + quote(time)); + throw new IllegalInputException("Invalid number '" + time + "'"); } return unitOffset; } diff --git a/maven-plugins/pom.xml b/maven-plugins/pom.xml index c2a011e0408..5d3fe638d4d 100644 --- a/maven-plugins/pom.xml +++ b/maven-plugins/pom.xml @@ -16,11 +16,11 @@ <url>http://yahoo.github.io/vespa</url> <modules> + <module>../abi-check-plugin</module> <module>../annotations</module> <module>../bundle-plugin</module> - <module>../configgen</module> <module>../config-class-plugin</module> + <module>../configgen</module> <module>../vespa-application-maven-plugin</module> - <module>../abi-check-plugin</module> </modules> </project> diff --git a/parent/pom.xml b/parent/pom.xml index 983d8fd3e56..a6635658d53 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -348,7 +348,7 @@ <id>generate-javadoc</id> <phase>package</phase> <goals> - <goal>javadoc</goal> + <goal>javadoc-no-fork</goal> </goals> </execution> <execution> diff --git a/yolean/pom.xml b/yolean/pom.xml index f994d401c60..9f55027a220 100644 --- a/yolean/pom.xml +++ b/yolean/pom.xml @@ -38,6 +38,7 @@ <extensions>true</extensions> </plugin> <plugin> + <!-- Needed for IntelliJ --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> </plugin> |