本文整理汇总了Java中org.apache.maven.model.Resource.setDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.setDirectory方法的具体用法?Java Resource.setDirectory怎么用?Java Resource.setDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.model.Resource
的用法示例。
在下文中一共展示了Resource.setDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
final Resource resource = new Resource();
resource.setDirectory(outputDir.getCanonicalPath());
project.addResource(resource);
final Set<File> generated = new HashSet<>();
final ReadApiClientData reader = new ReadApiClientData();
final List<ModelData<?>> modelList = reader.readDataFromFile("io/syndesis/dao/deployment.json");
for (final ModelData<?> model : modelList) {
if (model.getKind() == Kind.Connector) {
final Connector connector = (Connector) model.getData();
for (final ConnectorAction action : connector.getActions()) {
process(generated, connector, action, action.getInputDataShape());
process(generated, connector, action, action.getOutputDataShape());
}
}
}
} catch (final IOException e) {
throw new MojoFailureException(e.getMessage(), e);
}
}
示例2: install
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Override
public boolean install() {
if (!this.isInstalled()) {
getResourceDirectories().forEach(DirectoryResource::mkdirs);
}
// Update Maven model - main resource only
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
Resource main = new Resource();
main.setDirectory("${project.basedir}/src/main/" + name);
pom.getBuild().getResources().add(main);
maven.setModel(pom);
return true;
}
示例3: execute
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
/**
* Triggers thee execution of SJS compilation.
*
* @throws MojoExecutionException
* whenever an unexpected error occurs when executing mojo.
*/
@Override
public void execute() throws MojoExecutionException {
if (isChangeDetected()) {
try {
runSjsCompilation();
} catch (IOException | DependencyResolutionRequiredException | ScriptException | ResourceException ex) {
throw new MojoExecutionException(
"An unexpected exception occurred when running SJS compilation.", ex);
}
} else {
getLog().info("No change detected. Skipping generation.");
}
Resource outputResource = new Resource();
outputResource.setDirectory(outputDir.getPath());
project.addResource(outputResource);
}
示例4: execute
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
/**
* Main plugin execution
*/
public void execute()
{
for ( Resource resource : resources )
{
// Check for relative paths in the resource configuration.
// http://maven.apache.org/plugin-developers/common-bugs.html#Resolving_Relative_Paths
File resourceDir = new File( resource.getDirectory() );
if ( !resourceDir.isAbsolute() )
{
resourceDir = new File( project.getBasedir(), resource.getDirectory() );
resource.setDirectory( resourceDir.getAbsolutePath() );
}
addResource( resource );
}
}
示例5: setupMavenPaths
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
/**
* Updates XJC's compilePath ans resources and update hyperjaxb2's
* resources, that is, *.hbm.xml files and hibernate.config.xml file.
*
* @param xjcOpts
* @throws MojoExecutionException
*/
protected void setupMavenPaths() {
super.setupMavenPaths();
final Resource resource = new Resource();
resource.setDirectory(getGenerateDirectory().getPath());
for (String resourceInclude : resourceIncludes) {
resource.addInclude(resourceInclude);
}
getProject().addResource(resource);
if (this.roundtripTestClassName != null) {
getProject().addTestCompileSourceRoot(
getGenerateDirectory().getPath());
}
}
示例6: getResources
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
Resource[] getResources() throws MojoExecutionException {
final Resource resourceNonGenerated = new Resource();
resourceNonGenerated.setDirectory(getTopDirectory().getPath());
try {
addNonPartialsToResources(getTopDirectory(),resourceNonGenerated);
} catch (CodeGenException e) {
throw new MojoExecutionException("Couldn't add non partial specifications to resources");
}
if (resourceNonGenerated.getIncludes().isEmpty()) {
resourceNonGenerated.addExclude("**/*");
}
Resource resourceGenerated = new Resource();
final File specificationOutputDir = getSpecificationOutput();
resourceGenerated.setDirectory(specificationOutputDir.getPath());
resourceGenerated.addInclude("**/*.json");
final Resource[] resources = {resourceNonGenerated,resourceGenerated};
return resources;
}
示例7: filterAndCopy
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private static void filterAndCopy(AbstractWisdomMojo mojo, MavenResourcesFiltering filtering, File in, File out) throws IOException {
Resource resource = new Resource();
resource.setDirectory(in.getAbsolutePath());
resource.setFiltering(true);
resource.setTargetPath(out.getAbsolutePath());
List<String> excludedExtensions = new ArrayList<>();
excludedExtensions.addAll(filtering.getDefaultNonFilteredFileExtensions());
excludedExtensions.addAll(NON_FILTERED_EXTENSIONS);
MavenResourcesExecution exec = new MavenResourcesExecution(ImmutableList.of(resource), out, mojo.project,
"UTF-8", Collections.<String>emptyList(), excludedExtensions, mojo.session);
exec.setEscapeString("\\");
try {
filtering.filterResources(exec);
} catch (MavenFilteringException e) {
throw new IOException("Error while copying resources", e);
}
}
示例8: testMojoHandlingSchemaInvalidBpmn
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Test
public void testMojoHandlingSchemaInvalidBpmn()
throws XPathExpressionException, SAXException, IOException,
MojoExecutionException {
Resource res = new Resource();
res.setDirectory("src/test/invalid-resources");
mojo.resources.add(res);
mojo.application = "Yaoqiang BPMN Editor 2.2.6";
mojo.execute();
assertTrue(overview.exists());
Document document = docBuilder.parse(overview);
XPathExpression xpath = createXpathExpression("//div[@class=\"test\" and @testcase=\"A.1.0\" and contains(@tool, \"Yaoqiang\")]");
NodeList nodes = (NodeList) xpath.evaluate(document,
XPathConstants.NODESET);
Node invalidNode = nodes.item(0);
// There should be 2 findings: an invalid element and an invalid
// attribute
assertEquals("2",
invalidNode.getAttributes().getNamedItem("data-xsd-finding")
.getNodeValue());
}
示例9: getResourceList
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private List<Resource> getResourceList() {
final Resource resource = new Resource();
resource.setDirectory("/");
resource.setTargetPath("/");
final List<Resource> resources = new ArrayList<>();
resources.add(resource);
return resources;
}
示例10: getResources
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
protected List<Resource> getResources() {
final Resource resource = new Resource();
resource.setDirectory(getBuildDirectoryAbsolutePath());
resource.setTargetPath("/");
resource.setFiltering(false);
resource.setIncludes(Arrays.asList("*.jar"));
return Arrays.asList(resource);
}
示例11: handleWebResources
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
/**
* Handles the web resources.
*
* @param context the packaging context
* @throws MojoExecutionException if a resource could not be copied
*/
protected void handleWebResources( WarPackagingContext context )
throws MojoExecutionException
{
for ( Resource resource : webResources )
{
// MWAR-246
if ( resource.getDirectory() == null )
{
throw new MojoExecutionException( "The <directory> tag is missing from the <resource> tag." );
}
if ( !( new File( resource.getDirectory() ) ).isAbsolute() )
{
resource.setDirectory( context.getProject().getBasedir() + File.separator + resource.getDirectory() );
}
// Make sure that the resource directory is not the same as the webappDirectory
if ( !resource.getDirectory().equals( context.getWebappDirectory().getPath() ) )
{
try
{
copyResources( context, resource );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Could not copy resource [" + resource.getDirectory() + "]", e );
}
}
}
}
示例12: createGeneratedDir
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private File createGeneratedDir(File buildDir) {
File generatedDir = new File(buildDir, "generated-resources");
Resource resource = new Resource();
resource.setDirectory(generatedDir.getPath());
project.addResource(resource);
return generatedDir;
}
示例13: addingCompileSource
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private void addingCompileSource()
{
String generatedSourcePath = getGeneratedResourceFolder();
File generatedSourcesDir = new File(generatedSourcePath);
getLog().info("Adding " + generatedSourcePath + " to compile source.");
project.addCompileSourceRoot(generatedSourcesDir.getAbsolutePath());
Resource resource = new Resource();
resource.setDirectory(generatedSourcesDir.getAbsolutePath());
resource.setFiltering(false);
project.addResource(resource);
buildContext.refresh(generatedSourcesDir);
}
示例14: execute
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Override
public void execute() {
try {
sourceDirectory = makeAbsolute(sourceDirectory);
outputDirectory = makeAbsolute(outputDirectory);
if ( ! sourceDirectory.exists() ) return;
getLog().debug("Running ApiGen\n\tsourceDirectory=" + sourceDirectory +
"\n\toutputDirectory=" + outputDirectory);
ClassLoader cp = getCompileClassLoader();
ApiGen apiGen = new ApiGen.Builder()
.withOutputDirectory(outputDirectory.toPath())
.withGuiceModuleName(guiceModuleName)
.withDefaultPackageName(defaultPackageName)
.build();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cp);
for ( org.springframework.core.io.Resource resource : resolver.getResources("classpath*:graphql-apigen-schema/*.graphql{,s}") ) {
URL url = resource.getURL();
getLog().debug("Processing "+url);
apiGen.addForReference(url);
}
findGraphql(sourceDirectory, apiGen::addForGeneration);
apiGen.generate();
Resource schemaResource = new Resource();
schemaResource.setTargetPath("graphql-apigen-schema");
schemaResource.setFiltering(false);
schemaResource.setIncludes(Arrays.asList("*.graphqls","*.graphql"));
schemaResource.setDirectory(sourceDirectory.toString());
project.addResource(schemaResource);
project.addCompileSourceRoot(outputDirectory.getAbsolutePath());
} catch (Exception e) {
String msg = e.getMessage();
if ( null == msg ) msg = e.getClass().getName();
getLog().error(msg + " when trying to build sources from graphql.", e);
}
}
示例15: execute
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void execute() throws MojoExecutionException {
getLog().info("Writing plugin description file to " + outputDescriptionFile);
try {
PluginDescription description = new PluginDescription(new MavenArtifact(project.getArtifact()),
((Set<Artifact>) project.getArtifacts()).stream()
.filter(artifact -> Artifact.SCOPE_COMPILE.equals(artifact.getScope()))
.filter(artifact -> !artifact.isOptional())
.filter(artifact -> excludes == null || !excludes.contains(artifact.getGroupId() + ":" + artifact.getArtifactId()))
.map(MavenArtifact::new)
.collect(toSet()));
File outputDescriptionFileParent = outputDescriptionFile.getParentFile();
if (!outputDescriptionFileParent.exists()) {
outputDescriptionFileParent.mkdirs();
}
try (Writer writer = new OutputStreamWriter(new BufferedOutputStream(buildContext.newFileOutputStream(outputDescriptionFile)), "UTF-8")) {
gson.toJson(description, writer);
}
Resource resource = new Resource();
resource.setDirectory(outputDescriptionFile.getParentFile().getAbsolutePath());
resource.setIncludes(Arrays.asList(outputDescriptionFile.getName()));
resource.setTargetPath(outputTarget);
project.addResource(resource);
File descriptionArtifact = new File(artifactOutputDir, project.getArtifactId() + "-" + project.getVersion() + "-lolixl-plugin.json");
FileUtils.copyFile(outputDescriptionFile, descriptionArtifact);
projectHelper.attachArtifact(project, "json", "lolixl-plugin", descriptionArtifact);
} catch (IOException e) {
throw new MojoExecutionException("Couldn't generate plugin description file", e);
}
}