List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:io.apigee.trireme.rhino.compiler.RhinoCompiler.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { Log log = getLog(); File baseDir = new File(directory); if (baseDir.exists() && baseDir.isDirectory()) { CompilerEnvirons env = createEnvironment(); ClassCompiler compiler = new ClassCompiler(env); File targetDirFile = new File(targetPath); DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(baseDir);/*from w ww . ja v a 2 s . c o m*/ scanner.setIncludes(new String[] { pattern }); scanner.scan(); for (String fn : scanner.getIncludedFiles()) { File input = new File(baseDir, fn); String baseName = getBaseName(fn); String className = baseName.replaceAll("[/\\\\]", "."); File output = new File(targetDirFile, baseName + ".class"); File srcOutput = new File(targetDirFile, baseName + ".js"); if (input.lastModified() >= output.lastModified()) { if (output.getParentFile() != null) { output.getParentFile().mkdirs(); } log.info("Compiling " + fn + " to " + output.getPath()); try { String source = loadSource(input); Object[] bytes; try { bytes = compiler.compileToClassFiles(addPrefixes(source), input.getName(), 1, className); } catch (RhinoException re) { throw new MojoExecutionException( "Error compiling script file " + fn + " :" + re.lineNumber() + ':' + re, re); } if (bytes.length > 2) { throw new MojoExecutionException( "Compiler produced more than one class, which was not expected"); } writeFromArray((byte[]) bytes[1], output); writeFromString(source, srcOutput); } catch (IOException ioe) { throw new MojoExecutionException("Error reading or writing file: " + ioe, ioe); } } } } else { log.info("Ignoring non-existent directory " + baseDir.getPath()); } }
From source file:io.cloudslang.lang.enforcer.SpringCleansingRule.java
License:Open Source License
private void applyForJavaSourcesInRoot(final String path, final Log log) throws EnforcerRuleException { Iterator<File> fileIterator = iterateFiles(new File(path), new String[] { JAVA }, true); while (fileIterator.hasNext()) { File source = fileIterator.next(); if (isRegularFile(source.toPath(), NOFOLLOW_LINKS)) { if (log.isDebugEnabled()) { log.debug(format(STARTED_SCANNING_ORG_SPRINGFRAMEWORK, source.getAbsolutePath())); }/*ww w . j a v a2s. c om*/ try { String contents = readFileToString(source, UTF_8.displayName()); if (isSpringConfigurationAnnotatedClass(contents)) { log.info(format("Skipping verification for Spring configuration class in file '%s'", source.getAbsolutePath())); continue; } // At this point it is clear this is a regular Java class that is not a Spring Configuration class // and just validate we don't have org.springframework in it findMatchesUsingPattern(source, log, contents, patternImport, FOUND_USAGE_OF_ORG_SPRINGFRAMEWORK_IN_IMPORT_AT_LINE); findMatchesUsingPattern(source, log, contents, patternCodeLine, FOUND_USAGE_OF_ORG_SPRINGFRAMEWORK_IN_CODE_FRAGMENT_AT_LINE); } catch (IOException ignore) { log.error(format("Could not process file '%s'", source)); } if (log.isDebugEnabled()) { log.debug(format(FINISHED_SCANNING_ORG_SPRINGFRAMEWORK, source.getAbsolutePath())); } } } }
From source file:io.cloudslang.lang.enforcer.SpringCleansingRule.java
License:Open Source License
private void findMatchesUsingPattern(final File javaFile, final Log log, final String contents, final Pattern pattern, String message) throws EnforcerRuleException { Matcher matcherImportForFile = pattern.matcher(contents); if (matcherImportForFile.find()) { int lineNumber = findLineNumber(contents.substring(0, matcherImportForFile.start())); log.info(format(FOUND_UNWANTED_OCCURRENCE_OF_ORG_SPRINGFRAMEWORK, lineNumber, javaFile.getAbsolutePath())); if (shouldFail) { throw new EnforcerRuleException( message + valueOf(lineNumber) + IN_SOURCE + javaFile.getAbsolutePath() + "'"); }// w w w . j a v a 2 s. c om } }
From source file:io.fabric8.maven.AbstractProfileMojo.java
License:Apache License
public static void combineProfileFilesToFolder(MavenProject reactorProject, File buildDir, Log log, String reactorProjectOutputPath) throws IOException { File basedir = reactorProject.getBasedir(); if (!basedir.exists()) { log.warn("No basedir " + basedir.getAbsolutePath() + " for project + " + reactorProject); return;/*from w w w .j a v a2s . c o m*/ } File outDir = new File(basedir, reactorProjectOutputPath); if (!outDir.exists()) { log.warn("No profile output dir at: " + outDir.getAbsolutePath() + " for project + " + reactorProject + " so ignoring this project."); return; } log.info("Copying profiles from " + outDir.getAbsolutePath() + " into the output directory: " + buildDir); appendProfileConfigFiles(outDir, buildDir); }
From source file:io.fabric8.maven.ApplyMojo.java
License:Apache License
/** * Should we try to create a route for the given service? * <p/>// www . j av a 2s . co m * By default lets ignore the kubernetes services and any service which does not expose ports 80 and 443 * * @return true if we should create an OpenShift Route for this service. */ protected static boolean shouldCreateRouteForService(Log log, Service service, String id) { if ("kubernetes".equals(id) || "kubernetes-ro".equals(id)) { return false; } Set<Integer> ports = KubernetesHelper.getPorts(service); log.debug("Service " + id + " has ports: " + ports); if (ports.size() == 1) { return true; } else { log.info("Not generating route for service " + id + " as only single port services are supported. Has ports: " + ports); return false; } }
From source file:io.fabric8.maven.CreateRoutesMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException, MojoFailureException { try {/*ww w .j a v a 2 s . co m*/ KubernetesClient kubernetes = getKubernetes(); Controller controller = createController(); String namespace = getNamespace(); Log log = getLog(); log.info("Querying services in namespace: " + namespace + " on Kubernetes address: " + kubernetes.getMasterUrl()); ServiceList services = kubernetes.services().inNamespace(namespace).list(); if (services != null) { List<Service> items = services.getItems(); if (items != null) { log.info("Found " + items.size() + " service(s)"); String routeDomainPostfix = routeDomain; for (Service service : items) { Route route = ApplyMojo.createRouteForService(routeDomainPostfix, namespace, service, log); if (route != null) { controller.applyRoute(route, "Service " + getName(service)); } } } } } catch (Exception e) { throw new MojoExecutionException("Failed to load environment schemas: " + e, e); } }
From source file:io.fabric8.maven.plugin.AbstractDeployMojo.java
License:Apache License
/** * Should we try to create an external URL for the given service? * <p/>/*w ww . j a va 2 s .co m*/ * By default lets ignore the kubernetes services and any service which does not expose ports 80 and 443 * * @return true if we should create an OpenShift Route for this service. */ protected static boolean shouldCreateExternalURLForService(Log log, Service service, String id) { if ("kubernetes".equals(id) || "kubernetes-ro".equals(id)) { return false; } Set<Integer> ports = KubernetesHelper.getPorts(service); log.debug("Service " + id + " has ports: " + ports); if (ports.size() == 1) { String type = null; ServiceSpec spec = service.getSpec(); if (spec != null) { type = spec.getType(); if (Objects.equals(type, "LoadBalancer")) { return true; } } log.info("Not generating route for service " + id + " type is not LoadBalancer: " + type); return false; } else { log.info("Not generating route for service " + id + " as only single port services are supported. Has ports: " + ports); return false; } }
From source file:io.fabric8.maven.plugin.AbstractDeployMojo.java
License:Apache License
protected void createIngress(Controller controller, KubernetesClient kubernetesClient, Collection<HasMetadata> collection) { String routeDomainPostfix = this.routeDomain; Log log = getLog(); String namespace = clusterAccess.getNamespace(); List<Ingress> ingressList = null; // lets get the routes first to see if we should bother try {/* w w w .ja v a2 s.co m*/ IngressList ingresses = kubernetesClient.extensions().ingresses().inNamespace(namespace).list(); if (ingresses != null) { ingressList = ingresses.getItems(); } } catch (Exception e) { log.warn("Cannot load Ingress instances. Must be an older version of Kubernetes? Error: " + e, e); return; } List<Ingress> ingresses = new ArrayList<>(); for (Object object : collection) { if (object instanceof Service) { Service service = (Service) object; if (!serviceHasIngressRule(ingressList, service)) { Ingress ingress = createIngressForService(routeDomainPostfix, namespace, service, log); if (ingress != null) { ingresses.add(ingress); log.info("Created ingress for " + namespace + ":" + KubernetesHelper.getName(service)); } else { log.debug("No ingress required for " + namespace + ":" + KubernetesHelper.getName(service)); } } else { log.info("Already has ingress for service " + namespace + ":" + KubernetesHelper.getName(service)); } } } collection.addAll(ingresses); }
From source file:io.fabric8.maven.plugin.mojo.build.ApplyMojo.java
License:Apache License
protected void createIngress(Controller controller, KubernetesClient kubernetesClient, Collection<HasMetadata> collection) { String routeDomainPostfix = this.routeDomain; Log log = getLog(); String namespace = clusterAccess.getNamespace(); List<Ingress> ingressList = null; // lets get the routes first to see if we should bother try {/*from w w w . j av a2 s .co m*/ IngressList ingresses = kubernetesClient.extensions().ingresses().inNamespace(namespace).list(); if (ingresses != null) { ingressList = ingresses.getItems(); } } catch (Exception e) { log.warn("Cannot load Ingress instances. Must be an older version of Kubernetes? Error: " + e, e); return; } List<Ingress> ingresses = new ArrayList<>(); for (Object object : collection) { if (object instanceof Service) { Service service = (Service) object; if (!serviceHasIngressRule(ingressList, service)) { Ingress ingress = createIngressForService(routeDomainPostfix, namespace, service); if (ingress != null) { ingresses.add(ingress); log.info("Created ingress for " + namespace + ":" + KubernetesHelper.getName(service)); } else { log.debug("No ingress required for " + namespace + ":" + KubernetesHelper.getName(service)); } } else { log.info("Already has ingress for service " + namespace + ":" + KubernetesHelper.getName(service)); } } } collection.addAll(ingresses); }
From source file:io.fabric8.maven.ZipMojo.java
License:Apache License
protected static void combineAppFilesToFolder(MavenProject reactorProject, File buildDir, Log log, String reactorProjectOutputPath) throws IOException { File basedir = reactorProject.getBasedir(); if (!basedir.exists()) { log.warn("No basedir " + basedir.getAbsolutePath() + " for project + " + reactorProject); return;/*from w w w.jav a 2s. c o m*/ } File outDir = new File(basedir, reactorProjectOutputPath); if (!outDir.exists()) { log.warn("No app output dir at: " + outDir.getAbsolutePath() + " for project + " + reactorProject + " so ignoring this project."); return; } log.info("Copying apps from " + outDir.getAbsolutePath() + " into the output directory: " + buildDir); File[] files = outDir.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { appendAppConfigFiles(file, buildDir); } } } }