public boolean isFrameworkVersionExisting(String frameworkVersion) throws MojoExecutionException, IOException File file = PathUtil.buildSettingsFilePath( settingsPath );
/** * Returns the path of the artifact within the user assembly cache. * * @param artifact the artifact to find the path of. This value should not be null. * @param localRepository the local repository. This value should not be null. * @return the path of the artifact within the user assembly cache or null if either of the specified * parameters is null */ public static File getUserAssemblyCacheFileFor( Artifact artifact, File localRepository ) { if ( artifact == null ) { logger.warning( "NPANDAY-040-005: Artifact is null - Cannot get application file." ); return null; } if ( localRepository == null ) { logger.warning( "NPANDAY-040-006: Local Repository is null - Cannot get application file." ); return null; } return getDotNetArtifact( artifact , localRepository ); }
public void execute() throws MojoExecutionException, MojoFailureException { for (Artifact dependency : dependencies) { try { String filename = dependency.getArtifactId() + "." + dependency.getArtifactHandler().getExtension(); File targetFile = new File(binDir, filename); if (!targetFile.exists()) { getLog().debug("NPANDAY-000-0001: copy dependency: typeof:" + dependency.getClass()); getLog().debug("NPANDAY-000-0001: copy dependency: " + dependency); getLog().debug("NPANDAY-000-0002: copying " + dependency.getFile().getAbsolutePath() + " to " + targetFile); File sourceFile = PathUtil.getGACFile4Artifact(dependency); FileUtils.copyFile(sourceFile, targetFile); } } catch (IOException ioe) { throw new MojoExecutionException("NPANDAY-000-00002: Error copying dependency " + dependency, ioe); } } }
source = new File( localRepository + File.separator + getTokenizedPath(artifact.getGroupId() ) + File.separator + artifact.getArtifactId() + File.separator + artifact.getVersion() + File.separator + artifact.getArtifactId() + "-" + artifact.getVersion() + classifier +"." + ext ); source = new File( System.getProperty( "user.home" ),".m2" + File.separator + "repository" + File.separator + getTokenizedPath(artifact.getGroupId() ) + File.separator + artifact.getArtifactId() + File.separator + artifact.getVersion() + File.separator + artifact.getArtifactId() + "-" + artifact.getVersion() +"." + ext ); File dotnetFile = getDotNetArtifact( artifact, source.toString() );
artifactFile = PathUtil.getGlobalAssemblyCacheFileFor( assembly, new File("C:\\WINDOWS\\assembly\\") ); artifactFile = PathUtil.getGACFile4Artifact(assembly); artifactFile = PathUtil.getUserAssemblyCacheFileFor( assembly, new File( System.getProperty( "user.home" ), File.separator + ".m2" + File.separator + "repository") );
/** * Creates an artifact using information from the specified project. * * @param project a project to use as the source of the returned artifact * @param artifactFactory artifact factory used to create the artifact * @param localRepository the local repository * @return an artifact using information from the specified project */ public static Artifact createArtifactFrom( Project project, ArtifactFactory artifactFactory, File localRepository ) { logAndVerifyProjectParameters( project ); Artifact assembly = artifactFactory.createArtifactWithClassifier( project.getGroupId(), project.getArtifactId(), project.getVersion(), project.getArtifactType(), project.getPublicKeyTokenId() ); File artifactFile = ( ( ArtifactTypeHelper.isDotnetAnyGac( project.getArtifactType() ) ) ) ? PathUtil.getGlobalAssemblyCacheFileFor( assembly, localRepository) : PathUtil.getDotNetArtifact( assembly, localRepository ) ; assembly.setFile( artifactFile ); return assembly; }
public NetExecutable getPluginLoaderFor(Artifact artifact, VendorInfo vendorInfo, String localRepository, File parameterFile, String mojoName) throws PlatformUnsupportedException { //AssemblyRepositoryLayout layout = new AssemblyRepositoryLayout(); File artifactPath = PathUtil.getPrivateApplicationBaseFileFor( artifact, new File( localRepository ) ); List<String> commands = new ArrayList<String>(); commands.add( "parameterFile=" + parameterFile.getAbsolutePath() ); commands.add( "assemblyFile=" + artifactPath.getAbsolutePath() ); commands.add( "mojoName=" + mojoName );//ArtifactId = namespace Artifact pluginLoaderArtifact = artifactContext.getArtifactsFor( "org.apache.npanday.plugins", "NPanday.Plugin.Loader", null, null ).get( 0 ); artifactPath = PathUtil.getPrivateApplicationBaseFileFor( pluginLoaderArtifact, new File( localRepository ) ); commands.add( "startProcessAssembly=" + artifactPath.getAbsolutePath() ); return getNetExecutableFromRepository( "org.apache.npanday.plugins", "NPanday.Plugin.Runner", vendorInfo, new File( localRepository ), commands, false ); }
FileUtils.copyFileToDirectory( configExeFile, PathUtil.getUserAssemblyCacheFileFor( artifact,localRepository ).getParentFile() );
public File getExecutionPath() { String executable; try { executable = getExecutable(); } catch ( ExecutionException e ) { return null; } List<String> executablePaths = executableContext.getExecutableConfig().getExecutionPaths(); if ( executablePaths != null ) { for ( String executablePath : executablePaths ) { if ( PathUtil.containsExecutable(executablePath, executable) ) { logger.info("NPANDAY-070-003: Found executable path for " + executable + ": " + executablePath); return new File( executablePath ); } } } logger.warn("NPANDAY-070-004: Did not find path for " + executable + " in " + executablePaths); return null; }
public File getRepositoryPath( File localRepository ) { File basedir = PathUtil.getMavenLocalRepositoryFileFor( artifact, localRepository ).getParentFile(); StringBuffer buffer = new StringBuffer(); buffer.append( artifact.getArtifactId() ).append( "-" ).append( artifact.getVersion() ); if ( artifact.getClassifier() != null ) { buffer.append( "-" ).append( artifact.getClassifier() ); } buffer.append( ".exe.config" ); return new File( basedir, buffer.toString() ); }
/** * Return the registered settings, or create from configured (-Dnpanday-settings=...) or default settings file location (.m2/npanday-settings.xml) * @param repositoryRegistry The registry. * @return The current, or just created SettingsRepository * @throws SettingsException If anything goes wrong reading or registering the settings */ public static SettingsRepository getOrPopulateSettingsRepository( RepositoryRegistry repositoryRegistry) throws SettingsException { String settingsFolder = PathUtil.getHomeM2Folder(); String customFolder = System.getProperty( "npanday.settings" ); if ( !StringUtils.isEmpty( customFolder ) ) { settingsFolder = customFolder; } return getOrPopulateSettingsRepository(repositoryRegistry, settingsFolder ); }
File artifactPath = PathUtil.getPrivateApplicationBaseFileFor( artifact, localRepository ); commands.add( "startProcessAssembly=" + artifactPath.getAbsolutePath() ); String pluginArtifactPath = PathUtil.getPrivateApplicationBaseFileFor( artifactContext.getArtifactsFor( "org.apache.npanday.plugins", "NPanday.Plugin", null, null ).get( 0 ), localRepository ).getAbsolutePath(); File artifactPath = PathUtil.getPrivateApplicationBaseFileFor( artifact, localRepository ); List<String> modifiedCommands = new ArrayList<String>(); String exe = null;
/** * @see ArtifactContext#getArtifactsFor(String, String, String, String) */ public List<Artifact> getArtifactsFor( String groupId, String artifactId, String version, String type ) { NetDependenciesRepositoryImpl repository = (NetDependenciesRepositoryImpl) repositoryRegistry.find( "net-dependencies" ); if ( repository == null ) { logger.warn( "NPANDAY-000-001: Could not locate artifact (net dependencies repository not found): Group ID = " + groupId + ", Artifact ID = " + artifactId + ", Version = " + version + ", Type = " + type ); return new ArrayList<Artifact>(); } repository.init( artifactFactory ); List<Artifact> artifacts = repository.getArtifactsFor( groupId, artifactId, version, type ); for ( Artifact artifact : artifacts ) { logger.debug("NPANDAY-000-002: set file"); artifact.setFile( PathUtil.getUserAssemblyCacheFileFor( artifact, getLocalRepository() ) ); } return artifacts; }
/** * @see npanday.executable.compiler.CompilerExecutable#getExecutionPath() */ public File getExecutionPath() { String executable; try { executable = getExecutable(); } catch ( ExecutionException e ) { return null; } List<String> executablePaths = compilerContext.getNetCompilerConfig().getExecutionPaths(); if ( executablePaths != null ) { for ( String executablePath : executablePaths ) { if ( PathUtil.containsExecutable(executablePath, executable) ) { logger.info("NPANDAY-068-005: Found executable path for " + executable + ": " + executablePath); return new File(executablePath); } } } logger.warn("NPANDAY-068-006: Did not find path for " + executable + " in " + executablePaths); return null; }
/** * Returns the path of the artifact within the private application base. * * @param artifact the artifact to find the path of. This value should not be null. * @param localRepository the local repository. This value should not be null. * @return the path of the artifact within the private application base or null if either of the specified * parameters is null */ public static File getPrivateApplicationBaseFileFor( Artifact artifact, File localRepository ) { if ( artifact == null ) { logger.warning( "NPANDAY-040-003: Artifact is null - Cannot get application file." ); return null; } if ( localRepository == null ) { logger.warning( "NPANDAY-040-004: Local Repository is null - Cannot get application file." ); return null; } return getDotNetArtifact( artifact, localRepository ); }
protected boolean isUpToDateWithPomAndSettingsAndDependencies(File targetFile) { File settingsFile = PathUtil.buildSettingsFilePath(settingsPath); Artifact latestDependencyModification = this.getLatestDependencyModification(project.getDependencyArtifacts()); //TODO: Different parameters from the command line should also cause an update //TODO: Change in resource should cause an update if (targetFile.lastModified() < pomFile.lastModified()) { getLog().info("NPANDAY-900-007: Project pom has changed. Forcing a recompile."); return false; } else if (settingsFile.exists() && targetFile.lastModified() < settingsFile.lastModified()) { getLog().info("NPANDAY-900-008:Project settings has changed. Forcing a recompile."); return false; } else if (latestDependencyModification != null && targetFile.lastModified() < latestDependencyModification.getFile().lastModified()) { getLog().info( "NPANDAY-900-009: Detected change in module dependency. Forcing a recompile: Changed Artifact = " + latestDependencyModification); return false; } return true; }
private void resolveArtifact(Artifact artifact) throws ComponentLookupException, MojoExecutionException { File localRepository = new File(getLocalRepository()); if (PathUtil.getPrivateApplicationBaseFileFor(artifact, localRepository).exists())
public File getExecutionPath() { String executable; try { executable = getExecutable(); } catch ( ExecutionException e ) { return null; } List<String> executablePaths = executableContext.getExecutableConfig().getExecutionPaths(); if ( executablePaths != null ) { for ( String executablePath : executablePaths ) { if ( PathUtil.containsExecutable(executablePath, executable) ) { logger.info("NPANDAY-063-005: Found executable path for " + executable + ": " + executablePath); return new File( executablePath ); } } } logger.warn("NPANDAY-063-006: Did not find path for " + executable + " in " + executablePaths); return null; }
return getDotNetArtifact( artifact , gacRepository );
File settingsFile = PathUtil.buildSettingsFilePath( settingsPathOrFile );