org.apache.maven.model.FileSet Java Examples
The following examples show how to use
org.apache.maven.model.FileSet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckFormatMojo.java From xml-maven-plugin with Apache License 2.0 | 5 votes |
/** * A {@link DirectoryScanner} boiler plate. * * @param fileSet {@link FileSet} to scan * @return the included paths */ private String[] scan( FileSet fileSet ) { File basedir = new File( fileSet.getDirectory() ); if ( !basedir.exists() || !basedir.isDirectory() ) { return null; } DirectoryScanner scanner = new DirectoryScanner(); List<String> includes = fileSet.getIncludes(); List<String> excludes = fileSet.getExcludes(); if ( includes != null && includes.size() > 0 ) { scanner.setIncludes( includes.toArray( new String[0] ) ); } if ( excludes != null && excludes.size() > 0 ) { scanner.setExcludes( excludes.toArray( new String[0] ) ); } scanner.setBasedir( basedir ); scanner.scan(); return scanner.getIncludedFiles(); }
Example #2
Source File: AbstractXJC2Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 5 votes |
protected List<URI> createResourceEntryUris(ResourceEntry resourceEntry, String defaultDirectory, String[] defaultIncludes, String[] defaultExcludes) throws MojoExecutionException { if (resourceEntry == null) { return Collections.emptyList(); } else { final List<URI> uris = new LinkedList<URI>(); if (resourceEntry.getFileset() != null) { final FileSet fileset = resourceEntry.getFileset(); uris.addAll(createFileSetUris(fileset, defaultDirectory, defaultIncludes, defaultExcludes)); } if (resourceEntry.getUrl() != null) { String urlDraft = resourceEntry.getUrl(); uris.add(createUri(urlDraft)); } if (resourceEntry.getDependencyResource() != null) { final String systemId = resourceEntry.getDependencyResource() .getSystemId(); try { URI uri = new URI(systemId); uris.add(uri); } catch (URISyntaxException e) { throw new MojoExecutionException( MessageFormat.format( "Could not create the resource entry URI from the following system id: [{0}].", systemId), e); } } return uris; } }
Example #3
Source File: SignCodeMojo.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public void execute() throws MojoExecutionException { List<File> filesToSign = new ArrayList<>(); if ( includeProjectArtifact ) filesToSign.add(project.getArtifact().getFile()); if ( artifactSets != null ) { for ( FileSet artifactSet : artifactSets ) { File base = new File(project.getBasedir(), artifactSet.getDirectory()); Scanner scanner = buildContext.newScanner(base); scanner.setIncludes(artifactSet.getIncludes().toArray(new String[0])); scanner.setExcludes(artifactSet.getExcludes().toArray(new String[0])); scanner.scan(); for ( String file : scanner.getIncludedFiles() ) { filesToSign.add(new File(base, file)); } } } if ( filesToSign.isEmpty() ) { getLog().info("No files to sign, skipping"); return; } for ( File toSign : filesToSign ) getLog().info("Would sign " + toSign); // Set up the TLS client System.setProperty("javax.net.ssl.keyStore", keyStore); System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword); String oldSslDebug = null; if ( sslDebug ) { oldSslDebug = System.setProperty("javax.net.debug","all"); } SignedFiles signedFiles = new SignedFiles(filesToSign); try { String signingSetID = makeSigningRequest(signedFiles); downloadSignedFiles(signedFiles, signingSetID); } catch (SOAPException | IOException e) { throw new MojoExecutionException("Signing failed : " + e.getMessage(), e); } finally { if ( sslDebug ) { if ( oldSslDebug != null ) { System.setProperty("javax.net.debug", oldSslDebug); } else { System.clearProperty("javax.net.debug"); } } } }
Example #4
Source File: ResourceEntry.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 4 votes |
public FileSet getFileset() { return fileset; }
Example #5
Source File: ResourceEntry.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 4 votes |
public void setFileset(FileSet fileset) { this.fileset = fileset; }
Example #6
Source File: AbstractXJC2Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 4 votes |
private List<URI> createFileSetUris(final FileSet fileset, String defaultDirectory, String[] defaultIncludes, String defaultExcludes[]) throws MojoExecutionException { final String draftDirectory = fileset.getDirectory(); final String directory = draftDirectory == null ? defaultDirectory : draftDirectory; final List<String> includes; @SuppressWarnings("unchecked") final List<String> draftIncludes = (List<String>) fileset.getIncludes(); if (draftIncludes == null || draftIncludes.isEmpty()) { includes = defaultIncludes == null ? Collections .<String> emptyList() : Arrays.asList(defaultIncludes); } else { includes = draftIncludes; } final List<String> excludes; @SuppressWarnings("unchecked") final List<String> draftExcludes = (List<String>) fileset.getExcludes(); if (draftExcludes == null || draftExcludes.isEmpty()) { excludes = defaultExcludes == null ? Collections .<String> emptyList() : Arrays.asList(defaultExcludes); } else { excludes = draftExcludes; } String[] includesArray = includes.toArray(new String[includes.size()]); String[] excludesArray = excludes.toArray(new String[excludes.size()]); try { final List<File> files = IOUtils.scanDirectoryForFiles( getBuildContext(), new File(directory), includesArray, excludesArray, !getDisableDefaultExcludes()); final List<URI> uris = new ArrayList<URI>(files.size()); for (final File file : files) { // try { final URI uri = file.toURI(); uris.add(uri); // } catch (MalformedURLException murlex) { // throw new MojoExecutionException( // MessageFormat.format( // "Could not create an URL for the file [{0}].", // file), murlex); // } } return uris; } catch (IOException ioex) { throw new MojoExecutionException( MessageFormat .format("Could not scan directory [{0}] for files with inclusion [{1}] and exclusion [{2}].", directory, includes, excludes)); } }
Example #7
Source File: FileSetUtils.java From hadoop with Apache License 2.0 | 3 votes |
/** * Converts a Maven FileSet to a list of File objects. * * @param source FileSet to convert * @return List containing every element of the FileSet as a File * @throws IOException if an I/O error occurs while trying to find the files */ @SuppressWarnings("unchecked") public static List<File> convertFileSetToFiles(FileSet source) throws IOException { String includes = getCommaSeparatedList(source.getIncludes()); String excludes = getCommaSeparatedList(source.getExcludes()); return FileUtils.getFiles(new File(source.getDirectory()), includes, excludes); }
Example #8
Source File: FileSetUtils.java From big-c with Apache License 2.0 | 3 votes |
/** * Converts a Maven FileSet to a list of File objects. * * @param source FileSet to convert * @return List containing every element of the FileSet as a File * @throws IOException if an I/O error occurs while trying to find the files */ @SuppressWarnings("unchecked") public static List<File> convertFileSetToFiles(FileSet source) throws IOException { String includes = getCommaSeparatedList(source.getIncludes()); String excludes = getCommaSeparatedList(source.getExcludes()); return FileUtils.getFiles(new File(source.getDirectory()), includes, excludes); }
Example #9
Source File: FileSetUtils.java From tajo with Apache License 2.0 | 3 votes |
/** * Converts a Maven FileSet to a list of File objects. * * @param source FileSet to convert * @return List<File> containing every element of the FileSet as a File * @throws IOException if an I/O error occurs while trying to find the files */ @SuppressWarnings("unchecked") public static List<File> convertFileSetToFiles(FileSet source) throws IOException { String includes = getCommaSeparatedList(source.getIncludes()); String excludes = getCommaSeparatedList(source.getExcludes()); return FileUtils.getFiles(new File(source.getDirectory()), includes, excludes); }