Skip to content

Commit

Permalink
[ARCHETYPE-651] add INFO when catalog updated
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Oct 7, 2023
1 parent 29048c8 commit e1feeca
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ public interface ArchetypeManager {
File archiveArchetype(File archetypeDirectory, File outputDirectory, String finalName)
throws DependencyResolutionRequiredException, IOException;

void updateLocalCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype);
File updateLocalCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype);
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,14 @@ public ArchetypeCatalog getRemoteCatalog(ProjectBuildingRequest buildingRequest)
}

@Override
public void updateLocalCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype) {
public File updateLocalCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype) {
try {
ArchetypeDataSource source = archetypeSources.get("catalog");

source.updateCatalog(buildingRequest, archetype);
return source.updateCatalog(buildingRequest, archetype);
} catch (ArchetypeDataSourceException e) {
getLogger().warn("failed to update catalog", e);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.maven.archetype.source;

import java.io.File;

import org.apache.maven.archetype.catalog.Archetype;
import org.apache.maven.archetype.catalog.ArchetypeCatalog;
import org.apache.maven.project.ProjectBuildingRequest;
Expand All @@ -36,5 +38,5 @@ public interface ArchetypeDataSource {

ArchetypeCatalog getArchetypeCatalog(ProjectBuildingRequest buildingRequest) throws ArchetypeDataSourceException;

void updateCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype) throws ArchetypeDataSourceException;
File updateCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype) throws ArchetypeDataSourceException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.maven.archetype.source;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
Expand Down Expand Up @@ -48,7 +49,7 @@ public ArchetypeCatalog getArchetypeCatalog(ProjectBuildingRequest buildingReque
}

@Override
public void updateCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype)
public File updateCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype)
throws ArchetypeDataSourceException {
throw new ArchetypeDataSourceException("Not supported yet.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class LocalCatalogArchetypeDataSource extends CatalogArchetypeDataSource
private RepositoryManager repositoryManager;

@Override
public void updateCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype)
public File updateCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype)
throws ArchetypeDataSourceException {
File localRepo = repositoryManager.getLocalRepositoryBasedir(buildingRequest);

Expand Down Expand Up @@ -83,6 +83,7 @@ public void updateCatalog(ProjectBuildingRequest buildingRequest, Archetype arch
newArchetype.setGoals(archetype.getGoals());

writeLocalCatalog(catalog, catalogFile);
return catalogFile;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public ArchetypeCatalog getArchetypeCatalog(ProjectBuildingRequest buildingReque
}

@Override
public void updateCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype)
public File updateCatalog(ProjectBuildingRequest buildingRequest, Archetype archetype)
throws ArchetypeDataSourceException {
throw new ArchetypeDataSourceException("Not supported yet.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.maven.archetype.mojos;

import java.io.File;

import org.apache.maven.archetype.ArchetypeManager;
import org.apache.maven.archetype.catalog.Archetype;
import org.apache.maven.archetype.common.Constants;
Expand Down Expand Up @@ -68,6 +70,9 @@ public void execute() throws MojoExecutionException {
archetype.setDescription(project.getName());
}

manager.updateLocalCatalog(session.getProjectBuildingRequest(), archetype);
File catalog = manager.updateLocalCatalog(session.getProjectBuildingRequest(), archetype);
if (catalog != null) {
getLog().info("Updated local archetypes catalog " + catalog);
}
}
}

0 comments on commit e1feeca

Please sign in to comment.